From 81fdd790f20eb79ff2389b4e687624131be47e4a Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 20 Mar 2012 14:03:01 +0100 Subject: [PATCH] Notes on HTTP_PROXY env var --- doc/03-cli.md | 9 +++++++-- src/Composer/Util/StreamContextFactory.php | 6 +++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/doc/03-cli.md b/doc/03-cli.md index 0ee6a140e..45344adea 100644 --- a/doc/03-cli.md +++ b/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 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 -`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. +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 `. + ← [Libraries](02-libraries.md) | [Schema](04-schema.md) → \ No newline at end of file diff --git a/src/Composer/Util/StreamContextFactory.php b/src/Composer/Util/StreamContextFactory.php index 4ea31da4d..6541d811b 100644 --- a/src/Composer/Util/StreamContextFactory.php +++ b/src/Composer/Util/StreamContextFactory.php @@ -34,15 +34,15 @@ final class StreamContextFactory // Handle system proxy if (isset($_SERVER['HTTP_PROXY']) || isset($_SERVER['http_proxy'])) { // 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 $proxy = str_replace(array('http://', 'https://'), array('tcp://', 'ssl://'), $proxy); if (0 === strpos($proxy, 'ssl:') && !extension_loaded('openssl')) { throw new \RuntimeException('You must enable the openssl extension to use a proxy over https'); } - + $options['http'] = array( 'proxy' => $proxy, 'request_fulluri' => true,