From: tomsn at inetoffice dot com Operating system: Linux PHP version: 5.1.5 PHP Bug Type: Apache2 related Bug description: header( "HTTP/1.0 ..." ) does not change proto ver. Fix included.
Description: ------------ Steps: 1. Create a php script with header("HTTP/1.0 200 OK") at the end. That call is documented to change the protocol number of the response to 1.0. 2. Use mod_dumpio in Apache2 to observe the sent headers from any HTTP/1.1 request, or you can use Firefox Live HTTP Headers header watcher, or whatever. RESULT: Apache sends HTTP/1.1 200 OK as the response header. EXPECT: Apache to respect your wishes and send HTTP/1.0 200 OK as the response header. DIAGNOSES: The problem results from the way Apache2 tracks the pieces of the resultant status line seperately. The httpd.h structure request_rec has fields status_line, status, and proto_num. These are analyzed and combined within Apache in a mystical and magical way. The fix to this bug is to give it an updated proto_num and to send it a special apache_setenv(). DETAILS: sapi/apache2handler/sapi_apache2(121) -- php_apache_sapi_send_headers() Has the following code used to transmit the HTTP response status line to Apache: /* httpd requires that r->status_line is set to the first digit of * the status-code: */ if (sline && strlen(sline) > 12 && strncmp(sline, "HTTP/1.", 7) == 0 && sline[8] == ' ') { ctx->r->status_line = apr_pstrdup(ctx->r->pool, sline + 9); } Insert into that code the following line just before the end curly: ctx->r->proto_num = 1000 + (sline[7]-'0'); That funky 1000 + expression is how apache2 tracks HTTP protocol numbers internally. See their HTTP_VERSION() macro. NOW, although this added line of code sends Apache an accurate status line protocol number, Apache is in the habit of ignoring it. To force Apache to really use it, you can either code the following apache_setenv() into PHP as a special case of send headers, or you can document for the user that they need to call it from their script. The call is: apache_setenv( "force-response-1.0", "true" ); I hope this is of some use to you. Thanks for all the excellent work in building and maintaining PHP. Reproduce code: --------------- header("HTTP/1.0 200 OK"); Expected result: ---------------- Browser to receive this header: HTTP/1.0 200 OK Actual result: -------------- Browser receives this header: HTTP/1.1 200 OK (notice the last 1 in /1.1) -- Edit bug report at http://bugs.php.net/?id=38602&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=38602&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=38602&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=38602&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=38602&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=38602&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=38602&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=38602&r=needscript Try newer version: http://bugs.php.net/fix.php?id=38602&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=38602&r=support Expected behavior: http://bugs.php.net/fix.php?id=38602&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=38602&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=38602&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=38602&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=38602&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=38602&r=dst IIS Stability: http://bugs.php.net/fix.php?id=38602&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=38602&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=38602&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=38602&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=38602&r=mysqlcfg