diff --git a/doc/03-cli.md b/doc/03-cli.md index 1daae9154..aff1bce30 100644 --- a/doc/03-cli.md +++ b/doc/03-cli.md @@ -815,10 +815,10 @@ similar use case), and need to support proxies, please provide the `CGI_HTTP_PRO environment variable instead. See [httpoxy.org](https://httpoxy.org/) for further details. -### no_proxy +### no_proxy or NO_PROXY If you are behind a proxy and would like to disable it for certain domains, you -can use the `no_proxy` env var. Simply set it to a comma separated list of +can use the `no_proxy` or `NO_PROXY` env var. Simply set it to a comma separated list of domains the proxy should *not* be used for. The env var accepts domains, IP addresses, and IP address blocks in CIDR diff --git a/src/Composer/Util/StreamContextFactory.php b/src/Composer/Util/StreamContextFactory.php index 911bb36a1..b8290086c 100644 --- a/src/Composer/Util/StreamContextFactory.php +++ b/src/Composer/Util/StreamContextFactory.php @@ -55,8 +55,8 @@ final class StreamContextFactory } // Remove proxy if URL matches no_proxy directive - if (!empty($_SERVER['no_proxy']) && parse_url($url, PHP_URL_HOST)) { - $pattern = new NoProxyPattern($_SERVER['no_proxy']); + if (!empty($_SERVER['NO_PROXY']) || !empty($_SERVER['no_proxy']) && parse_url($url, PHP_URL_HOST)) { + $pattern = new NoProxyPattern(!empty($_SERVER['no_proxy']) ? $_SERVER['no_proxy'] : $_SERVER['NO_PROXY']); if ($pattern->test($url)) { unset($proxy); } diff --git a/tests/Composer/Test/Util/StreamContextFactoryTest.php b/tests/Composer/Test/Util/StreamContextFactoryTest.php index 93cf881e2..0618675a2 100644 --- a/tests/Composer/Test/Util/StreamContextFactoryTest.php +++ b/tests/Composer/Test/Util/StreamContextFactoryTest.php @@ -22,6 +22,7 @@ class StreamContextFactoryTest extends \PHPUnit_Framework_TestCase unset($_SERVER['http_proxy']); unset($_SERVER['HTTPS_PROXY']); unset($_SERVER['https_proxy']); + unset($_SERVER['NO_PROXY']); unset($_SERVER['no_proxy']); } @@ -31,6 +32,7 @@ class StreamContextFactoryTest extends \PHPUnit_Framework_TestCase unset($_SERVER['http_proxy']); unset($_SERVER['HTTPS_PROXY']); unset($_SERVER['https_proxy']); + unset($_SERVER['NO_PROXY']); unset($_SERVER['no_proxy']); }