Skip to content

Commit 827b895

Browse files
committed
disable multiplexing for some versions of curl
I'm behind a corporate proxy and was hitting a `Curl 2 (...) [CONN-1-0] send: no filter connected` error when trying to download some packages. Some google research led me to rust-lang/cargo#12202 and its fix rust-lang/cargo#12234. This PR backports this fix to composer. > In certain versions of libcurl when proxy is in use with HTTP/2 multiplexing, connections will continue stacking up. This was fixed in libcurl 8.0.0 in curl/curl@821f6e2
1 parent 38cb4bf commit 827b895

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

Diff for: src/Composer/Util/Http/RequestProxy.php

+19
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@
2222
*/
2323
class RequestProxy
2424
{
25+
/**
26+
* Known libcurl's broken versions when proxy is in use with HTTP/2
27+
* multiplexing.
28+
*
29+
* @var list<non-empty-string>
30+
*/
31+
private const BAD_MULTIPLEXING_CURL_VERSIONS = ['7.87.0', '7.88.0', '7.88.1'];
32+
2533
/** @var ?contextOptions */
2634
private $contextOptions;
2735
/** @var ?non-empty-string */
@@ -101,6 +109,17 @@ public function getCurlOptions(array $sslOptions): array
101109
}
102110
}
103111

112+
/**
113+
* Disable HTTP/2 multiplexing for some broken versions of libcurl.
114+
*
115+
* In certain versions of libcurl when proxy is in use with HTTP/2
116+
* multiplexing, connections will continue stacking up. This was
117+
* fixed in libcurl 8.0.0 in curl/curl@821f6e2a89de8aec1c7da3c0f381b92b2b801efc
118+
*/
119+
if ($options[CURLOPT_PROXY] !== '' && ($version = curl_version()) !== false && in_array($version['version'], self::BAD_MULTIPLEXING_CURL_VERSIONS, true)) {
120+
$options[CURLMOPT_PIPELINING] = /* CURLPIPE_NOTHING */ 0;
121+
}
122+
104123
return $options;
105124
}
106125

0 commit comments

Comments
 (0)