|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-10-12 20:20 UTC] sjoerd-php at linuxonly dot nl
Description:
------------
If a HTTP response contains an header of exactly 1024 characters, the remaining headers are not parsed and are returned in the output.
Reproduce code:
---------------
<?php
echo file_get_contents('http://localhost/a.php');
?>
a.php:
<?php
header(str_pad('X-Padding: ', 1022, 'x'));
header('Location: http://www.google.nl/');
echo "Foo";
?>
Expected result:
----------------
The homepage of google.nl.
Actual result:
--------------
Location: http://www.google.nl
Vary: Accept-Encoding
Content-Length: 3
Connection: close
Content-Type: text/html
Foo
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 16:00:01 2025 UTC |
php internally does not have any hard coded limit to parse the header value. the only time, you will see http header in your output is when the header does not end with \r\n (to mark it as new line). as per HTTP spec, every HTTP headers need to end with \r\n (CR LF) to mark the end of the line. php internally checks for this line to determine if the header is done before proceeding to parse the body of the request. if you modify this below test case to reflect that there needs to be \r\n to mark it as end of line, then you will see the expected output. <?php $string = str_pad('X-Padding: ', 1022, 'x').'\r\n'; header($string); header('Location: http://www.google.nl/'); echo "Foo"; ?> i suggest marking this bug as bogus (or not an issue).Thank you for your input. However, I disagree with your post. > php internally does not have any hard coded limit http_fopen_wrapper.c:75 #define HTTP_HEADER_BLOCK_SIZE 1024 > the header does not end with \r\n This is not needed with header(). > $string = str_pad('X-Padding: ', 1022, 'x').'\r\n'; This appends \r\n instead of CRLF, because you use single quotes instead of double quotes.