1
0
Fork 0

Add default http options to stream context, fixes #1774

pull/1773/merge
Jordi Boggiano 2013-04-05 12:48:15 +02:00
parent 2b385cbe58
commit 9a69886a92
1 changed files with 7 additions and 5 deletions

View File

@ -30,7 +30,11 @@ final class StreamContextFactory
*/ */
public static function getContext(array $defaultOptions = array(), array $defaultParams = array()) public static function getContext(array $defaultOptions = array(), array $defaultParams = array())
{ {
$options = array('http' => array()); $options = array('http' => array(
// specify defaults again to try and work better with curlwrappers enabled
'follow_location' => 1,
'max_redirects' => 20,
));
// Handle system proxy // Handle system proxy
if (!empty($_SERVER['HTTP_PROXY']) || !empty($_SERVER['http_proxy'])) { if (!empty($_SERVER['HTTP_PROXY']) || !empty($_SERVER['http_proxy'])) {
@ -57,10 +61,8 @@ final class StreamContextFactory
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( $options['http']['proxy'] = $proxyURL;
'proxy' => $proxyURL, $options['http']['request_fulluri'] = true;
'request_fulluri' => true,
);
if (isset($proxy['user'])) { if (isset($proxy['user'])) {
$auth = $proxy['user']; $auth = $proxy['user'];