Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6faf987

Browse files
committed
Patch for --keep-alive (drei)
1 parent bc88903 commit 6faf987

3 files changed

Lines changed: 14 additions & 10 deletions

File tree

lib/core/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4692,7 +4692,7 @@ def getRequestHeader(request, name):
46924692

46934693
if request and request.headers and name:
46944694
_ = name.upper()
4695-
retVal = max(value if _ == key.upper() else "" for key, value in request.header_items()) or None
4695+
retVal = max(value if _ == key.upper() else type(value)() for key, value in request.header_items()) or None
46964696

46974697
return retVal
46984698

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from thirdparty import six
1919

2020
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
21-
VERSION = "1.3.5.43"
21+
VERSION = "1.3.5.44"
2222
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
2323
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
2424
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)

thirdparty/keepalive/keepalive.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def __init__(self):
135135
def add(self, host, connection, ready):
136136
self._lock.acquire()
137137
try:
138-
if not self._hostmap.has_key(host): self._hostmap[host] = []
138+
if host not in self._hostmap: self._hostmap[host] = []
139139
self._hostmap[host].append(connection)
140140
self._connmap[connection] = host
141141
self._readymap[connection] = ready
@@ -165,7 +165,7 @@ def get_ready_conn(self, host):
165165
conn = None
166166
self._lock.acquire()
167167
try:
168-
if self._hostmap.has_key(host):
168+
if host in self._hostmap:
169169
for c in self._hostmap[host]:
170170
if self._readymap[c]:
171171
self._readymap[c] = 0
@@ -312,16 +312,16 @@ def _reuse_connection(self, h, req, host):
312312

313313
def _start_transaction(self, h, req):
314314
try:
315-
if req.has_data():
315+
if req.data:
316316
data = req.data
317317
if hasattr(req, 'selector'):
318318
h.putrequest(req.get_method() or 'POST', req.selector, skip_host=req.has_header("Host"), skip_accept_encoding=req.has_header("Accept-encoding"))
319319
else:
320320
h.putrequest(req.get_method() or 'POST', req.get_selector(), skip_host=req.has_header("Host"), skip_accept_encoding=req.has_header("Accept-encoding"))
321-
if not req.headers.has_key('Content-type'):
321+
if 'Content-type' not in req.headers:
322322
h.putheader('Content-type',
323323
'application/x-www-form-urlencoded')
324-
if not req.headers.has_key('Content-length'):
324+
if 'Content-length' not in req.headers:
325325
h.putheader('Content-length', '%d' % len(data))
326326
else:
327327
if hasattr(req, 'selector'):
@@ -331,16 +331,16 @@ def _start_transaction(self, h, req):
331331
except (socket.error, _http_client.HTTPException) as err:
332332
raise _urllib.error.URLError(err)
333333

334-
if not req.headers.has_key('Connection'):
334+
if 'Connection' not in req.headers:
335335
req.headers['Connection'] = 'keep-alive'
336336

337337
for args in self.parent.addheaders:
338-
if not req.headers.has_key(args[0]):
338+
if args[0] not in req.headers:
339339
h.putheader(*args)
340340
for k, v in req.headers.items():
341341
h.putheader(k, v)
342342
h.endheaders()
343-
if req.has_data():
343+
if req.data:
344344
h.send(data)
345345

346346
def _get_connection(self, host):
@@ -419,6 +419,10 @@ def close(self):
419419
self._handler._request_closed(self, self._host,
420420
self._connection)
421421

422+
# Note: Patch for Python3 (otherwise, connections won't be reusable)
423+
def _close_conn(self):
424+
self.close()
425+
422426
def close_connection(self):
423427
self._handler._remove_connection(self._host, self._connection, close=1)
424428
self.close()

0 commit comments

Comments
 (0)