mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-03-29 04:00:34 +00:00
on redirection to different URL scheme take caching into account; adjust tests
git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@3173 e7d03fd6-7b0d-0410-9947-9c21f3af8025
This commit is contained in:
parent
2a336f8dad
commit
91ff370ed7
2 changed files with 13 additions and 15 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue