2019-05-08 12:47:52 +02:00
|
|
|
#!/usr/bin/env python
|
2010-11-08 12:26:13 +00:00
|
|
|
|
|
|
|
|
"""
|
2023-01-02 23:24:59 +01:00
|
|
|
Copyright (c) 2006-2023 sqlmap developers (https://sqlmap.org/)
|
2017-10-11 14:50:46 +02:00
|
|
|
See the file 'LICENSE' for copying permission
|
2010-11-08 12:26:13 +00:00
|
|
|
"""
|
|
|
|
|
|
2012-12-06 14:14:19 +01:00
|
|
|
from lib.core.exception import SqlmapConnectionException
|
2019-03-27 13:33:46 +01:00
|
|
|
from thirdparty.six.moves import urllib as _urllib
|
2010-11-08 12:26:13 +00:00
|
|
|
|
2019-03-27 13:33:46 +01:00
|
|
|
class HTTPRangeHandler(_urllib.request.BaseHandler):
|
2010-11-08 12:26:13 +00:00
|
|
|
"""
|
|
|
|
|
Handler that enables HTTP Range headers.
|
|
|
|
|
|
|
|
|
|
Reference: http://stackoverflow.com/questions/1971240/python-seek-on-remote-file
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
def http_error_206(self, req, fp, code, msg, hdrs):
|
|
|
|
|
# 206 Partial Content Response
|
2019-03-27 13:33:46 +01:00
|
|
|
r = _urllib.response.addinfourl(fp, hdrs, req.get_full_url())
|
2010-11-08 12:26:13 +00:00
|
|
|
r.code = code
|
|
|
|
|
r.msg = msg
|
|
|
|
|
return r
|
|
|
|
|
|
|
|
|
|
def http_error_416(self, req, fp, code, msg, hdrs):
|
|
|
|
|
# HTTP's Range Not Satisfiable error
|
2019-07-11 11:30:21 +02:00
|
|
|
errMsg = "there was a problem while connecting "
|
|
|
|
|
errMsg += "target ('406 - Range Not Satisfiable')"
|
2013-01-03 23:20:55 +01:00
|
|
|
raise SqlmapConnectionException(errMsg)
|