|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-01-14 18:18 UTC] php dot net at thermoman dot de
Description: ------------ On php.net Doc sites (e.g. http://php.net/print_r) the scripts return a HTTP/1.1 header even if the client requested HTTP/1.0 This leads to Content-Transfer-Encoding metadata being inserted into the websites body. Reproduce code: --------------- $ telnet php3.de 80 Trying 217.160.72.57... Connected to php3.de. Escape character is '^]'. HEAD /print_r HTTP/1.0 Connection: close Host: de3.php.net HTTP/1.1 200 OK [..] Expected result: ---------------- HTTP/1.0 200 OK Actual result: -------------- The header is generated at this point: == schnipp == // Send out a proper status header function status_header($num) { // Set status text switch ($num) { case 200: $status = "OK"; break; case 301: $status = "Moved Permanently"; break; case 302: $status = "Found"; break; case 404: $status = "Not Found"; break; default: return FALSE; } // BC code for PHP < 4.3.0 @header("HTTP/1.1 $num $status"); @header("Status: $num $status", TRUE, $num); return TRUE; } == schnapp == See http://trac.wordpress.org/ticket/3886 for the exact same problem including a patch for older wordpress versions. Here is a screenshot of the website with garbage in it when requested via squid proxy server with HTTP/1.0: http://test.thermoman.de/images/php_net_chunked_error.png Please cross-reference bug #42402. Credits to Timm Friebe for the deeper look inside. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 17 21:00:01 2025 UTC |
This patch could fix it: php3:/home/httpd/php3.de/doc_root/include# diff -u errors.inc ~/errors.inc.fixed --- errors.inc Tue Jan 15 16:46:23 2008 +++ /root/errors.inc.fixed Tue Jan 15 16:45:57 2008 @@ -75,8 +75,13 @@ default: return FALSE; } + // Figure out HTTP protocol version - use 1.1 answer for 1.1 request, + // answer with HTTP/1.0 for any other (ancient or futuristic) user agent + switch (strtoupper($_ENV['SERVER_PROTOCOL'])) { + case 'HTTP/1.1': @header("HTTP/1.1 $num $status"); break; + case 'HTTP/1.0': default: @header("HTTP/1.0 $num $status"); break; + } // BC code for PHP < 4.3.0 - @header("HTTP/1.1 $num $status"); @header("Status: $num $status", TRUE, $num); return TRUE;