#23759 [Opn->Asn]: PHP doesn't preserve subrequest status

From: Date: Thu, 22 May 2003 22:43:55 +0000
Subject: #23759 [Opn->Asn]: PHP doesn't preserve subrequest status
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-40226@lists.php.net to get a copy of this message
ID: 23759 Updated by: sniper@php.net Reported By: jaboydjr at netwalk dot com -Status: Open +Status: Assigned Bug Type: Apache2 related Operating System: Linux 2.4.20 PHP Version: 4.3.2RC4 -Assigned To: +Assigned To: iliaa New Comment: Ilia promised to look into this. Previous Comments: ------------------------------------------------------------------------ [2003-05-22 15:04:42] jaboydjr at netwalk dot com I attempted to use PHP for "branding" Apache2 error documents, and noticed that it always returns status 200. In order for PHP to work correctly in this situation, it must return the status it is given. This is especially important for 401 status codes, since a browser must receive the 401 code in order to know to present an authorization dialogue to the user. The attached patch works for me to fix this problem; consider it just a workaround patch if you wish. The patch simply preserves non-zero request codes passed in, and sets status HTTP_OK (=200) if 0 is passed in. ============================================================================== --- php-4.3.2RC4-orig/sapi/apache2filter/sapi_apache2.c 2003-05-21 05:34:14.000000000 -0400 +++ php-4.3.2RC4/sapi/apache2filter/sapi_apache2.c 2003-05-22 15:43:09.000000000 -0400 @@ -376,7 +376,8 @@ const char *auth; PG(during_request_startup) = 0; - SG(sapi_headers).http_response_code = 200; + SG(sapi_headers).http_response_code = + (!f->r->status ? HTTP_OK : f->r->status); SG(request_info).content_type = apr_table_get(f->r->headers_in, "Content-Type"); #undef safe_strdup #define safe_strdup(x) ((x)?strdup((x)):NULL) --- php-4.3.2RC4-orig/sapi/apache2handler/sapi_apache2.c 2003-05-21 05:34:14.000000000 -0400 +++ php-4.3.2RC4/sapi/apache2handler/sapi_apache2.c 2003-05-22 15:43:09.000000000 -0400 @@ -412,7 +412,7 @@ char *content_type; const char *auth; - SG(sapi_headers).http_response_code = 200; + SG(sapi_headers).http_response_code = (!r->status ? HTTP_OK : r->status); SG(request_info).content_type = apr_table_get(r->headers_in, "Content-Type"); SG(request_info).query_string = apr_pstrdup(r->pool, r->args); SG(request_info).request_method = r->method; ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=23759&edit=1

« previous php.bugs (#40226) next »