-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Description
Symfony version(s) affected
6.1.4
Description
The Symfony RetryableHttpClient defines the $delay variable by calling $this->getDelayFromHeader($context->getHeaders())
.
According to the RFC this header should be A non-negative decimal integer indicating the seconds to delay after the response is received. By directly casting the value to integer, we lose the decimal value, resulting in an invalid delay.
How to reproduce
Use the Symfony HTTP Client package.
Use the RetryableHttpClient in combination with an API which returns a HTTP code causing the RetryableHttpClient to retry.
Make sure the API returns the header 'retry-after' with a decimal value, e.g. 0.63
.
The expected result will be the $delay variable to be 630
.
The actual result is the $delay variable to be 0
Possible Solution
Rewrite line 141 of the Symfony\Component\HttpClient\RetryableHttpClient
from return (int) $after * 1000;
to return (int) ($after * 1000);
Additional Context
Test showing the issue
The same test with the changed line in the RetryableHttpClient
In both cases, the header retry-after returned a value of 0.70