#48929 [NEW]: Duplicate \r\n after HTTP headers when "header" context option is an array.

From: Date: Wed, 15 Jul 2009 17:26:51 +0000
Subject: #48929 [NEW]: Duplicate \r\n after HTTP headers when "header" context option is an array.
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-139764@lists.php.net to get a copy of this message
From: david dot zuelke at bitextender dot com Operating system: Mac OS X 10.5.7 PHP version: 5.3.0 PHP Bug Type: Streams related Bug description: Duplicate \r\n after HTTP headers when "header" context option is an array. Description: ------------ When making an HTTP request through the HTTP stream wrapper, there will be a duplicate \r\n sequence separating header lines and request body if the HTTP stream context option "header" is an array (which is possible since 5.2.10; it had to be a string with the individual, \r\n-separated header lines before that). As a result, the last two bytes of the request will never reach the destination server, as it closes the connection when reaching the indicated Content-Length (which is off by two bytes due to the extra \r\n). The HTTP specification explicitly states that one \r\n sequence should be used to separate the last (\r\n-terminated) header line from the request body. All is fine when supplying headers as a string instead of an array. Reproduce code: --------------- $context = stream_context_create(array('http' => array('header' => array('X-Foo: bar', 'Content-Type: text/plain'), 'method' => 'POST', 'content' => 'ohai'))); $fd = fopen('http://127.0.0.1:12342/', 'rb', false, $context); Expected result: ---------------- A \r\n after the last header, another \r\n to create a blank line, then "ohai" Actual result: -------------- A \r\n after the last header, then \r\n twice which creates two blank lines, then "oh". "ai" never arrives as the Content-Length is reached. -- Edit bug report at http://bugs.php.net/?id=48929&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=48929&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=48929&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=48929&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=48929&r=fixedcvs Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=48929&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=48929&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=48929&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=48929&r=needscript Try newer version: http://bugs.php.net/fix.php?id=48929&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=48929&r=support Expected behavior: http://bugs.php.net/fix.php?id=48929&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=48929&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=48929&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=48929&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=48929&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=48929&r=dst IIS Stability: http://bugs.php.net/fix.php?id=48929&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=48929&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=48929&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=48929&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=48929&r=mysqlcfg

« previous php.bugs (#139764) next »