fix chunked encoding.

This commit is contained in:
benoitc 2010-02-26 04:56:46 +01:00
parent 6badf22041
commit b6693a81aa
2 changed files with 14 additions and 20 deletions

View File

@ -148,9 +148,12 @@ class Parser(object):
chunk_size = int(chunk.pop(0), 16) chunk_size = int(chunk.pop(0), 16)
self.start_offset = i+2 self.start_offset = i+2
self.chunk_size = chunk_size self.chunk_size = chunk_size
if self.start_offset:
if self.chunk_size == 0: if self.chunk_size == 0:
self._chunk_eof = True self._chunk_eof = True
return '', data[:self.start_offset] ret = '', data[:self.start_offset]
return ret
else: else:
buf = data[self.start_offset:self.start_offset+self.chunk_size] buf = data[self.start_offset:self.start_offset+self.chunk_size]
end_offset = self.start_offset + self.chunk_size + 2 end_offset = self.start_offset + self.chunk_size + 2

View File

@ -92,16 +92,7 @@ def close(sock):
pass pass
def read_partial(sock, length): def read_partial(sock, length):
while True: return sock.recv(length)
try:
ret = select.select([sock.fileno()], [], [], 0)
if ret[0]: break
except select.error, e:
if e[0] == errno.EINTR:
continue
raise
data = sock.recv(length)
return data
def write(sock, data): def write(sock, data):
sock.sendall(data) sock.sendall(data)