Skip to content

Commit

Permalink
disable multiplexing for some versions of curl
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Lctrs committed Nov 22, 2024
1 parent 38cb4bf commit 827b895
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/Composer/Util/Http/RequestProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@
*/
class RequestProxy
{
/**
* Known libcurl's broken versions when proxy is in use with HTTP/2
* multiplexing.
*
* @var list<non-empty-string>
*/
private const BAD_MULTIPLEXING_CURL_VERSIONS = ['7.87.0', '7.88.0', '7.88.1'];

/** @var ?contextOptions */
private $contextOptions;
/** @var ?non-empty-string */
Expand Down Expand Up @@ -101,6 +109,17 @@ public function getCurlOptions(array $sslOptions): array
}
}

/**
* Disable HTTP/2 multiplexing for some broken versions of libcurl.
*
* 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@821f6e2a89de8aec1c7da3c0f381b92b2b801efc
*/
if ($options[CURLOPT_PROXY] !== '' && ($version = curl_version()) !== false && in_array($version['version'], self::BAD_MULTIPLEXING_CURL_VERSIONS, true)) {
$options[CURLMOPT_PIPELINING] = /* CURLPIPE_NOTHING */ 0;
}

return $options;
}

Expand Down

0 comments on commit 827b895

Please sign in to comment.