diff --git a/linkcheck/checker/httpurl.py b/linkcheck/checker/httpurl.py index 270ffd55..eb40b879 100644 --- a/linkcheck/checker/httpurl.py +++ b/linkcheck/checker/httpurl.py @@ -313,13 +313,6 @@ class HttpUrl (internpaturl.InternPatternUrl, proxysupport.ProxySupport): assert None == linkcheck.log.debug(linkcheck.LOG_CHECK, "Norm redirected to %r", redirected) urlparts = linkcheck.strformat.url_unicode_split(redirected) - # check if we still have the same scheme type, it could be a - # different one - if urlparts[0] != self.scheme: - self.add_warning( - _("Redirection to different URL type encountered; " - "the original URL was %r.") % self.url, - tag="http-wrong-redirect") # check extern filter again self.set_extern(redirected) if self.extern[0] and self.extern[0]: @@ -348,8 +341,9 @@ class HttpUrl (internpaturl.InternPatternUrl, proxysupport.ProxySupport): _("recursive redirection encountered:\n %s") % "\n => ".join(recursion), valid=False) return -1, response - # remember redireced url as alias - self.aliases.append(redirected) + if urlparts[0] == self.scheme: + # remember redireced url as alias + self.aliases.append(redirected) # note: urlparts has to be a list self.urlparts = urlparts if response.status == 301: @@ -364,13 +358,15 @@ class HttpUrl (internpaturl.InternPatternUrl, proxysupport.ProxySupport): return -1, response # in case of changed scheme make new URL object if self.urlparts[0] != self.scheme: + self.add_warning( + _("Redirection to different URL type encountered; " + "the original URL was %r.") % self.url, + tag="http-wrong-redirect") newobj = linkcheck.checker.get_url_from( redirected, self.recursion_level, self.aggregate, parent_url=self.parent_url, base_ref=self.base_ref, line=self.line, column=self.column, name=self.name, assume_local=False) - newobj.warnings = self.warnings - newobj.info = self.info # append new object to queue self.aggregate.urlqueue.put(newobj) # pretend to be finished and logged diff --git a/linkcheck/checker/tests/test_http.py b/linkcheck/checker/tests/test_http.py index aa2662f8..2b0a77a5 100644 --- a/linkcheck/checker/tests/test_http.py +++ b/linkcheck/checker/tests/test_http.py @@ -53,17 +53,19 @@ class TestHttp (linkcheck.checker.tests.httptest.HttpServerTest): def redirect_https_test (self): url = u"http://localhost:%d/redirect1" % self.port nurl = url - rurl = url.replace('redirect', 'newurl') + rurl = u"https://localhost:%d/newurl1" % self.port resultlines = [ u"url %s" % url, u"cache key %s" % nurl, - u"real url %s" % nurl, + u"real url %s" % rurl, u"info Redirected to %s." % rurl.replace('http:', 'https:'), - u"info The redirected URL is outside of the domain filter, " \ - u"checked only syntax.", u"warning Redirection to different URL type encountered; the " \ u"original URL was u'http://localhost:%d/redirect1'." % self.port, u"valid", + u"url https://localhost:8001/newurl1", + u"cache key https://localhost:8001/newurl1", + u"real url https://localhost:8001/newurl1", + u"error", ] self.direct(url, resultlines, recursionlevel=0, assume_local=True)