Skip to main content

parse_retry_after

Function parse_retry_after 

Source
pub fn parse_retry_after(retry_after: &str) -> Option<Duration>
Expand description

Parse Retry-After header from HTTP response.

The Retry-After header can be in two formats:

  • Delta-seconds: “60” (integer number of seconds)
  • HTTP-date: “Wed, 21 Oct 2015 07:28:00 GMT” (RFC 7231 format)

§Arguments

  • retry_after - The Retry-After header value

§Returns

Some(Duration) if the header is valid, None otherwise.

§Examples

use github_bot_sdk::client::parse_retry_after;
use std::time::Duration;

// Delta-seconds format
let delay = parse_retry_after("60");
assert_eq!(delay, Some(Duration::from_secs(60)));

// Invalid format
let delay = parse_retry_after("invalid");
assert_eq!(delay, None);

See docs/spec/interfaces/rate-limiting-retry.md