Skip to content

Commit

Permalink
cancel passthru
Browse files Browse the repository at this point in the history
  • Loading branch information
jderusse committed Sep 14, 2020
1 parent 3a5f3f5 commit 75d727f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Expand Up @@ -67,10 +67,6 @@ public function __construct(array $statusCodes = [423, 425, 429, 500, 502, 503,
$this->maxDelayMilliseconds = $maxDelayMilliseconds;
}

public function shouldRetry(ResponseInterface $response, \Throwable $throwable = null): bool
{
}

public function isRetryable(int $retryCount, ResponseInterface $response, \Throwable $throwable = null): bool
{
if ($retryCount >= $this->maxRetries) {
Expand Down
10 changes: 9 additions & 1 deletion src/Symfony/Component/HttpClient/RetryHttpClient.php
Expand Up @@ -47,8 +47,15 @@ public function request(string $method, string $url, array $options = []): Respo
return new AsyncResponse($this->client, $method, $url, $options, function (ChunkInterface $chunk, AsyncContext $context) use ($method, $url, $options) {
$exception = null;
try {
if ($chunk->isTimeout() || null !== $chunk->getInformationalStatus()) {
yield $chunk;

return;
}

// only retry first chunk
if ($chunk->isTimeout() || !$chunk->isFirst()) {
if (!$chunk->isFirst()) {
$context->passthru();
yield $chunk;

return;
Expand All @@ -58,6 +65,7 @@ public function request(string $method, string $url, array $options = []): Respo
}

if (!$this->strategy->isRetryable($this->retryCount, $response = $context->getResponse(), $exception)) {
$context->passthru();
yield $chunk;

return;
Expand Down

0 comments on commit 75d727f

Please sign in to comment.