1
0
Fork 0

Merge pull request #6740 from croensch/master

also support NO_PROXY
pull/6706/merge
Jordi Boggiano 2017-11-03 19:50:28 +01:00 committed by GitHub
commit 4ab34c22fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 4 deletions

View File

@ -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

View File

@ -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);
}

View File

@ -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']);
}