mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
fix chunked encoding. It's ok now but we need unitests
This commit is contained in:
parent
19a4a081a2
commit
49c02c8c4c
@ -132,8 +132,6 @@ class TeeInput(object):
|
|||||||
def _tee(self, length):
|
def _tee(self, length):
|
||||||
""" fetch partial body"""
|
""" fetch partial body"""
|
||||||
while True:
|
while True:
|
||||||
self.buf = read_partial(self.socket, length, self.buf)
|
|
||||||
|
|
||||||
chunk, self.buf = self.parser.filter_body(self.buf)
|
chunk, self.buf = self.parser.filter_body(self.buf)
|
||||||
if chunk:
|
if chunk:
|
||||||
self.tmp.write(chunk)
|
self.tmp.write(chunk)
|
||||||
@ -144,6 +142,7 @@ class TeeInput(object):
|
|||||||
if self.parser.body_eof():
|
if self.parser.body_eof():
|
||||||
break
|
break
|
||||||
|
|
||||||
|
self.buf = read_partial(self.socket, length, self.buf)
|
||||||
self._finalize()
|
self._finalize()
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
|||||||
@ -94,11 +94,13 @@ def close(sock):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def read_partial(sock, length, buf=None):
|
def read_partial(sock, length, buf=None):
|
||||||
|
tmp_buf = array.array("c", '\0' * length)
|
||||||
|
l = sock.recv_into(tmp_buf, length)
|
||||||
|
|
||||||
if not buf:
|
if not buf:
|
||||||
buf = array.array("c", '\0' * length)
|
return tmp_buf[:l]
|
||||||
l = sock.recv_into(buf, length)
|
|
||||||
return buf[:l]
|
return buf + tmp_buf[:l]
|
||||||
return buf
|
|
||||||
|
|
||||||
def write_chunk(sock, data):
|
def write_chunk(sock, data):
|
||||||
chunk = "".join(("%X\r\n" % len(data), data, "\r\n"))
|
chunk = "".join(("%X\r\n" % len(data), data, "\r\n"))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user