mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
should fix _ensure_length in tee. while I'm here fix chunked response.
This commit is contained in:
parent
29fd1cf48f
commit
c2f12a4977
@ -37,13 +37,12 @@ class Parser(object):
|
|||||||
with new headers.
|
with new headers.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
ld = len("\r\n\r\n")
|
|
||||||
s = "".join(buf)
|
s = "".join(buf)
|
||||||
i = s.find("\r\n\r\n")
|
i = s.find("\r\n\r\n")
|
||||||
if i != -1:
|
if i != -1:
|
||||||
if i > 0:
|
if i > 0:
|
||||||
r = s[:i]
|
r = s[:i]
|
||||||
pos = i+ld
|
pos = i+4
|
||||||
return self.finalize_headers(headers, r, pos)
|
return self.finalize_headers(headers, r, pos)
|
||||||
return -1
|
return -1
|
||||||
|
|
||||||
@ -119,8 +118,7 @@ class Parser(object):
|
|||||||
@property
|
@property
|
||||||
def is_chunked(self):
|
def is_chunked(self):
|
||||||
""" is TE: chunked ?"""
|
""" is TE: chunked ?"""
|
||||||
transfert_encoding = self.headers_dict.get('Transfer-Encoding', False)
|
return (self.headers_dict.get('Transfer-Encoding') == "chunked")
|
||||||
return (transfert_encoding == "chunked")
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def content_len(self):
|
def content_len(self):
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
# This file is part of gunicorn released under the MIT license.
|
# This file is part of gunicorn released under the MIT license.
|
||||||
# See the NOTICE for more information.
|
# See the NOTICE for more information.
|
||||||
|
|
||||||
from gunicorn.util import http_date, write, close
|
from gunicorn.util import close, http_date, write, write_chunk
|
||||||
|
|
||||||
class Response(object):
|
class Response(object):
|
||||||
|
|
||||||
|
|||||||
@ -155,7 +155,9 @@ class TeeInput(object):
|
|||||||
def _ensure_length(self, buf, length):
|
def _ensure_length(self, buf, length):
|
||||||
if not buf or not self._len:
|
if not buf or not self._len:
|
||||||
return buf
|
return buf
|
||||||
while len(buf) < length and self.len != self.tmp.tell():
|
while True:
|
||||||
|
if len(buf) >= length:
|
||||||
|
break
|
||||||
data = self._tee(length - len(buf))
|
data = self._tee(length - len(buf))
|
||||||
if not data: break
|
if not data: break
|
||||||
buf += data
|
buf += data
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user