Skip to main content

parse_retry_after

Function parse_retry_after 

Source
pub fn parse_retry_after(s: &str) -> Option<RetryAfter>
Expand description

Parse a Retry-After field value per RFC 9110 §10.2.3.

ABNF: Retry-After = HTTP-date / delay-seconds where delay-seconds = 1*DIGIT. The grammar is delay-seconds disjoint from HTTP-date, so we try delay-seconds first (cheaper, ambiguity-free — pure digits cannot match any of the three HTTP-date forms which all start with an alphabetic weekday name or token) then fall back to parse_http_date.

Returns None on syntactically invalid input (leading sign, non-numeric characters in the delay-seconds form that also fail every HTTP-date form, empty input, etc.). §10.2.3 makes delay-seconds “a non-negative decimal integer” — we reject a leading + or - even though Rust’s u64::parse would refuse - natively, because + would otherwise parse successfully.