Fixes Python3 support for --chunked (drei)

This commit is contained in:
Miroslav Stampar
2020-01-27 11:32:05 +01:00
parent 4cf14c80eb
commit 8c57b9cd4c
4 changed files with 34 additions and 1 deletions

View File

@@ -193,6 +193,25 @@ class ReqHandler(BaseHTTPRequestHandler):
data = self.rfile.read(length)
data = unquote_plus(data.decode(UNICODE_ENCODING, "ignore"))
self.data = data
elif self.headers.get("Transfer-encoding") == "chunked":
data, line = b"", b""
count = 0
while True:
line += self.rfile.read(1)
if line.endswith(b'\n'):
if count % 2 == 1:
current = line.rstrip(b"\r\n")
if not current:
break
else:
data += current
count += 1
line = b""
self.data = data.decode(UNICODE_ENCODING, "ignore")
self.do_REQUEST()
def log_message(self, format, *args):