Fixed indentation

main
Maxim Chernyshev 12 years ago
parent 8918551f29
commit 37476eb61f

@ -42,20 +42,20 @@ final class StreamContextFactory
$proxyPort = parse_url($proxy, PHP_URL_PORT);
if (isset($proxyPort)) {
$proxyURL .= ":" . $proxyPort;
$proxyURL .= ":" . $proxyPort;
} else {
if ('http://' == substr($proxyURL, 0, 7)) {
$proxyURL .= ":80";
} else if ('https://' == substr($proxyURL, 0, 8)) {
$proxyURL .= ":443";
}
if ('http://' == substr($proxyURL, 0, 7)) {
$proxyURL .= ":80";
} else if ('https://' == substr($proxyURL, 0, 8)) {
$proxyURL .= ":443";
}
}
// http(s):// is not supported in proxy
$proxyURL = str_replace(array('http://', 'https://'), array('tcp://', 'ssl://'), $proxyURL);
if (0 === strpos($proxyURL, 'ssl:') && !extension_loaded('openssl')) {
throw new \RuntimeException('You must enable the openssl extension to use a proxy over https');
throw new \RuntimeException('You must enable the openssl extension to use a proxy over https');
}
$options['http'] = array(
@ -68,18 +68,18 @@ final class StreamContextFactory
$pass = parse_url($proxy, PHP_URL_PASS);
if (isset($user)) {
$auth = $user;
if (isset($pass)) {
$auth .= ":{$pass}";
}
$auth = base64_encode($auth);
// Preserve headers if already set in default options
if (isset($defaultOptions['http']) && isset($defaultOptions['http']['header'])) {
$defaultOptions['http']['header'] .= "Proxy-Authorization: Basic {$auth}\r\n";
} else {
$options['http']['header'] = "Proxy-Authorization: Basic {$auth}\r\n";
}
$auth = $user;
if (isset($pass)) {
$auth .= ":{$pass}";
}
$auth = base64_encode($auth);
// Preserve headers if already set in default options
if (isset($defaultOptions['http']) && isset($defaultOptions['http']['header'])) {
$defaultOptions['http']['header'] .= "Proxy-Authorization: Basic {$auth}\r\n";
} else {
$options['http']['header'] = "Proxy-Authorization: Basic {$auth}\r\n";
}
}
}

@ -96,8 +96,8 @@ class StreamContextFactoryTest extends \PHPUnit_Framework_TestCase
if (extension_loaded('openssl')) {
$context = StreamContextFactory::getContext();
$options = stream_context_get_options($context);
$this->assertEquals(array('http' => array(
$this->assertEquals(array('http' => array(
'proxy' => $expected,
'request_fulluri' => true,
)), $options);

Loading…
Cancel
Save