FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
sqlmap/lib/request/rangehandler.py at master · sql9/sqlmap · GitHub
sql9
sqlmap
Repository navigation
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
sqlmap
/
lib
/
request
/
rangehandler.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
50 lines (38 loc) · 1.41 KB
Breadcrumbs
sqlmap
/
lib
/
request
/
rangehandler.py
Copy path
File metadata and controls
50 lines (38 loc) · 1.41 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python
"""
Copyright (c) 2006-2015 sqlmap developers (http://sqlmap.org/)
See the file 'doc/COPYING' for copying permission
"""
import
urllib
import
urllib2
from
lib
.
core
.
exception
import
SqlmapConnectionException
class
HTTPRangeHandler
(
urllib2
.
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('http://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
.
code
=
code
r
.
msg
=
msg
return
r
def
http_error_416
(
self
,
req
,
fp
,
code
,
msg
,
hdrs
):
# HTTP's Range Not Satisfiable error
errMsg
=
"Invalid range"
raise
SqlmapConnectionException
(
errMsg
)
Back
|
FazBrowse Home
|
New Git URL