Browse Source

Add default http options to stream context, fixes #1774

Jordi Boggiano 12 years ago
parent
commit
9a69886a92
1 changed files with 7 additions and 5 deletions
  1. 7 5
      src/Composer/Util/StreamContextFactory.php

+ 7 - 5
src/Composer/Util/StreamContextFactory.php

@@ -30,7 +30,11 @@ final class StreamContextFactory
      */
     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
         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');
             }
 
-            $options['http'] = array(
-                'proxy'           => $proxyURL,
-                'request_fulluri' => true,
-            );
+            $options['http']['proxy'] = $proxyURL;
+            $options['http']['request_fulluri'] = true;
 
             if (isset($proxy['user'])) {
                 $auth = $proxy['user'];