fix: Improve headers handling

This commit is contained in:
Cristian 2020-09-24 08:37:27 -05:00 committed by Cristian Vargas
parent a40af98ced
commit 62ed11a5ca
6 changed files with 60 additions and 3 deletions

View file

@ -186,13 +186,17 @@ def get_headers(url: str, timeout: int=None) -> str:
headers={'User-Agent': WGET_USER_AGENT},
verify=CHECK_SSL_VALIDITY,
timeout=timeout,
allow_redirects=True
)
if response.status_code >= 400:
raise RequestException
except RequestException:
response = requests.get(
url,
headers={'User-Agent': WGET_USER_AGENT},
verify=CHECK_SSL_VALIDITY,
timeout=timeout,
stream=True
)
return pyjson.dumps(dict(response.headers), indent=4)