diff --git a/docs/quickstart.rst b/docs/quickstart.rst index 69ceb9d4d..3c61d25af 100644 --- a/docs/quickstart.rst +++ b/docs/quickstart.rst @@ -609,6 +609,8 @@ behavior of the library. Note: because the HTTP_PROXY variable may contain arbitrary user input on some (CGI) environments, the variable is only used on the CLI SAPI. See https://httpoxy.org for more information. ``HTTPS_PROXY`` Defines the proxy to use when sending requests using the "https" protocol. +``NO_PROXY`` + Defines URLs for which a proxy should not be used. See :ref:`proxy-option` for usage. Relevant ini Settings diff --git a/src/Handler/CurlMultiHandler.php b/src/Handler/CurlMultiHandler.php index 2754d8e43..7097835d1 100644 --- a/src/Handler/CurlMultiHandler.php +++ b/src/Handler/CurlMultiHandler.php @@ -37,8 +37,14 @@ public function __construct(array $options = []) { $this->factory = isset($options['handle_factory']) ? $options['handle_factory'] : new CurlFactory(50); - $this->selectTimeout = isset($options['select_timeout']) - ? $options['select_timeout'] : 1; + + if (isset($options['select_timeout'])) { + $this->selectTimeout = $options['select_timeout']; + } elseif ($selectTimeout = getenv('GUZZLE_CURL_SELECT_TIMEOUT')) { + $this->selectTimeout = $selectTimeout; + } else { + $this->selectTimeout = 1; + } } public function __get($name) diff --git a/tests/Handler/CurlMultiHandlerTest.php b/tests/Handler/CurlMultiHandlerTest.php index 61df32679..6c987afb8 100644 --- a/tests/Handler/CurlMultiHandlerTest.php +++ b/tests/Handler/CurlMultiHandlerTest.php @@ -74,6 +74,20 @@ public function testDelaysConcurrently() $this->assertGreaterThanOrEqual($expected, microtime(true)); } + public function testUsesTimeoutEnvironmentVariables() + { + $a = new CurlMultiHandler(); + + //default if no options are given and no environment variable is set + $this->assertEquals(1, $this->readAttribute($a, 'selectTimeout')); + + putenv("GUZZLE_CURL_SELECT_TIMEOUT=3"); + $a = new CurlMultiHandler(); + $selectTimeout = getenv('GUZZLE_CURL_SELECT_TIMEOUT'); + //Handler reads from the environment if no options are given + $this->assertEquals($selectTimeout, $this->readAttribute($a, 'selectTimeout')); + } + /** * @expectedException \BadMethodCallException */