Commit c2ea04ac authored by Denis Bilenko's avatar Denis Bilenko

pywsgi: fix TypeError in environ['wsgi.input'].read(<number>)

parent 1207d69e
...@@ -63,11 +63,17 @@ class Input(object): ...@@ -63,11 +63,17 @@ class Input(object):
self.sendall = None self.sendall = None
def _do_read(self, reader, length=None): def _do_read(self, reader, length=None):
content_length = self.content_length
if content_length is None:
# Either Content-Length or "Transfer-Encoding: chunked" must be present in a request with a body
# if it was chunked, then this function would have not been called
return ''
self._send_100_continue() self._send_100_continue()
if length is None and self.content_length is not None: left = content_length - self.position
length = self.content_length - self.position if length is None:
if length and length > self.content_length - self.position: length = left
length = self.content_length - self.position elif length > left:
length = left
if not length: if not length:
return '' return ''
read = reader(length) read = reader(length)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment