mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2024-11-22 01:26:42 +03:00
Patch for --keep-alive (drei)
This commit is contained in:
parent
bc88903699
commit
6faf9872bc
|
@ -4692,7 +4692,7 @@ def getRequestHeader(request, name):
|
|||
|
||||
if request and request.headers and name:
|
||||
_ = name.upper()
|
||||
retVal = max(value if _ == key.upper() else "" for key, value in request.header_items()) or None
|
||||
retVal = max(value if _ == key.upper() else type(value)() for key, value in request.header_items()) or None
|
||||
|
||||
return retVal
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ from lib.core.enums import OS
|
|||
from thirdparty import six
|
||||
|
||||
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
|
||||
VERSION = "1.3.5.43"
|
||||
VERSION = "1.3.5.44"
|
||||
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
|
||||
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
|
||||
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)
|
||||
|
|
20
thirdparty/keepalive/keepalive.py
vendored
20
thirdparty/keepalive/keepalive.py
vendored
|
@ -135,7 +135,7 @@ class ConnectionManager:
|
|||
def add(self, host, connection, ready):
|
||||
self._lock.acquire()
|
||||
try:
|
||||
if not self._hostmap.has_key(host): self._hostmap[host] = []
|
||||
if host not in self._hostmap: self._hostmap[host] = []
|
||||
self._hostmap[host].append(connection)
|
||||
self._connmap[connection] = host
|
||||
self._readymap[connection] = ready
|
||||
|
@ -165,7 +165,7 @@ class ConnectionManager:
|
|||
conn = None
|
||||
self._lock.acquire()
|
||||
try:
|
||||
if self._hostmap.has_key(host):
|
||||
if host in self._hostmap:
|
||||
for c in self._hostmap[host]:
|
||||
if self._readymap[c]:
|
||||
self._readymap[c] = 0
|
||||
|
@ -312,16 +312,16 @@ class KeepAliveHandler:
|
|||
|
||||
def _start_transaction(self, h, req):
|
||||
try:
|
||||
if req.has_data():
|
||||
if req.data:
|
||||
data = req.data
|
||||
if hasattr(req, 'selector'):
|
||||
h.putrequest(req.get_method() or 'POST', req.selector, skip_host=req.has_header("Host"), skip_accept_encoding=req.has_header("Accept-encoding"))
|
||||
else:
|
||||
h.putrequest(req.get_method() or 'POST', req.get_selector(), skip_host=req.has_header("Host"), skip_accept_encoding=req.has_header("Accept-encoding"))
|
||||
if not req.headers.has_key('Content-type'):
|
||||
if 'Content-type' not in req.headers:
|
||||
h.putheader('Content-type',
|
||||
'application/x-www-form-urlencoded')
|
||||
if not req.headers.has_key('Content-length'):
|
||||
if 'Content-length' not in req.headers:
|
||||
h.putheader('Content-length', '%d' % len(data))
|
||||
else:
|
||||
if hasattr(req, 'selector'):
|
||||
|
@ -331,16 +331,16 @@ class KeepAliveHandler:
|
|||
except (socket.error, _http_client.HTTPException) as err:
|
||||
raise _urllib.error.URLError(err)
|
||||
|
||||
if not req.headers.has_key('Connection'):
|
||||
if 'Connection' not in req.headers:
|
||||
req.headers['Connection'] = 'keep-alive'
|
||||
|
||||
for args in self.parent.addheaders:
|
||||
if not req.headers.has_key(args[0]):
|
||||
if args[0] not in req.headers:
|
||||
h.putheader(*args)
|
||||
for k, v in req.headers.items():
|
||||
h.putheader(k, v)
|
||||
h.endheaders()
|
||||
if req.has_data():
|
||||
if req.data:
|
||||
h.send(data)
|
||||
|
||||
def _get_connection(self, host):
|
||||
|
@ -419,6 +419,10 @@ class HTTPResponse(_http_client.HTTPResponse):
|
|||
self._handler._request_closed(self, self._host,
|
||||
self._connection)
|
||||
|
||||
# Note: Patch for Python3 (otherwise, connections won't be reusable)
|
||||
def _close_conn(self):
|
||||
self.close()
|
||||
|
||||
def close_connection(self):
|
||||
self._handler._remove_connection(self._host, self._connection, close=1)
|
||||
self.close()
|
||||
|
|
Loading…
Reference in New Issue
Block a user