1
0
Fork 0

Fixed indentation

pull/649/head
Maxim Chernyshev 2012-05-02 09:30:27 +08:00
parent 8918551f29
commit 37476eb61f
2 changed files with 21 additions and 21 deletions

View File

@ -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);
$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";
}
// 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";
}
}
}

View File

@ -97,7 +97,7 @@ class StreamContextFactoryTest extends \PHPUnit_Framework_TestCase
$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);