Skip to content

Commit e07a148

Browse files
committed
[HttpClient] Fix a bug preventing Server Pushes to be handled properly
1 parent 0fdbc49 commit e07a148

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

CurlHttpClient.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,7 @@ public function request(string $method, string $url, array $options = []): Respo
106106
$url = implode('', $url);
107107

108108
if (!isset($options['normalized_headers']['user-agent'])) {
109-
$options['normalized_headers']['user-agent'][] = 'Symfony HttpClient/Curl';
110-
$options['headers'][] = 'User-Agent: Symfony HttpClient/Curl';
109+
$options['normalized_headers']['user-agent'][] = $options['headers'][] = 'User-Agent: Symfony HttpClient/Curl';
111110
}
112111

113112
if ($pushedResponse = $this->multi->pushedResponses[$url] ?? null) {
@@ -364,7 +363,12 @@ private static function acceptPushForRequest(string $method, array $options, Pus
364363
}
365364

366365
foreach (['authorization', 'cookie', 'range', 'proxy-authorization'] as $k) {
367-
if (($pushedResponse->requestHeaders[$k] ?? null) !== ($options['normalized_headers'][$k] ?? null)) {
366+
$normalizedHeaders = $options['normalized_headers'][$k] ?? [];
367+
foreach ($normalizedHeaders as $i => $v) {
368+
$normalizedHeaders[$i] = substr($v, \strlen($k) + 2);
369+
}
370+
371+
if (($pushedResponse->requestHeaders[$k] ?? []) !== $normalizedHeaders) {
368372
return false;
369373
}
370374
}

0 commit comments

Comments
 (0)