From c764b5c36e6043a5c3100b4d4780ae30bdebdec3 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 15 May 2020 13:57:17 +0200 Subject: [PATCH] [HttpClient] fix PHP warning + accept status code >= 600 --- .../Component/HttpClient/Response/CurlResponse.php | 11 +++++++++-- .../Component/HttpClient/Response/ResponseTrait.php | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/HttpClient/Response/CurlResponse.php b/src/Symfony/Component/HttpClient/Response/CurlResponse.php index 58528108e8d1a..80709ed8a6a76 100644 --- a/src/Symfony/Component/HttpClient/Response/CurlResponse.php +++ b/src/Symfony/Component/HttpClient/Response/CurlResponse.php @@ -312,8 +312,15 @@ private static function parseHeaderLine($ch, string $data, array &$info, array & } 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:')) { diff --git a/src/Symfony/Component/HttpClient/Response/ResponseTrait.php b/src/Symfony/Component/HttpClient/Response/ResponseTrait.php index d0aee7a158649..786e995b16ffd 100644 --- a/src/Symfony/Component/HttpClient/Response/ResponseTrait.php +++ b/src/Symfony/Component/HttpClient/Response/ResponseTrait.php @@ -253,7 +253,7 @@ private static function initialize(self $response): void 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 = []; pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy