From 6da92e98acff05f746826e85942ff40f0d3ed6a6 Mon Sep 17 00:00:00 2001 From: croensch Date: Thu, 12 Oct 2017 16:35:05 +0200 Subject: [PATCH] also support NO_PROXY since WINDOWS can only have one case and that is usually upperase --- doc/03-cli.md | 4 ++-- src/Composer/Util/StreamContextFactory.php | 4 ++-- tests/Composer/Test/Util/StreamContextFactoryTest.php | 2 ++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/doc/03-cli.md b/doc/03-cli.md index 7a20d742f..1e9df8542 100644 --- a/doc/03-cli.md +++ b/doc/03-cli.md @@ -814,10 +814,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..e177059d3 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']) || $_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']); }