diff options
author | Robert Brewer <fumanchu@aminus.org> | 2006-09-02 18:39:10 +0000 |
---|---|---|
committer | Robert Brewer <fumanchu@aminus.org> | 2006-09-02 18:39:10 +0000 |
commit | 56304d2938ed9b08513c8942c92f34da9aa89e33 (patch) | |
tree | 906f758012fda647f2c6962edc848529b0101036 /cherrypy/lib/cptools.py | |
parent | 2e904a25d13b861cd38768134b1f6d7331e38645 (diff) | |
download | cherrypy-git-56304d2938ed9b08513c8942c92f34da9aa89e33.tar.gz |
Fix for #535 (Apache re-processes Range headers). _cpmodpy now uses a new "ignore_headers(['Range'])" Tool by default.
Diffstat (limited to 'cherrypy/lib/cptools.py')
-rw-r--r-- | cherrypy/lib/cptools.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/cherrypy/lib/cptools.py b/cherrypy/lib/cptools.py index 43c010c7..f3f374ea 100644 --- a/cherrypy/lib/cptools.py +++ b/cherrypy/lib/cptools.py @@ -122,6 +122,19 @@ def proxy(base=None, local='X-Forwarded-Host', remote='X-Forwarded-For'): request.remote.ip = xff +def ignore_headers(headers=('Range',)): + """Delete request headers whose field names are included in 'headers'. + + This is a useful tool for working behind certain HTTP servers; + for example, Apache duplicates the work that CP does for 'Range' + headers, and will doubly-truncate the response. + """ + request = cherrypy.request + for name in headers: + if name in request.headers: + del request.headers[name] + + def response_headers(headers=None): """Set headers on the response.""" for name, value in (headers or []): |