Skip to content

Commit b373aff

Browse files
Merge branch '4.3' into 4.4
* 4.3: [HttpKernel] fix merge fix tests [HttpClient] fix throwing HTTP exceptions when the 1st chunk is emitted
2 parents 813e856 + 5882f85 commit b373aff

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

Response/ResponseTrait.php

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -339,20 +339,28 @@ public static function stream(iterable $responses, float $timeout = null): \Gene
339339
} elseif ($chunk instanceof ErrorChunk) {
340340
unset($responses[$j]);
341341
$isTimeout = true;
342-
} elseif ($chunk instanceof FirstChunk && $response->logger) {
343-
$info = $response->getInfo();
344-
$response->logger->info(sprintf('Response: "%s %s"', $info['http_code'], $info['url']));
342+
} elseif ($chunk instanceof FirstChunk) {
343+
if ($response->logger) {
344+
$info = $response->getInfo();
345+
$response->logger->info(sprintf('Response: "%s %s"', $info['http_code'], $info['url']));
346+
}
347+
348+
yield $response => $chunk;
349+
350+
if ($response->initializer && null === $response->info['error']) {
351+
// Ensure the HTTP status code is always checked
352+
$response->getHeaders(true);
353+
}
354+
355+
continue;
345356
}
346357

347358
yield $response => $chunk;
348359
}
349360

350361
unset($multi->handlesActivity[$j]);
351362

352-
if ($chunk instanceof FirstChunk && null === $response->initializer && null === $response->info['error']) {
353-
// Ensure the HTTP status code is always checked
354-
$response->getHeaders(true);
355-
} elseif ($chunk instanceof ErrorChunk && !$chunk->didThrow()) {
363+
if ($chunk instanceof ErrorChunk && !$chunk->didThrow()) {
356364
// Ensure transport exceptions are always thrown
357365
$chunk->getContent();
358366
}

0 commit comments

Comments
 (0)