#23759 [NEW]: PHP doesn't preserve subrequest status

From: Date: Thu, 22 May 2003 20:04:42 +0000
Subject: #23759 [NEW]: PHP doesn't preserve subrequest status
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-40208@lists.php.net to get a copy of this message
From: jaboydjr at netwalk dot com Operating system: Linux 2.4.20 PHP version: 4.3.2RC4 PHP Bug Type: Apache2 related Bug description: PHP doesn't preserve subrequest status 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 bug report at http://bugs.php.net/?id=23759&edit=1 -- Try a CVS snapshot: http://bugs.php.net/fix.php?id=23759&r=trysnapshot Fixed in CVS: http://bugs.php.net/fix.php?id=23759&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=23759&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=23759&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=23759&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=23759&r=support Expected behavior: http://bugs.php.net/fix.php?id=23759&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=23759&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=23759&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=23759&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=23759&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=23759&r=dst IIS Stability: http://bugs.php.net/fix.php?id=23759&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=23759&r=gnused

« previous php.bugs (#40208) next »