Functional Weave
Code in Python

http.retry-after@1.0.0

vectors.json

2,459 bytes · view raw

[
  {"name": "delay-seconds, as an API's 429 sends it", "args": ["120", 1790424000], "expect": 120},
  {"name": "zero means retry now", "args": ["0", 1790424000], "expect": 0},
  {"name": "no header at all", "args": [null, 1790424000], "expect": null},
  {"name": "an empty header", "args": ["", 1790424000], "expect": null},
  {"name": "spaces and tabs around the value are optional whitespace", "args": [" \t30 ", 1790424000], "expect": 30},
  {"name": "leading zeros are still 1*DIGIT", "args": ["007", 1790424000], "expect": 7},
  {"name": "nine digits is the most accepted", "args": ["999999999", 0], "expect": 999999999},
  {"name": "ten digits is a broken header, not a 317-year wait", "args": ["1000000000", 0], "expect": null},
  {"name": "a negative number is not delay-seconds", "args": ["-5", 1790424000], "expect": null},
  {"name": "a fraction is not delay-seconds", "args": ["1.5", 1790424000], "expect": null},
  {"name": "a plus sign is not delay-seconds (Rust's parse would take it)", "args": ["+5", 1790424000], "expect": null},
  {"name": "Arabic-Indic digits are not ASCII digits", "args": ["٣٠", 1790424000], "expect": null},
  {"name": "a trailing newline is not optional whitespace", "args": ["120\n", 1790424000], "expect": null},
  {"name": "an HTTP date a minute ahead is 60 seconds", "args": ["Wed, 21 Oct 2015 07:28:00 GMT", 1445412420], "expect": 60},
  {"name": "an HTTP date already past is 0, not negative", "args": ["Wed, 21 Oct 2015 07:28:00 GMT", 1445412490], "expect": 0},
  {"name": "29 February in a leap year", "args": ["Thu, 29 Feb 2024 12:00:00 GMT", 1709207000], "expect": 1000},
  {"name": "29 February in a common year is no date", "args": ["Wed, 29 Feb 2023 12:00:00 GMT", 1600000000], "expect": null},
  {"name": "the zone must be GMT, upper case", "args": ["Wed, 21 Oct 2015 07:28:00 gmt", 1445412420], "expect": null},
  {"name": "hour 24 is refused", "args": ["Wed, 21 Oct 2015 24:00:00 GMT", 1445412420], "expect": null},
  {"name": "year 0000 is refused", "args": ["Sat, 01 Jan 0000 00:00:00 GMT", 0], "expect": null},
  {"name": "the obsolete RFC 850 form is not accepted", "args": ["Wednesday, 21-Oct-15 07:28:00 GMT", 1445412420], "expect": null},
  {"name": "the obsolete asctime form is not accepted", "args": ["Wed Oct 21 07:28:00 2015", 1445412420], "expect": null},
  {"name": "a fractional now is refused", "args": ["120", 1790424000.5], "expectError": "now must be a whole number of seconds"}
]