Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sqlmapproject
GitHub Repository: sqlmapproject/sqlmap
Path: blob/master/lib/request/rangehandler.py
2989 views
1
#!/usr/bin/env python
2
3
"""
4
Copyright (c) 2006-2025 sqlmap developers (https://sqlmap.org)
5
See the file 'LICENSE' for copying permission
6
"""
7
8
from lib.core.exception import SqlmapConnectionException
9
from thirdparty.six.moves import urllib as _urllib
10
11
class HTTPRangeHandler(_urllib.request.BaseHandler):
12
"""
13
Handler that enables HTTP Range headers.
14
15
Reference: http://stackoverflow.com/questions/1971240/python-seek-on-remote-file
16
"""
17
18
def http_error_206(self, req, fp, code, msg, hdrs):
19
# 206 Partial Content Response
20
r = _urllib.response.addinfourl(fp, hdrs, req.get_full_url())
21
r.code = code
22
r.msg = msg
23
return r
24
25
def http_error_416(self, req, fp, code, msg, hdrs):
26
# HTTP's Range Not Satisfiable error
27
errMsg = "there was a problem while connecting "
28
errMsg += "target ('406 - Range Not Satisfiable')"
29
raise SqlmapConnectionException(errMsg)
30
31