From 8fac4605a95f82c9304cbfe15eb0c60648b7dd3b Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Fri, 10 Jun 2011 22:28:15 +0000 Subject: [PATCH] minor fix for None results --- lib/request/redirecthandler.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/request/redirecthandler.py b/lib/request/redirecthandler.py index cce841877..8ac7ab9b4 100644 --- a/lib/request/redirecthandler.py +++ b/lib/request/redirecthandler.py @@ -48,19 +48,19 @@ class SmartRedirectHandler(urllib2.HTTPRedirectHandler): logger.log(7, responseMsg) - if "location" in headers: - result.redurl = headers.getheaders("location")[0].split("?")[0] - elif "uri" in headers: - result.redurl = headers.getheaders("uri")[0].split("?")[0] - - if hasattr(result, 'redurl'): - if not urlparse.urlsplit(result.redurl).netloc: - result.redurl = urlparse.urljoin(conf.url, result.redurl) - - if "set-cookie" in headers: - result.setcookie = headers["set-cookie"].split("; path")[0] - if result: + if "location" in headers: + result.redurl = headers.getheaders("location")[0].split("?")[0] + elif "uri" in headers: + result.redurl = headers.getheaders("uri")[0].split("?")[0] + + if hasattr(result, 'redurl'): + if not urlparse.urlsplit(result.redurl).netloc: + result.redurl = urlparse.urljoin(conf.url, result.redurl) + + if "set-cookie" in headers: + result.setcookie = headers["set-cookie"].split("; path")[0] + result.redcode = code return result