1
0
Fork 0

Follow-up coding standard fixes

pull/649/head
Maxim Chernyshev 2012-05-02 15:16:36 +08:00
parent 37476eb61f
commit 1ae0a1b7af
1 changed files with 5 additions and 8 deletions

View File

@ -43,13 +43,11 @@ final class StreamContextFactory
if (isset($proxyPort)) { if (isset($proxyPort)) {
$proxyURL .= ":" . $proxyPort; $proxyURL .= ":" . $proxyPort;
} else { } else if ('http://' == substr($proxyURL, 0, 7)) {
if ('http://' == substr($proxyURL, 0, 7)) {
$proxyURL .= ":80"; $proxyURL .= ":80";
} else if ('https://' == substr($proxyURL, 0, 8)) { } else if ('https://' == substr($proxyURL, 0, 8)) {
$proxyURL .= ":443"; $proxyURL .= ":443";
} }
}
// http(s):// is not supported in proxy // http(s):// is not supported in proxy
$proxyURL = str_replace(array('http://', 'https://'), array('tcp://', 'ssl://'), $proxyURL); $proxyURL = str_replace(array('http://', 'https://'), array('tcp://', 'ssl://'), $proxyURL);
@ -75,14 +73,13 @@ final class StreamContextFactory
$auth = base64_encode($auth); $auth = base64_encode($auth);
// Preserve headers if already set in default options // Preserve headers if already set in default options
if (isset($defaultOptions['http']) && isset($defaultOptions['http']['header'])) { if (isset($defaultOptions['http']['header'])) {
$defaultOptions['http']['header'] .= "Proxy-Authorization: Basic {$auth}\r\n"; $defaultOptions['http']['header'] .= "Proxy-Authorization: Basic {$auth}\r\n";
} else { } else {
$options['http']['header'] = "Proxy-Authorization: Basic {$auth}\r\n"; $options['http']['header'] = "Proxy-Authorization: Basic {$auth}\r\n";
} }
} }
} }
$options = array_merge_recursive($options, $defaultOptions); $options = array_merge_recursive($options, $defaultOptions);
return stream_context_create($options, $defaultParams); return stream_context_create($options, $defaultParams);