Skip to content
Permalink
Browse files

Recheck all client error responses (4xx) as GET requests

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 a056aba30434dc4fc9b57a750e15e8348ea87af8
Showing with 3 additions and 3 deletions.
  1. +1 −1 CHANGES.txt
  2. +2 −2 nikola/plugins/command/check.py
@@ -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
@@ -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)

0 comments on commit a056aba

Please sign in to comment.
You can’t perform that action at this time.