fix chunked encoding. It's ok now but we need unitests

This commit is contained in:
benoitc 2010-03-01 01:03:24 +01:00
parent 19a4a081a2
commit 49c02c8c4c
2 changed files with 7 additions and 6 deletions

View File

@ -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 ""

View File

@ -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"))