Skip to content

Commit 3a5f3f5

Browse files
committed
use response.pause
1 parent 4f257cb commit 3a5f3f5

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1653,7 +1653,8 @@ private function addHttpClientSection(ArrayNodeDefinition $rootNode)
16531653
->prototype('scalar')->end()
16541654
->info('A list of HTTP status code that triggers a retry')
16551655
->defaultValue([423, 425, 429, 500, 502, 503, 504, 507, 510])
1656-
->end() ->integerNode('max_retries')->defaultValue(3)->min(0)->end()
1656+
->end()
1657+
->integerNode('max_retries')->defaultValue(3)->min(0)->end()
16571658
->integerNode('delay')->defaultValue(1000)->min(0)->info('Time in ms to delay (or the initial value when multiplier is used)')->end()
16581659
->floatNode('multiplier')->defaultValue(2)->min(1)->info('If greater than 1, delay will grow exponentially for each retry: this delay = (delay * (multiple ^ retries))')->end()
16591660
->integerNode('max_delay')->defaultValue(0)->min(0)->info('Max time in ms that a retry should ever be delayed (0 = infinite)')->end()

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1994,7 +1994,7 @@ private function registerHttpClientConfiguration(array $config, ContainerBuilder
19941994
$container->removeDefinition(HttpClient::class);
19951995
}
19961996

1997-
$applyRetry = static function(array $retryOptions, string $name) use ($container) {
1997+
$applyRetry = static function (array $retryOptions, string $name) use ($container) {
19981998
if (!($retryOptions['enabled'] ?? false)) {
19991999
return;
20002000
}
@@ -2020,7 +2020,7 @@ private function registerHttpClientConfiguration(array $config, ContainerBuilder
20202020
->setArguments([
20212021
new Reference($name.'.retry.inner'),
20222022
$retryReferences,
2023-
new Reference('logger')
2023+
new Reference('logger'),
20242024
])
20252025
->addTag('monolog.logger', ['channel' => 'http_client']);
20262026
};

src/Symfony/Component/HttpClient/RetryHttpClient.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function request(string $method, string $url, array $options = []): Respo
6666
++$this->retryCount;
6767

6868
$context->setInfo('retry', $this->retryCount);
69-
$context->getResponse()->cancel();
69+
$response->cancel();
7070

7171
$delay = $this->strategy->getWaitingTime($this->retryCount, $response, $exception);
7272

@@ -75,11 +75,9 @@ public function request(string $method, string $url, array $options = []): Respo
7575
'delay' => $delay,
7676
'error' => ($exception ? $exception->getMessage() : 'StatusCode: '.$response->getStatusCode()),
7777
]);
78-
if ($delay > 0) {
79-
usleep($delay * 1000);
80-
}
8178

8279
$context->replaceRequest($method, $url, $options);
80+
$context->pause($delay / 1000);
8381
});
8482
}
8583
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy