Skip to content

Commit

Permalink
Assume UTC timezone if none specified in Retry-After header
Browse files Browse the repository at this point in the history
  • Loading branch information
hodbn committed Aug 25, 2020
1 parent df1f648 commit 02a69b9
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/urllib3/util/retry.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,12 @@ def parse_retry_after(self, retry_after):
retry_date_tuple = email.utils.parsedate_tz(retry_after)
if retry_date_tuple is None:
raise InvalidHeader("Invalid Retry-After header: %s" % retry_after)
if retry_date_tuple[9] is None: # Python 2
# Assume UTC if no timezone was specified
tmp = list(retry_date_tuple)
tmp[9] = 0
retry_date_tuple = tuple(tmp)

retry_date = email.utils.mktime_tz(retry_date_tuple)
seconds = retry_date - time.time()

Expand Down

0 comments on commit 02a69b9

Please sign in to comment.