Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions src/Symfony/Component/HttpClient/Response/AsyncResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,21 @@ public function __construct(HttpClientInterface $client, string $method, string
return false;
}

foreach (self::stream([$response]) as $chunk) {
if ($chunk->isTimeout() && $response->passthru) {
foreach (self::passthru($response->client, $response, new ErrorChunk($response->offset, new TransportException($chunk->getError()))) as $chunk) {
return !$chunk->isFirst();
while (true) {
foreach (self::stream([$response]) as $chunk) {
if ($chunk->isTimeout() && $response->passthru) {
foreach (self::passthru($response->client, $response, new ErrorChunk($response->offset, new TransportException($chunk->getError()))) as $chunk) {
if ($chunk->isFirst()) {
return false;
}
}

continue 2;
}

return true;
}

if ($chunk->isFirst()) {
break;
if ($chunk->isFirst()) {
return false;
}
}
}

Expand Down
14 changes: 10 additions & 4 deletions src/Symfony/Component/HttpClient/Tests/AsyncDecoratorTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,20 @@ public function testBufferPurePassthru()

public function testRetryTimeout()
{
$client = $this->getHttpClient(__FUNCTION__, function (ChunkInterface $chunk, AsyncContext $context) {
$cpt = 0;
$client = $this->getHttpClient(__FUNCTION__, function (ChunkInterface $chunk, AsyncContext $context) use (&$cpt) {
try {
$this->assertTrue($chunk->isTimeout());
yield $chunk;
} catch (TransportExceptionInterface $e) {
$context->passthru();
$context->getResponse()->cancel();
$context->replaceRequest('GET', 'http://localhost:8057/timeout-header', ['timeout' => 1]);
if ($cpt++ < 3) {
$context->getResponse()->cancel();
$context->replaceRequest('GET', 'http://localhost:8057/timeout-header', ['timeout' => 0.1]);
} else {
$context->passthru();
$context->getResponse()->cancel();
$context->replaceRequest('GET', 'http://localhost:8057/timeout-header', ['timeout' => 1]);
}
}
});

Expand Down