Skip to content
Permalink
Browse files

Remote links all returned warnings when checked

Successes should return here too, would otherwise proceed down to
line 256 and produce a warnig.
  • Loading branch information
da2x committed May 19, 2015
1 parent 7550c74 commit c09c93cf7229a1785586148e233310b5b3d8ae86
Showing with 8 additions and 1 deletion.
  1. +1 −0 CHANGES.txt
  2. +7 −1 nikola/plugins/command/check.py
@@ -10,6 +10,7 @@ Features
Bugfixes
--------

* All remotely checked links resulted in incorrect warnings (`nikola check -lr`)
* Exclude `<meta content="noindex" name="robots">` from sitemaps
* new_post paths are now relative to CWD (Issue #1325)

@@ -218,10 +218,16 @@ def analyze(self, task, find_sources=False, check_remote=False):
if parsed.netloc == base_url.netloc:
continue
# Check the remote link works
resp = requests.head(target)
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)
if resp.status_code > 399: # Error
self.logger.warn("Broken link in {0}: {1} [Error {2}]".format(filename, target, resp.status_code))
continue
elif resp.status_code <= 399: # The address leads *somewhere* that is not an error
self.logger.debug("Successfully checked remote link in {0}: {1} [HTTP: {2}]".format(filename, target, resp.status_code))
continue
self.logger.warn("Could not check remote link in {0}: {1} [Unknown problem]".format(filename, target))
continue

if url_type == 'rel_path':
target_filename = os.path.abspath(

0 comments on commit c09c93c

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