Consider a server response with the following HTTP header:
Retry-After: 120
What does the value 120 represent?
Think about the unit of time used in the Retry-After header when a number is given.
The Retry-After header with a numeric value indicates the number of seconds the client should wait before retrying.
The Retry-After header can have two types of values. Which of the following correctly describes them?
Think about how servers can tell clients when to retry: either a delay or a specific time.
The Retry-After header accepts either a delay in seconds or a HTTP-date indicating when to retry.
A server sends this header:
Retry-After: 2024-13-01T12:00:00Z
What is wrong with this header value?
Check the month part of the date carefully.
Months in dates must be between 01 and 12. 13 is invalid.
A client receives this header:
Retry-After: Wed, 21 Oct 2025 07:28:00 GMT
What should the client do?
Think about how to interpret a date in the Retry-After header.
The client must wait until the specified date/time before retrying, so it calculates the wait time.
Given this Python code snippet:
from datetime import datetime, timezone
import time
def parse_retry_after(value):
try:
delay = int(value)
return delay
except ValueError:
retry_time = datetime.strptime(value, '%a, %d %b %Y %H:%M:%S %Z')
now = datetime.now(timezone.utc)
delta = (retry_time - now).total_seconds()
return max(0, int(delta))
# Example usage:
print(parse_retry_after('120'))
print(parse_retry_after('Wed, 21 Oct 2030 07:28:00 GMT'))Assuming the current UTC time is Wed, 21 Oct 2025 07:28:00 GMT, what will be the output?
from datetime import datetime, timezone import time def parse_retry_after(value): try: delay = int(value) return delay except ValueError: retry_time = datetime.strptime(value, '%a, %d %b %Y %H:%M:%S %Z') now = datetime.now(timezone.utc) delta = (retry_time - now).total_seconds() return max(0, int(delta)) # Example usage: print(parse_retry_after('120')) print(parse_retry_after('Wed, 21 Oct 2030 07:28:00 GMT'))
Calculate the seconds between 2025 and 2030 in years, then convert to seconds.
The first call returns 120 as integer. The second calculates seconds between 2025 and 2030, about 5 years, which is roughly 157766400 seconds.