[HttpClient] fix PHP warning + accept status code >= 600

This commit is contained in:
Nicolas Grekas 2020-05-15 13:57:17 +02:00
parent 9bcf9c1e02
commit c764b5c36e
2 changed files with 10 additions and 3 deletions

View File

@ -312,8 +312,15 @@ final class CurlResponse implements ResponseInterface
}
if ("\r\n" !== $data) {
// Regular header line: add it to the list
self::addResponseHeaders([substr($data, 0, -2)], $info, $headers);
try {
// Regular header line: add it to the list
self::addResponseHeaders([substr($data, 0, -2)], $info, $headers);
} catch (TransportException $e) {
$multi->handlesActivity[$id][] = null;
$multi->handlesActivity[$id][] = $e;
return \strlen($data);
}
if (0 !== strpos($data, 'HTTP/')) {
if (0 === stripos($data, 'Location:')) {

View File

@ -253,7 +253,7 @@ trait ResponseTrait
private static function addResponseHeaders(array $responseHeaders, array &$info, array &$headers, string &$debug = ''): void
{
foreach ($responseHeaders as $h) {
if (11 <= \strlen($h) && '/' === $h[4] && preg_match('#^HTTP/\d+(?:\.\d+)? ([12345]\d\d)(?: |$)#', $h, $m)) {
if (11 <= \strlen($h) && '/' === $h[4] && preg_match('#^HTTP/\d+(?:\.\d+)? ([1-9]\d\d)(?: |$)#', $h, $m)) {
if ($headers) {
$debug .= "< \r\n";
$headers = [];