diff options
-rw-r--r-- | docs/news.txt | 2 | ||||
-rw-r--r-- | paste/proxy.py | 11 |
2 files changed, 10 insertions, 3 deletions
diff --git a/docs/news.txt b/docs/news.txt index 67f85dc..7561617 100644 --- a/docs/news.txt +++ b/docs/news.txt @@ -22,6 +22,8 @@ svn trunk don't always aggressively set cookies without the ``wildcard_cookie`` option. Also on logout, make cookies expire. +* In :class:`paste.proxy.Proxy` handle Content-Length of -1. + 1.7.2 ----- diff --git a/paste/proxy.py b/paste/proxy.py index 7de18c7..cb29c54 100644 --- a/paste/proxy.py +++ b/paste/proxy.py @@ -90,9 +90,14 @@ class Proxy(object): if environ.get('CONTENT_TYPE'): headers['content-type'] = environ['CONTENT_TYPE'] if environ.get('CONTENT_LENGTH'): - headers['content-length'] = environ['CONTENT_LENGTH'] - length = int(environ['CONTENT_LENGTH']) - body = environ['wsgi.input'].read(length) + if environ['CONTENT_LENGTH'] == '-1': + # This is a special case, where the content length is basically undetermined + body = environ['wsgi.input'].read(-1) + headers['content-length'] = str(len(body)) + else: + headers['content-length'] = environ['CONTENT_LENGTH'] + length = int(environ['CONTENT_LENGTH']) + body = environ['wsgi.input'].read(length) else: body = '' |