Fix multiple timeou with multiple retry
This commit is contained in:
parent
2a70f68847
commit
79a9392468
@ -50,17 +50,21 @@ final class AsyncResponse implements ResponseInterface, StreamableInterface
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -215,14 +215,20 @@ class AsyncDecoratorTraitTest extends NativeHttpClientTest
|
||||
|
||||
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]);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user