Skip to content

Commit

Permalink
Refactor and explain Retry-After behavior with no timezone
Browse files Browse the repository at this point in the history
  • Loading branch information
hodbn committed Aug 25, 2020
1 parent 02a69b9 commit f639520
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/urllib3/util/retry.py
Expand Up @@ -271,9 +271,10 @@ def parse_retry_after(self, retry_after):
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)
# On Python2.7, parsedate_tz returns None for a timezone offset
# instead of 0 if no timezone is given, where mktime_tz treats
# a None timezone offset as local time.
retry_date_tuple = retry_date_tuple[:9] + (0,) + retry_date_tuple[10:]

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

0 comments on commit f639520

Please sign in to comment.