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

+10-2
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

+1-1
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)