Browse Source

Notes on HTTP_PROXY env var

Jordi Boggiano 13 years ago
parent
commit
81fdd790f2
2 changed files with 10 additions and 5 deletions
  1. 7 2
      doc/03-cli.md
  2. 3 3
      src/Composer/Util/StreamContextFactory.php

+ 7 - 2
doc/03-cli.md

@@ -179,10 +179,15 @@ directory to something other than `vendor/bin`.
 This env var controls the time composer waits for commands (such as git
 This env var controls the time composer waits for commands (such as git
 commands) to finish executing. The default value is 60 seconds.
 commands) to finish executing. The default value is 60 seconds.
 
 
-### HTTP_PROXY
+### http_proxy or HTTP_PROXY
 
 
 If you are using composer from behind an HTTP proxy, you can use the standard
 If you are using composer from behind an HTTP proxy, you can use the standard
-`HTTP_PROXY` or `http_proxy` env vars. Simply set it to the URL of your proxy.
+`http_proxy` or `HTTP_PROXY` env vars. Simply set it to the URL of your proxy.
 Many operating systems already set this variable for you.
 Many operating systems already set this variable for you.
 
 
+Using `http_proxy` (lowercased) or even defining both might be preferrable since
+some tools like git or curl will only use the lower-cased `http_proxy` version.
+Alternatively you can also define the git proxy using
+`git config --global http.proxy <proxy url>`.
+
 &larr; [Libraries](02-libraries.md)  |  [Schema](04-schema.md) &rarr;
 &larr; [Libraries](02-libraries.md)  |  [Schema](04-schema.md) &rarr;

+ 3 - 3
src/Composer/Util/StreamContextFactory.php

@@ -34,15 +34,15 @@ final class StreamContextFactory
         // Handle system proxy
         // Handle system proxy
         if (isset($_SERVER['HTTP_PROXY']) || isset($_SERVER['http_proxy'])) {
         if (isset($_SERVER['HTTP_PROXY']) || isset($_SERVER['http_proxy'])) {
             // Some systems seem to rely on a lowercased version instead...
             // Some systems seem to rely on a lowercased version instead...
-            $proxy = isset($_SERVER['HTTP_PROXY']) ? $_SERVER['HTTP_PROXY'] : $_SERVER['http_proxy'];
-            
+            $proxy = isset($_SERVER['http_proxy']) ? $_SERVER['http_proxy'] : $_SERVER['HTTP_PROXY'];
+
             // http(s):// is not supported in proxy
             // http(s):// is not supported in proxy
             $proxy = str_replace(array('http://', 'https://'), array('tcp://', 'ssl://'), $proxy);
             $proxy = str_replace(array('http://', 'https://'), array('tcp://', 'ssl://'), $proxy);
 
 
             if (0 === strpos($proxy, 'ssl:') && !extension_loaded('openssl')) {
             if (0 === strpos($proxy, '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(
             $options['http'] = array(
                 'proxy'           => $proxy,
                 'proxy'           => $proxy,
                 'request_fulluri' => true,
                 'request_fulluri' => true,