1
0
Fork 0
mirror of https://github.com/composer/composer synced 2025-05-09 00:22:53 +00:00

A bug in PHP prevents the headers from correctly beeing sent when a content-type header is present and

NOT at the end of the array

https://bugs.php.net/bug.php?id=61548

This updates fixes the array by moving the content-type header to the end
This commit is contained in:
Markus Tacker 2013-02-27 17:07:13 +01:00
parent 9f961dca92
commit 821f57f443
2 changed files with 48 additions and 0 deletions

View file

@ -133,4 +133,28 @@ class StreamContextFactoryTest extends \PHPUnit_Framework_TestCase
array('ssl://proxyserver:8443', 'https://proxyserver:8443'),
);
}
/**
* @author Markus Tacker <m@coderbyheart.de>
*/
public function testEnsureThatfixHttpHeaderFieldMovesContentTypeToEndOfOptions()
{
$options = array(
'http' => array(
'header' => "X-Foo: bar\r\nContent-Type: application/json\r\nAuthorization: Basic aW52YWxpZA=="
)
);
$expectedOptions = array(
'http' => array(
'header' => array(
"X-Foo: bar",
"Authorization: Basic aW52YWxpZA==",
"Content-Type: application/json"
)
)
);
$context = StreamContextFactory::getContext($options);
$ctxoptions = stream_context_get_options($context);
$this->assertEquals(join("\n", $ctxoptions['http']['header']), join("\n", $expectedOptions['http']['header']));
}
}