diff options
| author | ianb <devnull@localhost> | 2009-03-06 00:26:22 +0000 |
|---|---|---|
| committer | ianb <devnull@localhost> | 2009-03-06 00:26:22 +0000 |
| commit | 832e1603db91bf42c83c4a7351ffdc3265ffb1a0 (patch) | |
| tree | 15c3333071c9da6c1d764791630811e80c39c5f5 | |
| parent | c1cde173851d9713fb0a27f7b6683364ec861940 (diff) | |
| download | paste-832e1603db91bf42c83c4a7351ffdc3265ffb1a0.tar.gz | |
Have the proxy handle a content-length of -1
| -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 = '' |
