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):
|
||||
""" fetch partial body"""
|
||||
while True:
|
||||
self.buf = read_partial(self.socket, length, self.buf)
|
||||
|
||||
chunk, self.buf = self.parser.filter_body(self.buf)
|
||||
if chunk:
|
||||
self.tmp.write(chunk)
|
||||
@ -144,6 +142,7 @@ class TeeInput(object):
|
||||
if self.parser.body_eof():
|
||||
break
|
||||
|
||||
self.buf = read_partial(self.socket, length, self.buf)
|
||||
self._finalize()
|
||||
return ""
|
||||
|
||||
|
||||
@ -94,11 +94,13 @@ def close(sock):
|
||||
pass
|
||||
|
||||
def read_partial(sock, length, buf=None):
|
||||
tmp_buf = array.array("c", '\0' * length)
|
||||
l = sock.recv_into(tmp_buf, length)
|
||||
|
||||
if not buf:
|
||||
buf = array.array("c", '\0' * length)
|
||||
l = sock.recv_into(buf, length)
|
||||
return buf[:l]
|
||||
return buf
|
||||
return tmp_buf[:l]
|
||||
|
||||
return buf + tmp_buf[:l]
|
||||
|
||||
def write_chunk(sock, data):
|
||||
chunk = "".join(("%X\r\n" % len(data), data, "\r\n"))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user