#30649 [NEW]: Invalid content with HTTP response > 8000 bytes

From: Date: Mon, 01 Nov 2004 12:57:50 +0000
Subject: #30649 [NEW]: Invalid content with HTTP response > 8000 bytes
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-68583@lists.php.net to get a copy of this message
From: l dot zurschmiede at delightsoftware dot com Operating system: Linux 2.6.7 PHP version: 5.0.2 PHP Bug Type: Sockets related Bug description: Invalid content with HTTP response > 8000 bytes Description: ------------ When a Socket/Stream function is used to get content, bigger then 8000bytes from a HTTP-Server, the received content has a false begin (3bb4 or similar) and end (0\n\n). This failure occures only if the Server does not respond with a "Content-Length: xx" header AND a clientside protocol of HTTP/1.1. If the clientside protocol is invalid (like "HTTP 1.1" or "HTTP 1.0") or it's an old one like HTTP/1.0, there is no failure. It only occures with HTTP/1.1 and NO serverside "Content-Length" header. The example-Script is a Server and a Client-Script. The Server-Script sends exactly 8001 bytes as content to the Client-Script. Comment out the "Content-Length" in Server, or the additional $cont .= "."; to retrieve the valid content. (Tested on PHP-5.0.2 with Apache 2.0.50, glibc-2.3.2) (A similarly one seams to be #28955) Reproduce code: --------------- Client test_client.php: <?php $cont = ''; $head = ''; $fp = stream_socket_client('tcp://localhost:80', $errno, $error, 30); fputs($fp, "POST /test_server.php HTTP/1.1\r\nHost: localhost\r\n"); fputs($fp, "Connection: Close\r\nAccept: text/xml\r\n\r\n"); while ( $str = trim(fgets($fp, 2048)) ) $head .= $str; while ( !(feof($fp)) ) $cont .= fgets($fp, 2048); fclose($fp); print("Length: ".strlen($cont)."<br/>\r\nbegin (10): ".substr($cont, 0, 10)." <br/>\r\nend (10): ".substr($cont, (strlen($cont) - 10))); ?> Server test_server.php: <?php $cont = ''; for ($i = 0; $i < 80; $i++) $cont .= '....................................................................................................'; $cont .= '.'; header('Content-Type: text/plain; charset=\"utf-8\"'); //header('Content-Length: '.strlen($cont)); print($cont); ?> Expected result: ---------------- Length: 8001<br/> begin (10): .......... <br/> end (10): .......... Actual result: -------------- Length: 8014<br/> begin (10): 1f41 .... <br/> end (10): ... 0 ******* There is no exception visible in a backtrace. -- Edit bug report at http://bugs.php.net/?id=30649&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=30649&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=30649&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=30649&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=30649&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=30649&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=30649&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=30649&r=needscript Try newer version: http://bugs.php.net/fix.php?id=30649&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=30649&r=support Expected behavior: http://bugs.php.net/fix.php?id=30649&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=30649&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=30649&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=30649&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=30649&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=30649&r=dst IIS Stability: http://bugs.php.net/fix.php?id=30649&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=30649&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=30649&r=float MySQL Configuration Error: http://bugs.php.net/fix.php?id=30649&r=mysqlcfg

« previous php.bugs (#68583) next »