diff --git a/src/Handler/CurlMultiHandler.php b/src/Handler/CurlMultiHandler.php index 7097835d1..aced1281a 100644 --- a/src/Handler/CurlMultiHandler.php +++ b/src/Handler/CurlMultiHandler.php @@ -50,7 +50,16 @@ public function __construct(array $options = []) public function __get($name) { if ($name === '_mh') { - return $this->_mh = curl_multi_init(); + $this->_mh = curl_multi_init(); + + if (defined('CURLMOPT_MAX_HOST_CONNECTIONS')) { // php 7.0.7 - http://php.net/manual/en/function.curl-multi-setopt.php#refsect1-function.curl-multi-setopt-changelog + $maxHostConnections = getenv('GUZZLE_CURL_MAX_HOST_CONNECTIONS'); + if ($maxHostConnections) { + curl_multi_setopt($this->_mh, CURLMOPT_MAX_HOST_CONNECTIONS, $maxHostConnections); + } + } + + return $this->_mh; } throw new \BadMethodCallException();