mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-14 07:04:27 -04:00
fix: Improve headers handling
This commit is contained in:
parent
a40af98ced
commit
62ed11a5ca
6 changed files with 60 additions and 3 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue