mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-12-06 04:31:30 +00:00
God help us all with this Python3 non-sense
This commit is contained in:
@@ -5,41 +5,19 @@ Copyright (c) 2006-2019 sqlmap developers (http://sqlmap.org/)
|
||||
See the file 'LICENSE' for copying permission
|
||||
"""
|
||||
|
||||
import urllib
|
||||
import urllib2
|
||||
|
||||
from lib.core.exception import SqlmapConnectionException
|
||||
from thirdparty.six.moves import urllib as _urllib
|
||||
|
||||
class HTTPRangeHandler(urllib2.BaseHandler):
|
||||
class HTTPRangeHandler(_urllib.request.BaseHandler):
|
||||
"""
|
||||
Handler that enables HTTP Range headers.
|
||||
|
||||
Reference: http://stackoverflow.com/questions/1971240/python-seek-on-remote-file
|
||||
|
||||
This was extremely simple. The Range header is a HTTP feature to
|
||||
begin with so all this class does is tell urllib2 that the
|
||||
"206 Partial Content" response from the HTTP server is what we
|
||||
expected.
|
||||
|
||||
Example:
|
||||
import urllib2
|
||||
import byterange
|
||||
|
||||
range_handler = range.HTTPRangeHandler()
|
||||
opener = urllib2.build_opener(range_handler)
|
||||
|
||||
# install it
|
||||
urllib2.install_opener(opener)
|
||||
|
||||
# create Request and set Range header
|
||||
req = urllib2.Request('https://www.python.org/')
|
||||
req.header['Range'] = 'bytes=30-50'
|
||||
f = urllib2.urlopen(req)
|
||||
"""
|
||||
|
||||
def http_error_206(self, req, fp, code, msg, hdrs):
|
||||
# 206 Partial Content Response
|
||||
r = urllib.addinfourl(fp, hdrs, req.get_full_url())
|
||||
r = _urllib.response.addinfourl(fp, hdrs, req.get_full_url())
|
||||
r.code = code
|
||||
r.msg = msg
|
||||
return r
|
||||
|
||||
Reference in New Issue
Block a user