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
-------
96759af1da
[HttpClient] fail properly when the server replies with HTTP/0.9
This commit is contained in:
commit
0383e53e5c
@ -123,6 +123,19 @@ final class CurlResponse implements ResponseInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
curl_setopt($ch, \CURLOPT_WRITEFUNCTION, static function ($ch, string $data) use ($multi, $id): int {
|
curl_setopt($ch, \CURLOPT_WRITEFUNCTION, static function ($ch, string $data) use ($multi, $id): int {
|
||||||
|
if ('H' === (curl_getinfo($ch, \CURLINFO_PRIVATE)[0] ?? null)) {
|
||||||
|
$multi->handlesActivity[$id][] = null;
|
||||||
|
$multi->handlesActivity[$id][] = new TransportException(sprintf('Unsupported protocol for "%s"', curl_getinfo($ch, \CURLINFO_EFFECTIVE_URL)));
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
curl_setopt($ch, \CURLOPT_WRITEFUNCTION, static function ($ch, string $data) use ($multi, $id): int {
|
||||||
|
$multi->handlesActivity[$id][] = $data;
|
||||||
|
|
||||||
|
return \strlen($data);
|
||||||
|
});
|
||||||
|
|
||||||
$multi->handlesActivity[$id][] = $data;
|
$multi->handlesActivity[$id][] = $data;
|
||||||
|
|
||||||
return \strlen($data);
|
return \strlen($data);
|
||||||
|
@ -270,7 +270,7 @@ trait ResponseTrait
|
|||||||
$debug .= "< \r\n";
|
$debug .= "< \r\n";
|
||||||
|
|
||||||
if (!$info['http_code']) {
|
if (!$info['http_code']) {
|
||||||
throw new TransportException('Invalid or missing HTTP status line.');
|
throw new TransportException(sprintf('Invalid or missing HTTP status line for "%s".', implode('', $info['url'])));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -350,7 +350,7 @@ trait ResponseTrait
|
|||||||
|
|
||||||
if (\is_string($chunk = array_shift($multi->handlesActivity[$j]))) {
|
if (\is_string($chunk = array_shift($multi->handlesActivity[$j]))) {
|
||||||
if (null !== $response->inflate && false === $chunk = @inflate_add($response->inflate, $chunk)) {
|
if (null !== $response->inflate && false === $chunk = @inflate_add($response->inflate, $chunk)) {
|
||||||
$multi->handlesActivity[$j] = [null, new TransportException('Error while processing content unencoding.')];
|
$multi->handlesActivity[$j] = [null, new TransportException(sprintf('Error while processing content unencoding for "%s".', $response->getInfo('url')))];
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user