cvs: php4 /main SAPI.c /sapi/aolserver aolserver.c /sapi/apache mod_php4.c /sapi/cgi cgi_main.c /sapi/isapi php4isapi.c /sapi/nsapi nsapi.c
/sapi/phttpd phttpd.c /sapi/pi3web pi3web_sapi.c /sapi/roxen roxen.c /sapi/servlet servlet.c /sapi/thttpd thttpd.c
| From: | Rasmus Lerdorf | Date: | Wed, 02 Aug 2000 22:48:48 +0000 |
| Subject: | cvs: php4 /main SAPI.c /sapi/aolserver aolserver.c /sapi/apache mod_php4.c /sapi/cgi cgi_main.c /sapi/isapi php4isapi.c /sapi/nsapi nsapi.c /sapi/phttpd phttpd.c /sapi/pi3web pi3web_sapi.c /sapi/roxen roxen.c /sapi/servlet servlet.c /sapi/thttpd thttpd.c |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-1014@lists.php.net to get a copy of this message | ||
rasmus Wed Aug 2 15:48:48 2000 EDT
Modified files:
/php4/main SAPI.c
/php4/sapi/aolserver aolserver.c
/php4/sapi/apache mod_php4.c
/php4/sapi/cgi cgi_main.c
/php4/sapi/isapi php4isapi.c
/php4/sapi/nsapi nsapi.c
/php4/sapi/phttpd phttpd.c
/php4/sapi/pi3web pi3web_sapi.c
/php4/sapi/roxen roxen.c
/php4/sapi/servlet servlet.c
/php4/sapi/thttpd thttpd.c
Log:
Heads up! I have moved the headers_only and response_code checks out of
SAPI and down into the individual SAPI modules. I have made the
appropriate changes in all the SAPI modules, but please verify these.
The reason for this change is that Apache sometimes will feed PHP
a request_method of GET but have r->header_only set to true. This happens
in an ErrorDocument redirect. In this same scenario we want to preserve
the status code as well instead of just overwriting it with a 200 and
losing this information. For now the other sapi modules act exactly as
before since they probably do not make this distinction, and they may
not even have a valid response code this early in the request.
@ Fix HEAD request bug on an Apache ErrorDocument redirect and preserve
@ the status code across the redirect as well. (Rasmus)
Index: php4/main/SAPI.c
diff -u php4/main/SAPI.c:1.79 php4/main/SAPI.c:1.80
--- php4/main/SAPI.c:1.79 Tue Jul 11 07:29:38 2000
+++ php4/main/SAPI.c Wed Aug 2 15:48:41 2000
@@ -267,19 +267,27 @@
zend_llist_init(&SG(sapi_headers).headers, sizeof(sapi_header_struct), (void (*)(void *))
sapi_free_header, 0);
SG(sapi_headers).send_default_content_type = 1;
+ /*
SG(sapi_headers).http_response_code = 200;
SG(sapi_headers).http_status_line = NULL;
+ */
SG(headers_sent) = 0;
SG(read_post_bytes) = 0;
SG(request_info).post_data = NULL;
SG(request_info).current_user = NULL;
SG(request_info).current_user_length = 0;
+#if 0
+ /* This can't be done here. We need to do that in the individual SAPI
+ * modules because you can actually have a GET request that is only
+ * allowed to send back headers.
+ */
if (SG(request_info).request_method && !strcmp(SG(request_info).request_method,
"HEAD")) {
SG(request_info).headers_only = 1;
} else {
SG(request_info).headers_only = 0;
}
+#endif
if (SG(server_context)) {
if (SG(request_info).request_method
Index: php4/sapi/aolserver/aolserver.c
diff -u php4/sapi/aolserver/aolserver.c:1.43 php4/sapi/aolserver/aolserver.c:1.44
--- php4/sapi/aolserver/aolserver.c:1.43 Wed Jul 5 04:27:24 2000
+++ php4/sapi/aolserver/aolserver.c Wed Aug 2 15:48:41 2000
@@ -22,7 +22,7 @@
* - CGI/1.1 conformance
*/
-/* $Id: aolserver.c,v 1.43 2000/07/05 11:27:24 sas Exp $ */
+/* $Id: aolserver.c,v 1.44 2000/08/02 22:48:41 rasmus Exp $ */
/* conflict between PHP and AOLserver headers */
#define Debug php_Debug
@@ -207,7 +207,7 @@
NSLS_FETCH();
php_info_print_table_start();
- php_info_print_table_row(2, "SAPI module version", "$Id: aolserver.c,v 1.43
2000/07/05 11:27:24 sas Exp $");
+ php_info_print_table_row(2, "SAPI module version", "$Id: aolserver.c,v 1.44
2000/08/02 22:48:41 rasmus Exp $");
php_info_print_table_row(2, "Build date", Ns_InfoBuildDate());
php_info_print_table_row(2, "Config file path", Ns_InfoConfigFile());
php_info_print_table_row(2, "Error Log path", Ns_InfoErrorLog());
@@ -473,6 +473,12 @@
index = Ns_SetIFind(NSG(conn)->headers, "content-type");
SG(request_info).content_type = index == -1 ? NULL :
Ns_SetValue(NSG(conn)->headers, index);
+ if (!strcmp(NSG(conn)->request->method, "HEAD")) {
+ SG(request_info).headers_only = 1;
+ } else {
+ SG(request_info).headers_only = 0;
+ }
+ SG(sapi_headers).http_response_code = 200;
tmp = Ns_ConnAuthUser(NSG(conn));
if(tmp) {
Index: php4/sapi/apache/mod_php4.c
diff -u php4/sapi/apache/mod_php4.c:1.61 php4/sapi/apache/mod_php4.c:1.62
--- php4/sapi/apache/mod_php4.c:1.61 Mon Jul 31 08:07:58 2000
+++ php4/sapi/apache/mod_php4.c Wed Aug 2 15:48:42 2000
@@ -17,7 +17,7 @@
| PHP 4.0 patches by Zeev Suraski <zeev@zend.com> |
+----------------------------------------------------------------------+
*/
-/* $Id: mod_php4.c,v 1.61 2000/07/31 15:07:58 rasmus Exp $ */
+/* $Id: mod_php4.c,v 1.62 2000/08/02 22:48:42 rasmus Exp $ */
#define NO_REGEX_EXTRA_H
#ifdef WIN32
@@ -379,6 +379,8 @@
SG(request_info).request_method = (char *)r->method;
SG(request_info).content_type = (char *) table_get(r->subprocess_env,
"CONTENT_TYPE");
SG(request_info).content_length = (content_length ? atoi(content_length) : 0);
+ SG(request_info).headers_only = r->header_only;
+ SG(sapi_headers).http_response_code = r->status;
if (r->headers_in) {
authorization = table_get(r->headers_in, "Authorization");
Index: php4/sapi/cgi/cgi_main.c
diff -u php4/sapi/cgi/cgi_main.c:1.64 php4/sapi/cgi/cgi_main.c:1.65
--- php4/sapi/cgi/cgi_main.c:1.64 Sat Jul 29 07:46:09 2000
+++ php4/sapi/cgi/cgi_main.c Wed Aug 2 15:48:43 2000
@@ -315,7 +315,12 @@
SG(request_info).path_translated = NULL; /* we have to update it later, when we have that
information */
SG(request_info).content_type = getenv("CONTENT_TYPE");
SG(request_info).content_length = (content_length?atoi(content_length):0);
-
+ SG(sapi_headers).http_response_code = 200;
+ if (SG(request_info).request_method && !strcmp(SG(request_info).request_method,
"HEAD")) {
+ SG(request_info).headers_only = 1;
+ } else {
+ SG(request_info).headers_only = 0;
+ }
/* CGI does not support HTTP authentication */
SG(request_info).auth_user = NULL;
SG(request_info).auth_password = NULL;
Index: php4/sapi/isapi/php4isapi.c
diff -u php4/sapi/isapi/php4isapi.c:1.47 php4/sapi/isapi/php4isapi.c:1.48
--- php4/sapi/isapi/php4isapi.c:1.47 Mon Jun 26 11:05:51 2000
+++ php4/sapi/isapi/php4isapi.c Wed Aug 2 15:48:43 2000
@@ -463,6 +463,12 @@
SG(request_info).request_uri = lpECB->lpszPathInfo;
SG(request_info).content_type = lpECB->lpszContentType;
SG(request_info).content_length = lpECB->cbTotalBytes;
+ SG(sapi_headers).http_response_code = 200; /* I think dwHttpStatusCode is invalid at this stage
-RL */
+ if (!strcmp(lpECB->lpszMethod, "HEAD")) {
+ SG(request_info).headers_only = 1;
+ } else {
+ SG(request_info).headers_only = 0;
+ }
{
char *path_end = strrchr(SG(request_info).path_translated, SEPARATOR);
Index: php4/sapi/nsapi/nsapi.c
diff -u php4/sapi/nsapi/nsapi.c:1.9 php4/sapi/nsapi/nsapi.c:1.10
--- php4/sapi/nsapi/nsapi.c:1.9 Mon Jun 26 11:05:52 2000
+++ php4/sapi/nsapi/nsapi.c Wed Aug 2 15:48:43 2000
@@ -478,6 +478,13 @@
SG(request_info).path_translated = nsapi_strdup(path_translated);
SG(request_info).content_type = nsapi_strdup(content_type);
SG(request_info).content_length = (content_length == NULL) ? 0 : strtoul(content_length, 0, 0);
+ SG(sapi_headers).http_response_code = 200;
+ if (!strcmp(request_method, "HEAD")) {
+ SG(request_info).headers_only = 1;
+ } else {
+ SG(request_info).headers_only = 0;
+ }
+
}
static void
Index: php4/sapi/phttpd/phttpd.c
diff -u php4/sapi/phttpd/phttpd.c:1.17 php4/sapi/phttpd/phttpd.c:1.18
--- php4/sapi/phttpd/phttpd.c:1.17 Mon Jun 26 11:05:52 2000
+++ php4/sapi/phttpd/phttpd.c Wed Aug 2 15:48:43 2000
@@ -202,6 +202,12 @@
SG(request_info).query_string = PHG(cip)->hip->request;
SG(request_info).request_method = PHG(cip)->hip->method;
SG(request_info).path_translated = malloc(MAXPATHLEN+1);
+ SG(sapi_headers).http_response_code = 200;
+ if (!strcmp(PHG(cip)->hip->method, "HEAD")) {
+ SG(request_info).headers_only = 1;
+ } else {
+ SG(request_info).headers_only = 0;
+ }
if (url_expand(PHG(cip)->hip->url, SG(request_info).path_translated, MAXPATHLEN,
&PHG(sb), NULL, NULL) == NULL) {
/* handle error */
}
Index: php4/sapi/pi3web/pi3web_sapi.c
diff -u php4/sapi/pi3web/pi3web_sapi.c:1.5 php4/sapi/pi3web/pi3web_sapi.c:1.6
--- php4/sapi/pi3web/pi3web_sapi.c:1.5 Sun Jul 23 22:41:01 2000
+++ php4/sapi/pi3web/pi3web_sapi.c Wed Aug 2 15:48:44 2000
@@ -20,7 +20,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: pi3web_sapi.c,v 1.5 2000/07/24 05:41:01 david Exp $ */
+/* $Id: pi3web_sapi.c,v 1.6 2000/08/02 22:48:44 rasmus Exp $ */
#if WIN32|WINNT
# include <windows.h>
@@ -83,7 +83,7 @@
PUTS("<table border=5 width=600>\n");
PUTS("<tr><th colspan=2 bgcolor=\"" PHP_HEADER_COLOR
"\">Pi3Web Server Information</th></tr>\n");
php_info_print_table_header(2, "Information Field", "Value");
- php_info_print_table_row(2, "Pi3Web SAPI module version", "$Id: pi3web_sapi.c,v 1.5
2000/07/24 05:41:01 david Exp $");
+ php_info_print_table_row(2, "Pi3Web SAPI module version", "$Id: pi3web_sapi.c,v 1.6
2000/08/02 22:48:44 rasmus Exp $");
php_info_print_table_row(2, "Server Name Stamp", HTTPCore_getServerStamp());
snprintf(variable_buf, 511, "%d", HTTPCore_debugEnabled());
php_info_print_table_row(2, "Debug Enabled", variable_buf);
@@ -321,6 +321,12 @@
SG(request_info).content_length = lpCB->cbTotalBytes;
SG(request_info).auth_user = lpCB->lpszUser;
SG(request_info).auth_password = lpCB->lpszPassword;
+ SG(sapi_headers).http_response_code = 200;
+ if (!strcmp(lpCB->lpszMethod, "HEAD")) {
+ SG(request_info).headers_only = 1;
+ } else {
+ SG(request_info).headers_only = 0;
+ }
}
static void hash_pi3web_variables(ELS_D SLS_DC)
Index: php4/sapi/roxen/roxen.c
diff -u php4/sapi/roxen/roxen.c:1.33 php4/sapi/roxen/roxen.c:1.34
--- php4/sapi/roxen/roxen.c:1.33 Mon Jun 26 11:05:54 2000
+++ php4/sapi/roxen/roxen.c Wed Aug 2 15:48:44 2000
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: roxen.c,v 1.33 2000/06/26 18:05:54 andrei Exp $ */
+/* $Id: roxen.c,v 1.34 2000/08/02 22:48:44 rasmus Exp $ */
#include "php.h"
#ifdef HAVE_ROXEN
@@ -447,7 +447,7 @@
{
/* char buf[512]; */
php_info_print_table_start();
- php_info_print_table_row(2, "SAPI module version", "$Id: roxen.c,v 1.33 2000/06/26
18:05:54 andrei Exp $");
+ php_info_print_table_row(2, "SAPI module version", "$Id: roxen.c,v 1.34 2000/08/02
22:48:44 rasmus Exp $");
/* php_info_print_table_row(2, "Build date", Ns_InfoBuildDate());
php_info_print_table_row(2, "Config file path", Ns_InfoConfigFile());
php_info_print_table_row(2, "Error Log path", Ns_InfoErrorLog());
@@ -671,7 +671,13 @@
SG(request_info).request_method = lookup_string_header("REQUEST_METHOD",
"GET");
SG(request_info).content_length = lookup_integer_header("HTTP_CONTENT_LENGTH", 0);
SG(request_info).content_type = lookup_string_header("HTTP_CONTENT_TYPE", NULL);
-
+ SG(sapi_headers).http_response_code = 200;
+ if (!strcmp(SG(request_info).request_method, "HEAD")) {
+ SG(request_info).headers_only = 1;
+ } else {
+ SG(request_info).headers_only = 0;
+ }
+
/* FIXME: Check for auth stuff needs to be fixed... */
SG(request_info).auth_user = NULL;
SG(request_info).auth_password = NULL;
Index: php4/sapi/servlet/servlet.c
diff -u php4/sapi/servlet/servlet.c:1.34 php4/sapi/servlet/servlet.c:1.35
--- php4/sapi/servlet/servlet.c:1.34 Sun Jul 23 22:29:19 2000
+++ php4/sapi/servlet/servlet.c Wed Aug 2 15:48:45 2000
@@ -356,6 +356,12 @@
SETSTRING( SG(request_info).query_string, queryString );
SETSTRING( SG(request_info).request_uri, requestURI );
SETSTRING( SG(request_info).content_type, contentType );
+ SG(sapi_headers).http_response_code = 200;
+ if (!strcmp(SG(request_info).request_method, "HEAD")) {
+ SG(request_info).headers_only = 1;
+ } else {
+ SG(request_info).headers_only = 1;
+ }
SG(request_info).content_length = contentLength;
SG(request_info).auth_password = NULL;
if (php_request_startup(CLS_C ELS_CC PLS_CC SLS_CC)==FAILURE) {
Index: php4/sapi/thttpd/thttpd.c
diff -u php4/sapi/thttpd/thttpd.c:1.15 php4/sapi/thttpd/thttpd.c:1.16
--- php4/sapi/thttpd/thttpd.c:1.15 Mon Jun 26 11:05:55 2000
+++ php4/sapi/thttpd/thttpd.c Wed Aug 2 15:48:45 2000
@@ -245,7 +245,12 @@
snprintf(buf, 1023, "/%s", TG(hc)->origfilename);
SG(request_info).request_uri = strdup(buf);
SG(request_info).request_method = httpd_method_str(TG(hc)->method);
-
+ if (!strcmp(SG(request_info).request_method, "HEAD")) {
+ SG(request_info).headers_only = 1;
+ } else {
+ SG(request_info).headers_only = 0;
+ }
+ SG(sapi_headers).http_response_code = 200;
SG(request_info).content_type = TG(hc)->contenttype;
SG(request_info).content_length = TG(hc)->contentlength;