Skip to content

Commit e5aea2b

Browse files
[HttpClient] fallbackto CURLMOPT_MAXCONNECTS when CURLMOPT_MAX_HOST_CONNECTIONS is not available
1 parent b3a69ad commit e5aea2b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

CurlHttpClient.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,10 @@ public function __construct(array $defaultOptions = [], int $maxHostConnections
7272
curl_multi_setopt($this->multi->handle, CURLMOPT_PIPELINING, CURLPIPE_MULTIPLEX);
7373
}
7474
if (\defined('CURLMOPT_MAX_HOST_CONNECTIONS')) {
75-
curl_multi_setopt($this->multi->handle, CURLMOPT_MAX_HOST_CONNECTIONS, 0 < $maxHostConnections ? $maxHostConnections : PHP_INT_MAX);
75+
$maxHostConnections = curl_multi_setopt($this->multi->handle, CURLMOPT_MAX_HOST_CONNECTIONS, 0 < $maxHostConnections ? $maxHostConnections : PHP_INT_MAX) ? 0 : $maxHostConnections;
76+
}
77+
if (\defined('CURLMOPT_MAXCONNECTS') && 0 < $maxHostConnections) {
78+
curl_multi_setopt($this->multi->handle, CURLMOPT_MAXCONNECTS, $maxHostConnections);
7679
}
7780

7881
// Skip configuring HTTP/2 push when it's unsupported or buggy, see https://bugs.php.net/77535

0 commit comments

Comments
 (0)