@@ -106,7 +106,6 @@ def getPage(**kwargs):
106106 conn = multipartOpener .open (url , multipart )
107107 page = conn .read ()
108108 responseHeaders = conn .info ()
109-
110109 page = decodePage (page , responseHeaders .get ("Content-Encoding" ), responseHeaders .get ("Content-Type" ))
111110
112111 return page
@@ -119,45 +118,21 @@ def getPage(**kwargs):
119118 get = urlencode (get )
120119 url = "%s?%s" % (url , get )
121120 requestMsg += "?%s" % get
122-
121+
123122 if conf .method == "POST" :
124123 if conf .parameters .has_key ("POST" ) and not post :
125124 post = conf .parameters ["POST" ]
126125
127126 requestMsg += " HTTP/1.1"
128127
129128 # Perform HTTP request
130- headers = forgeHeaders (cookie , ua )
131- req = urllib2 .Request (url , post , headers )
132- conn = urllib2 .urlopen (req )
133-
134- if hasattr (conn , "redurl" ) and hasattr (conn , "redcode" ) and not conf .redirectHandled :
135- msg = "sqlmap got a %d redirect to " % conn .redcode
136- msg += "%s - What target address do you " % conn .redurl
137- msg += "want to use from now on? %s " % conf .url
138- msg += "(default) or provide another target address based "
139- msg += "also on the redirection got from the application\n "
140-
141- while True :
142- choice = readInput (msg , default = "1" )
143-
144- if not choice or choice == "1" :
145- pass
146- else :
147- conf .url = choice
148- return Connect .__getPageProxy (** kwargs )
149-
150- break
151-
152- conf .redirectHandled = True
153-
154- # Reset the number of connection retries
155- conf .retriesCount = 0
129+ headers = forgeHeaders (cookie , ua )
130+ req = urllib2 .Request (url , post , headers )
156131
157132 if not req .has_header ("Accept-Encoding" ):
158- requestHeaders += "\n Accept -Encoding: identity"
133+ requestHeaders += "Accept -Encoding: identity\n "
159134
160- requestHeaders = "\n " .join (["%s: %s" % (header , value ) for header , value in req .header_items ()])
135+ requestHeaders + = "\n " .join (["%s: %s" % (header , value ) for header , value in req .header_items ()])
161136
162137 if not conf .dropSetCookie and conf .cj :
163138 for _ , cookie in enumerate (conf .cj ):
@@ -171,7 +146,7 @@ def getPage(**kwargs):
171146
172147 if not req .has_header ("Cookie" ) and cookieStr :
173148 requestHeaders += "\n %s" % cookieStr [:- 2 ]
174-
149+
175150 if not req .has_header ("Connection" ):
176151 requestHeaders += "\n Connection: close"
177152
@@ -184,12 +159,36 @@ def getPage(**kwargs):
184159
185160 logger .log (9 , requestMsg )
186161
162+ conn = urllib2 .urlopen (req )
163+
164+ if hasattr (conn , "redurl" ) and hasattr (conn , "redcode" ) and not conf .redirectHandled :
165+ msg = "sqlmap got a %d redirect to " % conn .redcode
166+ msg += "%s - What target address do you " % conn .redurl
167+ msg += "want to use from now on? %s " % conf .url
168+ msg += "(default) or provide another target address based "
169+ msg += "also on the redirection got from the application\n "
170+
171+ while True :
172+ choice = readInput (msg , default = "1" )
173+
174+ if not choice or choice == "1" :
175+ pass
176+ else :
177+ conf .url = choice
178+ return Connect .__getPageProxy (** kwargs )
179+
180+ break
181+
182+ conf .redirectHandled = True
183+
184+ # Reset the number of connection retries
185+ conf .retriesCount = 0
186+
187187 # Get HTTP response
188- page = conn .read ()
189- code = conn .code
190- status = conn .msg
188+ page = conn .read ()
189+ code = conn .code
190+ status = conn .msg
191191 responseHeaders = conn .info ()
192-
193192 page = decodePage (page , responseHeaders .get ("Content-Encoding" ), responseHeaders .get ("Content-Type" ))
194193
195194 except urllib2 .HTTPError , e :
0 commit comments