Skip to content

Commit 0b2645d

Browse files
[HttpClient] fix PHP warning + accept status code >= 600
1 parent 9bcf9c1 commit 0b2645d

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,16 @@ private static function parseHeaderLine($ch, string $data, array &$info, array &
312312
}
313313

314314
if ("\r\n" !== $data) {
315-
// Regular header line: add it to the list
316-
self::addResponseHeaders([substr($data, 0, -2)], $info, $headers);
315+
try {
316+
// Regular header line: add it to the list
317+
self::addResponseHeaders([substr($data, 0, -2)], $info, $headers);
318+
} catch (TransportException $e) {
319+
$multi->handlesActivity[$id][] = null;
320+
$multi->handlesActivity[$id][] = $e;
321+
322+
return \strlen($data);
323+
}
324+
317325

318326
if (0 !== strpos($data, 'HTTP/')) {
319327
if (0 === stripos($data, 'Location:')) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ private static function initialize(self $response): void
253253
private static function addResponseHeaders(array $responseHeaders, array &$info, array &$headers, string &$debug = ''): void
254254
{
255255
foreach ($responseHeaders as $h) {
256-
if (11 <= \strlen($h) && '/' === $h[4] && preg_match('#^HTTP/\d+(?:\.\d+)? ([12345]\d\d)(?: |$)#', $h, $m)) {
256+
if (11 <= \strlen($h) && '/' === $h[4] && preg_match('#^HTTP/\d+(?:\.\d+)? ([123456789]\d\d)(?: |$)#', $h, $m)) {
257257
if ($headers) {
258258
$debug .= "< \r\n";
259259
$headers = [];

0 commit comments

Comments
 (0)
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