ID: 47605 Updated by: j...@php.net Reported By: c dot c dot dean at durham dot ac dot uk -Status: Verified +Status: Feedback Bug Type: CGI related Operating System: * PHP Version: 5.*, 6CVS (2009-04-25) New Comment:
What have you set cgi.nph to? Try disabling it first. (See also bug #27026 as this fix changed the behaviour) Previous Comments: ------------------------------------------------------------------------ [2009-03-09 14:45:38] c dot c dot dean at durham dot ac dot uk Description: ------------ If you invoke header("HTTP/1.0 200 OK"); from PHP in CGI mode, the header is never output, because it's suppressed at line 379 in sapi/cgi/cgi_main.c. If you use any value other than 200, it is output correctly. This means for instance, that if you use PHP in CGI mode as an Apache errordocument handler, you cannot send back a non-error 200 OK to the user. The following trivial change fixes this, but you might prefer a more elegant solution. --- php-5.2.9/sapi/cgi/cgi_main.c.orig 2009-01-19 18:17:59.000000000 +0000 +++ php-5.2.9/sapi/cgi/cgi_main.c 2009-03-09 14:04:11.000000000 +0000 @@ -376,7 +376,7 @@ return SAPI_HEADER_SENT_SUCCESSFULLY; } - if (CGIG(nph) || SG(sapi_headers).http_response_code != 200) + if (CGIG(nph) || SG(sapi_headers).http_response_code != 666) { int len; zend_bool has_status = 0; @@ -914,7 +914,7 @@ SG(request_info).request_uri = NULL; SG(request_info).content_type = NULL; SG(request_info).content_length = 0; - SG(sapi_headers).http_response_code = 200; + SG(sapi_headers).http_response_code = 666; /* script_path_translated being set is a good indication that we are running in a cgi environment, since it is always Reproduce code: --------------- Use this as the Apache errordocument handler: <?php header("HTTP/1.0 200 OK"); echo "This is OK"; ?> Expected result: ---------------- HTTP/1.0 200 OK in the header and "This is OK" in the body Actual result: -------------- HTTP/1.0 404 Not Found ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=47605&edit=1