Skip to content

Commit a787ab9

Browse files
bug symfony#57870 [HttpClient] Disable HTTP/2 PUSH by default when using curl (nicolas-grekas)
This PR was merged into the 5.4 branch. Discussion ---------- [HttpClient] Disable HTTP/2 PUSH by default when using curl | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix symfony#57681 | License | MIT I propose to disable HTTP/2 PUSH by default when using curl. Amp still supports it out of the box, but support in curl is too fragile (it segfaults, see linked issue). We have to balance: - seeing a perf downgrade for apps that might benefit from pushes - vs putting every users at risk with a possible segfault when a server sends PUSH frames Preventing this possible segfault is the most important here IMHO. Apps that leverage PUSH should be rare, and can re-enable if they really want to. Commits ------- ae9b889 [HttpClient] Disable HTTP/2 PUSH by default when using curl
2 parents f3e0c81 + ae9b889 commit a787ab9

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

src/Symfony/Component/HttpClient/CurlHttpClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ final class CurlHttpClient implements HttpClientInterface, LoggerAwareInterface,
6767
*
6868
* @see HttpClientInterface::OPTIONS_DEFAULTS for available options
6969
*/
70-
public function __construct(array $defaultOptions = [], int $maxHostConnections = 6, int $maxPendingPushes = 50)
70+
public function __construct(array $defaultOptions = [], int $maxHostConnections = 6, int $maxPendingPushes = 0)
7171
{
7272
if (!\extension_loaded('curl')) {
7373
throw new \LogicException('You cannot use the "Symfony\Component\HttpClient\CurlHttpClient" as the "curl" extension is not installed.');

src/Symfony/Component/HttpClient/Tests/CurlHttpClientTest.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,19 @@ class CurlHttpClientTest extends HttpClientTestCase
2222
{
2323
protected function getHttpClient(string $testCase): HttpClientInterface
2424
{
25-
if (false !== strpos($testCase, 'Push')) {
26-
if (\PHP_VERSION_ID >= 70300 && \PHP_VERSION_ID < 70304) {
27-
$this->markTestSkipped('PHP 7.3.0 to 7.3.3 don\'t support HTTP/2 PUSH');
28-
}
29-
30-
if (!\defined('CURLMOPT_PUSHFUNCTION') || 0x073D00 > ($v = curl_version())['version_number'] || !(\CURL_VERSION_HTTP2 & $v['features'])) {
31-
$this->markTestSkipped('curl <7.61 is used or it is not compiled with support for HTTP/2 PUSH');
32-
}
25+
if (!str_contains($testCase, 'Push')) {
26+
return new CurlHttpClient(['verify_peer' => false, 'verify_host' => false]);
3327
}
3428

35-
return new CurlHttpClient(['verify_peer' => false, 'verify_host' => false]);
29+
if (\PHP_VERSION_ID >= 70300 && \PHP_VERSION_ID < 70304) {
30+
$this->markTestSkipped('PHP 7.3.0 to 7.3.3 don\'t support HTTP/2 PUSH');
31+
}
32+
33+
if (!\defined('CURLMOPT_PUSHFUNCTION') || 0x073D00 > ($v = curl_version())['version_number'] || !(\CURL_VERSION_HTTP2 & $v['features'])) {
34+
$this->markTestSkipped('curl <7.61 is used or it is not compiled with support for HTTP/2 PUSH');
35+
}
36+
37+
return new CurlHttpClient(['verify_peer' => false, 'verify_host' => false], 6, 50);
3638
}
3739

3840
public function testBindToPort()

0 commit comments

Comments
 (0)