|
|
@ -57,7 +57,7 @@ class StreamContextFactoryTest extends \PHPUnit_Framework_TestCase
|
|
|
|
|
|
|
|
|
|
|
|
public function testHttpProxy()
|
|
|
|
public function testHttpProxy()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$_SERVER['http_proxy'] = 'http://username:password@proxyserver.net:port/';
|
|
|
|
$_SERVER['http_proxy'] = 'http://username:password@proxyserver.net:3128/';
|
|
|
|
$_SERVER['HTTP_PROXY'] = 'http://proxyserver/';
|
|
|
|
$_SERVER['HTTP_PROXY'] = 'http://proxyserver/';
|
|
|
|
|
|
|
|
|
|
|
|
$context = StreamContextFactory::getContext(array('http' => array('method' => 'GET')));
|
|
|
|
$context = StreamContextFactory::getContext(array('http' => array('method' => 'GET')));
|
|
|
@ -66,22 +66,39 @@ class StreamContextFactoryTest extends \PHPUnit_Framework_TestCase
|
|
|
|
$this->assertSame('http://proxyserver/', $_SERVER['HTTP_PROXY']);
|
|
|
|
$this->assertSame('http://proxyserver/', $_SERVER['HTTP_PROXY']);
|
|
|
|
|
|
|
|
|
|
|
|
$this->assertEquals(array('http' => array(
|
|
|
|
$this->assertEquals(array('http' => array(
|
|
|
|
'proxy' => 'tcp://username:password@proxyserver.net:port/',
|
|
|
|
'proxy' => 'tcp://username:password@proxyserver.net:3128',
|
|
|
|
'request_fulluri' => true,
|
|
|
|
'request_fulluri' => true,
|
|
|
|
'method' => 'GET',
|
|
|
|
'method' => 'GET',
|
|
|
|
)), $options);
|
|
|
|
)), $options);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function testSSLProxy()
|
|
|
|
public function testHttpProxyWithoutPort()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$_SERVER['http_proxy'] = 'https://proxyserver/';
|
|
|
|
$_SERVER['http_proxy'] = 'http://username:password@proxyserver.net';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$context = StreamContextFactory::getContext(array('http' => array('method' => 'GET')));
|
|
|
|
|
|
|
|
$options = stream_context_get_options($context);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->assertEquals(array('http' => array(
|
|
|
|
|
|
|
|
'proxy' => 'tcp://username:password@proxyserver.net:80',
|
|
|
|
|
|
|
|
'request_fulluri' => true,
|
|
|
|
|
|
|
|
'method' => 'GET',
|
|
|
|
|
|
|
|
)), $options);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @dataProvider dataSSLProxy
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public function testSSLProxy($expected, $proxy)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$_SERVER['http_proxy'] = $proxy;
|
|
|
|
|
|
|
|
|
|
|
|
if (extension_loaded('openssl')) {
|
|
|
|
if (extension_loaded('openssl')) {
|
|
|
|
$context = StreamContextFactory::getContext();
|
|
|
|
$context = StreamContextFactory::getContext();
|
|
|
|
$options = stream_context_get_options($context);
|
|
|
|
$options = stream_context_get_options($context);
|
|
|
|
|
|
|
|
|
|
|
|
$this->assertSame(array('http' => array(
|
|
|
|
$this->assertEquals(array('http' => array(
|
|
|
|
'proxy' => 'ssl://proxyserver/',
|
|
|
|
'proxy' => $expected,
|
|
|
|
'request_fulluri' => true,
|
|
|
|
'request_fulluri' => true,
|
|
|
|
)), $options);
|
|
|
|
)), $options);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -93,4 +110,12 @@ class StreamContextFactoryTest extends \PHPUnit_Framework_TestCase
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function dataSSLProxy()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return array(
|
|
|
|
|
|
|
|
array('ssl://proxyserver:443', 'https://proxyserver/'),
|
|
|
|
|
|
|
|
array('ssl://proxyserver:8443', 'https://proxyserver:8443'),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|