diff options
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 []): |