should fix _ensure_length in tee. while I'm here fix chunked response.

This commit is contained in:
benoitc 2010-02-28 21:10:32 +01:00
parent 29fd1cf48f
commit c2f12a4977
3 changed files with 6 additions and 6 deletions

View File

@ -37,13 +37,12 @@ class Parser(object):
with new headers.
"""
ld = len("\r\n\r\n")
s = "".join(buf)
i = s.find("\r\n\r\n")
if i != -1:
if i > 0:
r = s[:i]
pos = i+ld
pos = i+4
return self.finalize_headers(headers, r, pos)
return -1
@ -119,8 +118,7 @@ class Parser(object):
@property
def is_chunked(self):
""" is TE: chunked ?"""
transfert_encoding = self.headers_dict.get('Transfer-Encoding', False)
return (transfert_encoding == "chunked")
return (self.headers_dict.get('Transfer-Encoding') == "chunked")
@property
def content_len(self):

View File

@ -3,7 +3,7 @@
# This file is part of gunicorn released under the MIT license.
# 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):

View File

@ -155,7 +155,9 @@ class TeeInput(object):
def _ensure_length(self, buf, length):
if not buf or not self._len:
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))
if not data: break
buf += data