diff options
author | Rasmus Lerdorf <rasmus@php.net> | 2000-08-02 22:48:45 +0000 |
---|---|---|
committer | Rasmus Lerdorf <rasmus@php.net> | 2000-08-02 22:48:45 +0000 |
commit | 76a2d2538c42934341a6257f0ba54723048116df (patch) | |
tree | 14d2b166c0d75444a9ec6d3be15d45c5154c6c15 /sapi | |
parent | f896b9a354af45508431900a70f7af9ce943aba4 (diff) | |
download | php-git-76a2d2538c42934341a6257f0ba54723048116df.tar.gz |
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)
Diffstat (limited to 'sapi')
-rw-r--r-- | sapi/aolserver/aolserver.c | 6 | ||||
-rw-r--r-- | sapi/apache/mod_php4.c | 2 | ||||
-rw-r--r-- | sapi/cgi/cgi_main.c | 7 | ||||
-rw-r--r-- | sapi/isapi/php4isapi.c | 6 | ||||
-rw-r--r-- | sapi/nsapi/nsapi.c | 7 | ||||
-rw-r--r-- | sapi/phttpd/phttpd.c | 6 | ||||
-rw-r--r-- | sapi/pi3web/pi3web_sapi.c | 6 | ||||
-rw-r--r-- | sapi/roxen/roxen.c | 8 | ||||
-rw-r--r-- | sapi/servlet/servlet.c | 6 | ||||
-rw-r--r-- | sapi/thttpd/thttpd.c | 7 |
10 files changed, 58 insertions, 3 deletions
diff --git a/sapi/aolserver/aolserver.c b/sapi/aolserver/aolserver.c index 21c4b4ff2e..67ca6d5992 100644 --- a/sapi/aolserver/aolserver.c +++ b/sapi/aolserver/aolserver.c @@ -473,6 +473,12 @@ php_ns_request_ctor(NSLS_D SLS_DC) 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) { diff --git a/sapi/apache/mod_php4.c b/sapi/apache/mod_php4.c index c5a51e8092..c3b81390ea 100644 --- a/sapi/apache/mod_php4.c +++ b/sapi/apache/mod_php4.c @@ -379,6 +379,8 @@ static void init_request_info(SLS_D) 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"); diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c index d61bea902f..10d5d39059 100644 --- a/sapi/cgi/cgi_main.c +++ b/sapi/cgi/cgi_main.c @@ -315,7 +315,12 @@ static void init_request_info(SLS_D) 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; diff --git a/sapi/isapi/php4isapi.c b/sapi/isapi/php4isapi.c index 949e96bc00..5e48b35811 100644 --- a/sapi/isapi/php4isapi.c +++ b/sapi/isapi/php4isapi.c @@ -463,6 +463,12 @@ static void init_request_info(sapi_globals_struct *sapi_globals, LPEXTENSION_CON 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); diff --git a/sapi/nsapi/nsapi.c b/sapi/nsapi/nsapi.c index 4e664b6559..94ac4072f7 100644 --- a/sapi/nsapi/nsapi.c +++ b/sapi/nsapi/nsapi.c @@ -478,6 +478,13 @@ nsapi_request_ctor(NSLS_D SLS_DC) 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 diff --git a/sapi/phttpd/phttpd.c b/sapi/phttpd/phttpd.c index 9f2eda9c16..72d81f401a 100644 --- a/sapi/phttpd/phttpd.c +++ b/sapi/phttpd/phttpd.c @@ -202,6 +202,12 @@ php_phttpd_request_ctor(PHLS_D SLS_DC) 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 */ } diff --git a/sapi/pi3web/pi3web_sapi.c b/sapi/pi3web/pi3web_sapi.c index c6a6f839b0..ff2951e708 100644 --- a/sapi/pi3web/pi3web_sapi.c +++ b/sapi/pi3web/pi3web_sapi.c @@ -321,6 +321,12 @@ static void init_request_info(sapi_globals_struct *sapi_globals, LPCONTROL_BLOCK 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) diff --git a/sapi/roxen/roxen.c b/sapi/roxen/roxen.c index 82c93664bb..740104da91 100644 --- a/sapi/roxen/roxen.c +++ b/sapi/roxen/roxen.c @@ -671,7 +671,13 @@ void f_php_roxen_request_handler(INT32 args) 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; diff --git a/sapi/servlet/servlet.c b/sapi/servlet/servlet.c index 3f5c7d19ff..2661d8fabe 100644 --- a/sapi/servlet/servlet.c +++ b/sapi/servlet/servlet.c @@ -356,6 +356,12 @@ JNIEXPORT void JNICALL Java_net_php_servlet_send 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) { diff --git a/sapi/thttpd/thttpd.c b/sapi/thttpd/thttpd.c index a9fe305b03..daef768dfc 100644 --- a/sapi/thttpd/thttpd.c +++ b/sapi/thttpd/thttpd.c @@ -245,7 +245,12 @@ static void thttpd_request_ctor(TLS_D SLS_DC) 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; |