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)
|
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.chunk_size == 0:
|
|
||||||
self._chunk_eof = True
|
if self.start_offset:
|
||||||
return '', data[:self.start_offset]
|
if self.chunk_size == 0:
|
||||||
else:
|
self._chunk_eof = True
|
||||||
buf = data[self.start_offset:self.start_offset+self.chunk_size]
|
ret = '', data[:self.start_offset]
|
||||||
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 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
|
return '', data
|
||||||
|
|
||||||
def trailing_header(self, data):
|
def trailing_header(self, data):
|
||||||
|
|||||||
@ -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)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user