Skip to content
Browse files
Retry HEAD as GET if server returns 405 when
  • Loading branch information
da2x committed Jul 27, 2015
1 parent e807212 commit c49ef8caff89c8661b96062243232bc90ff9aefe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
@@ -12,6 +12,7 @@ Features

* Retry HEAD as GET requests if server returns 405 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
@@ -29,6 +29,7 @@
import os
import re
import sys
import time
from urllib import unquote
from urlparse import urlparse, urljoin, urldefrag
@@ -223,6 +224,11 @@ 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:
resp = requests.get(target, headers=req_headers)

self.checked_remote_targets[target] = resp.status_code
if resp.status_code > 399: # Error
self.logger.warn("Broken link in {0}: {1} [Error {2}]".format(filename, target, resp.status_code))

0 comments on commit c49ef8c

Please sign in to comment.