Skip to content

Commit

Permalink
Recheck all client error responses (4xx) as GET requests
Browse files Browse the repository at this point in the history
Misconfigured reverse proxies and broken IIS setups return 404,
405, or other client errors for HEAD requests. Retesting these as
GET requests. Nikola is still a good netizen by at least trying
to perform this operation as HEAD before going all GET.
  • Loading branch information
da2x committed Jul 27, 2015
1 parent c49ef8c commit a056aba
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CHANGES.txt
Expand Up @@ -12,7 +12,7 @@ Features
Bugfixes
--------

* Retry HEAD as GET requests if server returns 405 when checking remote links
* Retry all client errors (4xx) to HEAD as GET reques when checking remote links
* Graceful fallback in ``nikola serve --detach`` on Windows (Issue #1913)
* Don't auto-rebuild on changes to ".foo" or "foo~" or changes in folders
* auto should also rebuild in response to move events
Expand Down
4 changes: 2 additions & 2 deletions nikola/plugins/command/check.py
Expand Up @@ -224,8 +224,8 @@ def analyze(self, fname, find_sources=False, check_remote=False):
# Check the remote link works
req_headers = {'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0 (Nikola)'} # I’m a real boy!
resp = requests.head(target, headers=req_headers)
# HEAD is not understood, so retry with a full GET after a half a second
if resp.status_code == 405:
# Retry client errors (4xx) as GET requests
if resp.status_code => 400 and resp.status_code <= 499:
time.sleep(0.5)
resp = requests.get(target, headers=req_headers)

Expand Down

0 comments on commit a056aba

Please sign in to comment.