Skip to content

Commit

Permalink
[HttpClient] fix PHP warning + accept status code >= 600
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas committed May 15, 2020
1 parent 9bcf9c1 commit 0b2645d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions src/Symfony/Component/HttpClient/Response/CurlResponse.php
Expand Up @@ -312,8 +312,16 @@ 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:')) {
Expand Down
Expand Up @@ -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+)? ([123456789]\d\d)(?: |$)#', $h, $m)) {
if ($headers) {
$debug .= "< \r\n";
$headers = [];
Expand Down

0 comments on commit 0b2645d

Please sign in to comment.