Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0383e53

Browse filesBrowse files
bug #38148 [HttpClient] fail properly when the server replies with HTTP/0.9 (nicolas-grekas)
This PR was merged into the 4.4 branch. Discussion ---------- [HttpClient] fail properly when the server replies with HTTP/0.9 | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | Fix #37923 | License | MIT | Doc PR | - Commits ------- 96759af [HttpClient] fail properly when the server replies with HTTP/0.9
2 parents 1b5f996 + 96759af commit 0383e53
Copy full SHA for 0383e53

File tree

2 files changed

+15
-2
lines changed
Filter options

2 files changed

+15
-2
lines changed

‎src/Symfony/Component/HttpClient/Response/CurlResponse.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpClient/Response/CurlResponse.php
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,19 @@ public function __construct(CurlClientState $multi, $ch, array $options = null,
123123
}
124124

125125
curl_setopt($ch, \CURLOPT_WRITEFUNCTION, static function ($ch, string $data) use ($multi, $id): int {
126+
if ('H' === (curl_getinfo($ch, \CURLINFO_PRIVATE)[0] ?? null)) {
127+
$multi->handlesActivity[$id][] = null;
128+
$multi->handlesActivity[$id][] = new TransportException(sprintf('Unsupported protocol for "%s"', curl_getinfo($ch, \CURLINFO_EFFECTIVE_URL)));
129+
130+
return 0;
131+
}
132+
133+
curl_setopt($ch, \CURLOPT_WRITEFUNCTION, static function ($ch, string $data) use ($multi, $id): int {
134+
$multi->handlesActivity[$id][] = $data;
135+
136+
return \strlen($data);
137+
});
138+
126139
$multi->handlesActivity[$id][] = $data;
127140

128141
return \strlen($data);

‎src/Symfony/Component/HttpClient/Response/ResponseTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpClient/Response/ResponseTrait.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ private static function addResponseHeaders(array $responseHeaders, array &$info,
270270
$debug .= "< \r\n";
271271

272272
if (!$info['http_code']) {
273-
throw new TransportException('Invalid or missing HTTP status line.');
273+
throw new TransportException(sprintf('Invalid or missing HTTP status line for "%s".', implode('', $info['url'])));
274274
}
275275
}
276276

@@ -350,7 +350,7 @@ public static function stream(iterable $responses, float $timeout = null): \Gene
350350

351351
if (\is_string($chunk = array_shift($multi->handlesActivity[$j]))) {
352352
if (null !== $response->inflate && false === $chunk = @inflate_add($response->inflate, $chunk)) {
353-
$multi->handlesActivity[$j] = [null, new TransportException('Error while processing content unencoding.')];
353+
$multi->handlesActivity[$j] = [null, new TransportException(sprintf('Error while processing content unencoding for "%s".', $response->getInfo('url')))];
354354
continue;
355355
}
356356

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.