Bug #61548 [Opn->Csd]: content-type must appear at the end of headers for 201 Location to work in http
| From: | mike@php.net | Date: | Tue, 01 Oct 2013 09:13:00 +0000 |
| Subject: | Bug #61548 [Opn->Csd]: content-type must appear at the end of headers for 201 Location to work in http | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-181862@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=61548&edit=1
ID: 61548
Updated by: mike@php.net
Reported by: david at greenseedtechnologies dot com
Summary: content-type must appear at the end of headers for
201 Location to work in http
-Status: Open
+Status: Closed
Type: Bug
Package: HTTP related
Operating System: linux
PHP Version: 5.3.10
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of mike
Revision: http://git.php.net/?p=php-src.git;a=commit;h=18b04b480ebc41841b2004cc11797eda40fb3958
Log: Fixed bug #61548
Previous Comments:
------------------------------------------------------------------------
[2012-03-28 22:14:35] david at greenseedtechnologies dot com
Description:
------------
Line 445 of http_fopen_wrapper.c
only works of the content-type is at the end of a list of header fields in the
context. It fails if it is in the middle, or the beginning.
memmove(tmp, tmp + (s2 + 1 - tmp_c), tmp_c + l - 1 - s2);
To see the problem watch the HTTP stream in something like WireShark.
Test script:
---------------
<?php
$http = array(
'header' =>
null
."AnyHeader: 1\r\n"
// BUG on line 445 of http_fopen_wrapper.c of PHP: content_type cannot be in the middle of
headers.
."Content-type: anythingyouwanthere\r\n"
."SomeOtherHeader: 2\r\n"
);
/*
PHP incorrectly sends across when following the "Location":
GET /services/storm/lead HTTP/1.0
Host: storm
SomeOtherHeader: 2ent-type: anythingyouwanthere
SomeOtherHeader: 2
*/
$http['method'] = 'POST';
$options = array('http' => $http);
$context = stream_context_create($options);
$result = file_get_contents('http://some/url/that/resturns/201/and/has/a/Location/in/the/header',
false, $context);
Expected result:
----------------
GET /services/storm/lead HTTP/1.0
Host: storm
AnyHeader: 1
SomeOtherHeader: 2
Actual result:
--------------
GET /services/storm/lead HTTP/1.0
Host: storm
SomeOtherHeader: 2ent-type: anythingyouwanthere
SomeOtherHeader: 2
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=61548&edit=1