retry httperrors in py2 without ssl

This commit is contained in:
Alan Hamlett 2021-11-01 17:18:06 -07:00
parent 6fa1321a95
commit 389c84673e

View File

@ -837,6 +837,18 @@ def request(url, last_modified=None):
except HTTPError as err: except HTTPError as err:
if err.code == 304: if err.code == 304:
return None, None, 304 return None, None, 304
if is_py2:
ssl._create_default_https_context = ssl._create_unverified_context
try:
resp = urlopen(url)
headers = dict(resp.getheaders()) if is_py2 else resp.headers
return headers, resp.read(), resp.getcode()
except HTTPError as err:
if err.code == 304:
return None, None, 304
raise
except IOError:
raise
raise raise
except IOError: except IOError:
if is_py2: if is_py2:
@ -849,6 +861,8 @@ def request(url, last_modified=None):
if err.code == 304: if err.code == 304:
return None, None, 304 return None, None, 304
raise raise
except IOError:
raise
raise raise