Skip to content

Commit

Permalink
Patch for an Issue sqlmapproject#1157
Browse files Browse the repository at this point in the history
  • Loading branch information
stamparm committed Feb 4, 2015
1 parent 66c2a79 commit 3801174
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/request/connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def _connReadProxy(conn):

if not kb.dnsMode and conn:
headers = conn.info()
if headers and (headers.getheader(HTTP_HEADER.CONTENT_ENCODING, "").lower() in ("gzip", "deflate")\
if headers and hasattr(headers, "getheader") and (headers.getheader(HTTP_HEADER.CONTENT_ENCODING, "").lower() in ("gzip", "deflate")\
or "text" not in headers.getheader(HTTP_HEADER.CONTENT_TYPE, "").lower()):
retVal = conn.read(MAX_CONNECTION_TOTAL_SIZE)
if len(retVal) == MAX_CONNECTION_TOTAL_SIZE:
Expand Down
20 changes: 20 additions & 0 deletions lib/request/redirecthandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
See the file 'doc/COPYING' for copying permission
"""

import types
import urllib2
import urlparse

Expand Down Expand Up @@ -124,6 +125,25 @@ def http_error_302(self, req, fp, code, msg, headers):
result = urllib2.HTTPRedirectHandler.http_error_302(self, req, fp, code, msg, headers)
except urllib2.HTTPError, e:
result = e

# Dirty hack for http://bugs.python.org/issue15701
try:
result.info()
except AttributeError:
def _(self):
return getattr(self, "hdrs") or {}
result.info = types.MethodType(_, result)

if not hasattr(result, "read"):
def _(self, length=None):
return e.msg
result.read = types.MethodType(_, result)

if not getattr(result, "url", None):
result.url = redurl

if not getattr(result, "code", None):
result.code = 999
except:
redurl = None
result = fp
Expand Down

0 comments on commit 3801174

Please sign in to comment.