Add redirect warning for commandline URLs

If URLs given on the commandline are redirected, the automatic
intern patterns might not match anymore. A warning makes this
more prominent.


git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@3712 e7d03fd6-7b0d-0410-9947-9c21f3af8025
This commit is contained in:
calvin 2008-04-21 09:18:36 +00:00
parent a7b368eb88
commit 5a2f89fa3d
3 changed files with 8 additions and 0 deletions

View file

@ -196,6 +196,10 @@ class HttpUrl (internpaturl.InternPatternUrl, proxysupport.ProxySupport):
# redirections might have changed the URL
newurl = urlparse.urlunsplit(self.urlparts)
if self.url != newurl:
if self.warn_redirect:
linkcheck.log.warn(linkcheck.LOG_CHECK,
_("""URL %s has been redirected.
Use URL %s instead for checking."""), self.url, newurl)
self.url = newurl
# check response
if response:

View file

@ -116,6 +116,8 @@ class UrlBase (object):
url = linkcheck.checker.absolute_url(base_url, base_ref, parent_url)
# assume file link if no scheme is found
self.scheme = url.split(":", 1)[0] or "file"
# warn if URL is redirected (for commandline client)
self.warn_redirect = False
def reset (self):
"""

View file

@ -718,6 +718,8 @@ for url in args:
# syntactic sugar
url = "ftp://%s" % url
url_data = get_url_from(url, 0, aggregate)
# warn if redirected since intern patterns do not match anymore then
url_data.warn_redirect = True
try:
linkcheck.add_intern_pattern(url_data, config)
except UnicodeError: