Some sites also return 403 on HEAD requests

Atlassian websites will return a 403 Forbidden access code when
queried, so add this to the list of codes that should trigger using a
GET request as a fallback.
This commit is contained in:
Darragh Bailey 2016-03-23 15:47:19 +00:00
parent 0b9ee8d451
commit 2f46c7899c

View File

@ -162,10 +162,10 @@ class CheckExternalLinksBuilder(Builder):
response = requests.head(req_url, **kwargs)
response.raise_for_status()
except HTTPError as err:
if err.response.status_code != 405:
if err.response.status_code not in (403, 405):
raise
# retry with GET if that fails, some servers
# don't like HEAD requests and reply with 405
# don't like HEAD requests and reply with 403 or 405
response = requests.get(req_url, stream=True, **kwargs)
response.raise_for_status()
except HTTPError as err: