From 2845897ec52e4422f28b83e1bab7122209d620ca Mon Sep 17 00:00:00 2001 From: ianb Date: Thu, 11 Oct 2007 16:41:20 +0000 Subject: Content-Length: -1 means we should read indefinitely, not count down to zero (which would of course be fatal) --- paste/cascade.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'paste/cascade.py') diff --git a/paste/cascade.py b/paste/cascade.py index 962da31..d939e4a 100644 --- a/paste/cascade.py +++ b/paste/cascade.py @@ -80,13 +80,16 @@ class Cascade(object): if length > 0: # We have to copy wsgi.input copy_wsgi_input = True - if length > 4096 or length == -1: + if length > 4096 or length < 0: f = tempfile.TemporaryFile() - copy_len = length - while copy_len: - chunk = environ['wsgi.input'].read(min(copy_len, 4096)) - f.write(chunk) - copy_len -= len(chunk) + if length < 0: + f.write(environ['wsgi.input'].read()) + else: + copy_len = length + while copy_len > 0: + chunk = environ['wsgi.input'].read(min(copy_len, 4096)) + f.write(chunk) + copy_len -= len(chunk) f.seek(0) else: f = StringIO(environ['wsgi.input'].read(length)) -- cgit v1.2.1