1313from lib .core .common import getSafeExString
1414from lib .core .common import logHTTPTraffic
1515from lib .core .common import readInput
16+ from lib .core .convert import getBytes
1617from lib .core .convert import getUnicode
1718from lib .core .data import conf
1819from lib .core .data import kb
@@ -64,8 +65,7 @@ def _ask_redirect_choice(self, redcode, redurl, method):
6465 self .redirect_request = self ._redirect_request
6566
6667 def _redirect_request (self , req , fp , code , msg , headers , newurl ):
67- newurl = newurl .replace (' ' , '%20' )
68- return _urllib .request .Request (newurl , data = req .data , headers = req .headers , origin_req_host = req .get_origin_req_host ())
68+ return _urllib .request .Request (newurl .replace (' ' , '%20' ), data = req .data , headers = req .headers , origin_req_host = req .get_origin_req_host ())
6969
7070 def http_error_302 (self , req , fp , code , msg , headers ):
7171 start = time .time ()
@@ -75,7 +75,7 @@ def http_error_302(self, req, fp, code, msg, headers):
7575 try :
7676 content = fp .read (MAX_CONNECTION_TOTAL_SIZE )
7777 except : # e.g. IncompleteRead
78- content = ""
78+ content = b ""
7979 finally :
8080 if content :
8181 try : # try to write it back to the read buffer so we could reuse it in further steps
@@ -163,7 +163,7 @@ def _(self, length=None):
163163 retVal = getSafeExString (ex ) # Note: pyflakes mistakenly marks 'ex' as undefined (NOTE: tested in both Python2 and Python3)
164164 except :
165165 retVal = ""
166- return retVal
166+ return getBytes ( retVal )
167167
168168 result .read = types .MethodType (_ , result )
169169
0 commit comments