From 8eb0a8f86b3198acd48f024f845ab73cd9542133 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 29 Sep 2021 08:44:08 +0200 Subject: [PATCH] [HttpClient] accept headers when CURLE_RECV_ERROR is received before the content --- src/Symfony/Component/HttpClient/Response/CurlResponse.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Symfony/Component/HttpClient/Response/CurlResponse.php b/src/Symfony/Component/HttpClient/Response/CurlResponse.php index 1ccc48a688699..c0891321fe5a2 100644 --- a/src/Symfony/Component/HttpClient/Response/CurlResponse.php +++ b/src/Symfony/Component/HttpClient/Response/CurlResponse.php @@ -290,6 +290,10 @@ private static function perform(ClientState $multi, array &$responses = null): v } } + if (\CURLE_RECV_ERROR === $result && 'H' === $waitFor[0] && 400 <= ($responses[(int) $ch]->info['http_code'] ?? 0)) { + $multi->handlesActivity[$id][] = new FirstChunk(); + } + $multi->handlesActivity[$id][] = null; $multi->handlesActivity[$id][] = \in_array($result, [\CURLE_OK, \CURLE_TOO_MANY_REDIRECTS], true) || '_0' === $waitFor || curl_getinfo($ch, \CURLINFO_SIZE_DOWNLOAD) === curl_getinfo($ch, \CURLINFO_CONTENT_LENGTH_DOWNLOAD) ? null : new TransportException(sprintf('%s for "%s".', curl_strerror($result), curl_getinfo($ch, \CURLINFO_EFFECTIVE_URL))); }