mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-12-10 09:49:06 +00:00
Revamp of #3536
This commit is contained in:
@@ -6,16 +6,15 @@ See the file 'LICENSE' for copying permission
|
||||
"""
|
||||
|
||||
import urllib2
|
||||
import httplib
|
||||
|
||||
from lib.core.data import conf
|
||||
|
||||
|
||||
class HTTPHandler(urllib2.HTTPHandler):
|
||||
class ChunkedHandler(urllib2.HTTPHandler):
|
||||
"""
|
||||
The hook http_requests function ensures that the chunk function is working properly.
|
||||
Ensures that urllib2.HTTPHandler is working properly in case of Chunked Transfer-Encoding
|
||||
"""
|
||||
|
||||
def _hook(self, request):
|
||||
def _http_request(self, request):
|
||||
host = request.get_host()
|
||||
if not host:
|
||||
raise urllib2.URLError('no host given')
|
||||
@@ -26,7 +25,7 @@ class HTTPHandler(urllib2.HTTPHandler):
|
||||
request.add_unredirected_header(
|
||||
'Content-type',
|
||||
'application/x-www-form-urlencoded')
|
||||
if not request.has_header('Content-length') and not conf.chunk:
|
||||
if not request.has_header('Content-length') and not conf.chunked:
|
||||
request.add_unredirected_header(
|
||||
'Content-length', '%d' % len(data))
|
||||
|
||||
@@ -43,4 +42,4 @@ class HTTPHandler(urllib2.HTTPHandler):
|
||||
request.add_unredirected_header(name, value)
|
||||
return request
|
||||
|
||||
http_request = _hook
|
||||
http_request = _http_request
|
||||
@@ -31,6 +31,7 @@ from lib.core.agent import agent
|
||||
from lib.core.common import asciifyUrl
|
||||
from lib.core.common import calculateDeltaSeconds
|
||||
from lib.core.common import checkSameHost
|
||||
from lib.core.common import chunkSplitPostData
|
||||
from lib.core.common import clearConsoleLine
|
||||
from lib.core.common import dataToStdout
|
||||
from lib.core.common import escapeJsonValue
|
||||
@@ -61,7 +62,6 @@ from lib.core.common import unicodeencode
|
||||
from lib.core.common import unsafeVariableNaming
|
||||
from lib.core.common import urldecode
|
||||
from lib.core.common import urlencode
|
||||
from lib.core.common import generateChunkDdata
|
||||
from lib.core.data import conf
|
||||
from lib.core.data import kb
|
||||
from lib.core.data import logger
|
||||
@@ -272,13 +272,14 @@ class Connect(object):
|
||||
checking = kwargs.get("checking", False)
|
||||
skipRead = kwargs.get("skipRead", False)
|
||||
finalCode = kwargs.get("finalCode", False)
|
||||
chunked = conf.chunk
|
||||
chunked = kwargs.get("chunked", False) or conf.chunked
|
||||
|
||||
if multipart:
|
||||
post = multipart
|
||||
|
||||
if chunked:
|
||||
post = urllib.unquote(post)
|
||||
post = generateChunkDdata(post)
|
||||
post = chunkSplitPostData(post)
|
||||
|
||||
websocket_ = url.lower().startswith("ws")
|
||||
|
||||
@@ -403,7 +404,7 @@ class Connect(object):
|
||||
headers[HTTP_HEADER.CONNECTION] = "keep-alive"
|
||||
|
||||
if chunked:
|
||||
headers[HTTP_HEADER.TRANSFER_ENCODING] = "Chunked"
|
||||
headers[HTTP_HEADER.TRANSFER_ENCODING] = "chunked"
|
||||
|
||||
if auxHeaders:
|
||||
headers = forgeHeaders(auxHeaders, headers)
|
||||
|
||||
Reference in New Issue
Block a user