@@ -44,34 +44,6 @@ def _ask_redirect_choice(self, redcode, redurl):
4444
4545 kb .redirectChoice = choice .upper ()
4646
47- def _process_http_redirect (self , result , headers , code , content , msg , redurl ):
48- content = decodePage (content , headers .get (HTTPHEADER .CONTENT_ENCODING ), headers .get (HTTPHEADER .CONTENT_TYPE ))
49-
50- threadData = getCurrentThreadData ()
51- threadData .lastRedirectMsg = (threadData .lastRequestUID , content )
52-
53- responseMsg = "HTTP response "
54- responseMsg += "[#%d] (%d %s):\n " % (threadData .lastRequestUID , code , getUnicode (msg ))
55-
56- if headers :
57- logHeaders = "\n " .join ("%s: %s" % (key .capitalize () if isinstance (key , basestring ) else key , getUnicode (value )) for (key , value ) in headers .items ())
58- else :
59- logHeaders = ""
60-
61- logHTTPTraffic (threadData .lastRequestMsg , "%s%s" % (responseMsg , logHeaders ))
62-
63- responseMsg += getUnicode (logHeaders )
64-
65- logger .log (CUSTOM_LOGGING .TRAFFIC_IN , responseMsg )
66-
67- if "set-cookie" in headers :
68- kb .redirectSetCookie = headers ["set-cookie" ].split ("; path" )[0 ]
69-
70- result .redcode = code
71- result .redurl = redurl
72-
73- return result
74-
7547 def http_error_302 (self , req , fp , code , msg , headers ):
7648 content = None
7749 redurl = self ._get_header_redirect (headers )
@@ -83,7 +55,11 @@ def http_error_302(self, req, fp, code, msg, headers):
8355 dbgMsg += "redirect response content (%s)" % msg
8456 logger .debug (dbgMsg )
8557
58+ content = decodePage (content , headers .get (HTTPHEADER .CONTENT_ENCODING ), headers .get (HTTPHEADER .CONTENT_TYPE ))
59+
8660 threadData = getCurrentThreadData ()
61+ threadData .lastRedirectMsg = (threadData .lastRequestUID , content )
62+
8763 redirectMsg = "HTTP redirect "
8864 redirectMsg += "[#%d] (%d %s):\n " % (threadData .lastRequestUID , code , getUnicode (msg ))
8965
@@ -92,10 +68,11 @@ def http_error_302(self, req, fp, code, msg, headers):
9268 else :
9369 logHeaders = ""
9470
95- redirectMsg += "%s \n " % logHeaders
71+ redirectMsg += logHeaders
9672 if content :
97- redirectMsg += "\n %s" % content [:MAX_CONNECTION_CHUNK_SIZE ]
73+ redirectMsg += "\n \n %s" % content [:MAX_CONNECTION_CHUNK_SIZE ]
9874
75+ logHTTPTraffic (threadData .lastRequestMsg , redirectMsg )
9976 logger .log (CUSTOM_LOGGING .TRAFFIC_IN , redirectMsg )
10077
10178 if redurl :
@@ -111,7 +88,13 @@ def http_error_302(self, req, fp, code, msg, headers):
11188 else :
11289 result = fp
11390
114- return self ._process_http_redirect (result , headers , code , content , msg , redurl )
91+ if HTTPHEADER .SET_COOKIE in headers :
92+ kb .redirectSetCookie = headers .get (HTTPHEADER .SET_COOKIE ).split ("; path" )[0 ]
93+
94+ result .redcode = code
95+ result .redurl = redurl
96+
97+ return result
11598
11699 http_error_301 = http_error_303 = http_error_307 = http_error_302
117100
0 commit comments