diff --git a/src/Composer/Util/StreamContextFactory.php b/src/Composer/Util/StreamContextFactory.php index de2de1d58..a42287ed4 100644 --- a/src/Composer/Util/StreamContextFactory.php +++ b/src/Composer/Util/StreamContextFactory.php @@ -72,7 +72,7 @@ final class StreamContextFactory if (isset($defaultOptions['http']['header'])) { $defaultOptions['http']['header'][] = "Proxy-Authorization: Basic {$auth}"; } else { - $options['http']['header'] = "Proxy-Authorization: Basic {$auth}\r\n"; + $options['http']['header'] = array("Proxy-Authorization: Basic {$auth}"); } } } diff --git a/tests/Composer/Test/Util/StreamContextFactoryTest.php b/tests/Composer/Test/Util/StreamContextFactoryTest.php index 691625a94..3d728ffeb 100644 --- a/tests/Composer/Test/Util/StreamContextFactoryTest.php +++ b/tests/Composer/Test/Util/StreamContextFactoryTest.php @@ -67,7 +67,7 @@ class StreamContextFactoryTest extends \PHPUnit_Framework_TestCase 'proxy' => 'tcp://proxyserver.net:3128', 'request_fulluri' => true, 'method' => 'GET', - 'header' => "Proxy-Authorization: Basic " . base64_encode('username:password') . "\r\n" + 'header' => array("Proxy-Authorization: Basic " . base64_encode('username:password')) )), $options); } @@ -75,14 +75,14 @@ class StreamContextFactoryTest extends \PHPUnit_Framework_TestCase { $_SERVER['http_proxy'] = 'http://username:password@proxyserver.net:3128/'; - $context = StreamContextFactory::getContext(array('http' => array('method' => 'GET', 'header' => "X-Foo: bar\r\n", 'request_fulluri' => false))); + $context = StreamContextFactory::getContext(array('http' => array('method' => 'GET', 'header' => array("X-Foo: bar"), 'request_fulluri' => false))); $options = stream_context_get_options($context); $this->assertEquals(array('http' => array( 'proxy' => 'tcp://proxyserver.net:3128', 'request_fulluri' => false, 'method' => 'GET', - 'header' => "X-Foo: bar\r\nProxy-Authorization: Basic " . base64_encode('username:password') . "\r\n" + 'header' => array("X-Foo: bar", "Proxy-Authorization: Basic " . base64_encode('username:password')) )), $options); } @@ -97,7 +97,7 @@ class StreamContextFactoryTest extends \PHPUnit_Framework_TestCase 'proxy' => 'tcp://proxyserver.net:80', 'request_fulluri' => true, 'method' => 'GET', - 'header' => "Proxy-Authorization: Basic " . base64_encode('username:password') . "\r\n" + 'header' => array("Proxy-Authorization: Basic " . base64_encode('username:password')) )), $options); }