1
0
Fork 0

Remove duplicate StreamContextFactory ssl options

Added in Dec 2014 (commit 8dad846), superseded in Jan 2016 (pr #4759)
pull/9324/head
johnstevenson 2020-09-29 13:04:30 +01:00 committed by Jordi Boggiano
parent 49a28f606c
commit 8feb83b22b
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
2 changed files with 14 additions and 40 deletions

View File

@ -130,14 +130,6 @@ final class StreamContextFactory
break; break;
} }
// add SNI opts for https URLs
if ('https' === parse_url($url, PHP_URL_SCHEME)) {
$options['ssl']['SNI_enabled'] = true;
if (PHP_VERSION_ID < 50600) {
$options['ssl']['SNI_server_name'] = parse_url($url, PHP_URL_HOST);
}
}
// handle proxy auth if present // handle proxy auth if present
if (isset($proxy['user'])) { if (isset($proxy['user'])) {
$auth = rawurldecode($proxy['user']); $auth = rawurldecode($proxy['user']);

View File

@ -129,22 +129,13 @@ class StreamContextFactoryTest extends TestCase
$context = StreamContextFactory::getContext('https://example.org', array('http' => array('method' => 'GET', 'header' => 'User-Agent: foo'))); $context = StreamContextFactory::getContext('https://example.org', array('http' => array('method' => 'GET', 'header' => 'User-Agent: foo')));
$options = stream_context_get_options($context); $options = stream_context_get_options($context);
$expected = array( $this->assertEquals(array('http' => array(
'http' => array(
'proxy' => 'tcp://proxyserver.net:80', 'proxy' => 'tcp://proxyserver.net:80',
'method' => 'GET', 'method' => 'GET',
'header' => array('User-Agent: foo', "Proxy-Authorization: Basic " . base64_encode('username:password')), 'header' => array('User-Agent: foo', "Proxy-Authorization: Basic " . base64_encode('username:password')),
'max_redirects' => 20, 'max_redirects' => 20,
'follow_location' => 1, 'follow_location' => 1,
), 'ssl' => array( )), $options);
'SNI_enabled' => true,
'SNI_server_name' => 'example.org',
),
);
if (PHP_VERSION_ID >= 50600) {
unset($expected['ssl']['SNI_server_name']);
}
$this->assertEquals($expected, $options);
} }
public function testHttpsProxyOverride() public function testHttpsProxyOverride()
@ -159,22 +150,13 @@ class StreamContextFactoryTest extends TestCase
$context = StreamContextFactory::getContext('https://example.org', array('http' => array('method' => 'GET', 'header' => 'User-Agent: foo'))); $context = StreamContextFactory::getContext('https://example.org', array('http' => array('method' => 'GET', 'header' => 'User-Agent: foo')));
$options = stream_context_get_options($context); $options = stream_context_get_options($context);
$expected = array( $this->assertEquals(array('http' => array(
'http' => array(
'proxy' => 'ssl://woopproxy.net:443', 'proxy' => 'ssl://woopproxy.net:443',
'method' => 'GET', 'method' => 'GET',
'max_redirects' => 20, 'max_redirects' => 20,
'follow_location' => 1, 'follow_location' => 1,
'header' => array('User-Agent: foo'), 'header' => array('User-Agent: foo'),
), 'ssl' => array( )), $options);
'SNI_enabled' => true,
'SNI_server_name' => 'example.org',
),
);
if (PHP_VERSION_ID >= 50600) {
unset($expected['ssl']['SNI_server_name']);
}
$this->assertEquals($expected, $options);
} }
/** /**