mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
fix chunked encoding.
This commit is contained in:
parent
6badf22041
commit
b6693a81aa
@ -148,17 +148,20 @@ class Parser(object):
|
||||
chunk_size = int(chunk.pop(0), 16)
|
||||
self.start_offset = i+2
|
||||
self.chunk_size = chunk_size
|
||||
if self.chunk_size == 0:
|
||||
self._chunk_eof = True
|
||||
return '', data[:self.start_offset]
|
||||
else:
|
||||
buf = data[self.start_offset:self.start_offset+self.chunk_size]
|
||||
end_offset = self.start_offset + self.chunk_size + 2
|
||||
# we wait CRLF else return None
|
||||
if len(data) >= end_offset:
|
||||
ret = buf, data[end_offset:]
|
||||
self.chunk_size = 0
|
||||
|
||||
if self.start_offset:
|
||||
if self.chunk_size == 0:
|
||||
self._chunk_eof = True
|
||||
ret = '', data[:self.start_offset]
|
||||
return ret
|
||||
else:
|
||||
buf = data[self.start_offset:self.start_offset+self.chunk_size]
|
||||
end_offset = self.start_offset + self.chunk_size + 2
|
||||
# we wait CRLF else return None
|
||||
if len(data) >= end_offset:
|
||||
ret = buf, data[end_offset:]
|
||||
self.chunk_size = 0
|
||||
return ret
|
||||
return '', data
|
||||
|
||||
def trailing_header(self, data):
|
||||
|
||||
@ -92,16 +92,7 @@ def close(sock):
|
||||
pass
|
||||
|
||||
def read_partial(sock, length):
|
||||
while True:
|
||||
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
|
||||
return sock.recv(length)
|
||||
|
||||
def write(sock, data):
|
||||
sock.sendall(data)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user