Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8fac460

Browse files
committed
minor fix for None results
1 parent 4b784b0 commit 8fac460

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

lib/request/redirecthandler.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,19 @@ def common_http_redirect(self, result, headers, code, content, msg):
4848

4949
logger.log(7, responseMsg)
5050

51-
if "location" in headers:
52-
result.redurl = headers.getheaders("location")[0].split("?")[0]
53-
elif "uri" in headers:
54-
result.redurl = headers.getheaders("uri")[0].split("?")[0]
51+
if result:
52+
if "location" in headers:
53+
result.redurl = headers.getheaders("location")[0].split("?")[0]
54+
elif "uri" in headers:
55+
result.redurl = headers.getheaders("uri")[0].split("?")[0]
5556

56-
if hasattr(result, 'redurl'):
57-
if not urlparse.urlsplit(result.redurl).netloc:
58-
result.redurl = urlparse.urljoin(conf.url, result.redurl)
57+
if hasattr(result, 'redurl'):
58+
if not urlparse.urlsplit(result.redurl).netloc:
59+
result.redurl = urlparse.urljoin(conf.url, result.redurl)
5960

60-
if "set-cookie" in headers:
61-
result.setcookie = headers["set-cookie"].split("; path")[0]
61+
if "set-cookie" in headers:
62+
result.setcookie = headers["set-cookie"].split("; path")[0]
6263

63-
if result:
6464
result.redcode = code
6565

6666
return result

0 commit comments

Comments
 (0)