summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Brewer <fumanchu@aminus.org>2006-12-11 20:36:16 +0000
committerRobert Brewer <fumanchu@aminus.org>2006-12-11 20:36:16 +0000
commit7a9877d371052e5faa02eba207e86ed14b0575f0 (patch)
tree0733b68e7a00bb011621564a166dd63f3fd34d82
parent8ea7bfde21cc3f80b52801dd8fc36c4e2fc10611 (diff)
downloadcherrypy-7a9877d371052e5faa02eba207e86ed14b0575f0.tar.gz
2.x backport of [1402]; fix for #577 (GzipFilter doesn't force an update of the Content-Length header)). Also fixes #617.
-rw-r--r--cherrypy/filters/encodingfilter.py2
-rw-r--r--cherrypy/filters/gzipfilter.py2
-rw-r--r--cherrypy/filters/logdebuginfofilter.py2
-rw-r--r--cherrypy/filters/nsgmlsfilter.py2
-rw-r--r--cherrypy/filters/sessionauthenticatefilter.py4
-rw-r--r--cherrypy/filters/tidyfilter.py6
6 files changed, 18 insertions, 0 deletions
diff --git a/cherrypy/filters/encodingfilter.py b/cherrypy/filters/encodingfilter.py
index c82ff8ca..05596e23 100644
--- a/cherrypy/filters/encodingfilter.py
+++ b/cherrypy/filters/encodingfilter.py
@@ -42,6 +42,8 @@ def encode_string(encoding, errors='strict'):
chunk = chunk.encode(encoding, errors)
body.append(chunk)
cherrypy.response.body = body
+ # Delete Content-Length header so finalize() recalcs it.
+ cherrypy.response.headers.pop("Content-Length", None)
except (LookupError, UnicodeError):
return False
else:
diff --git a/cherrypy/filters/gzipfilter.py b/cherrypy/filters/gzipfilter.py
index 94bc56fb..4bad813f 100644
--- a/cherrypy/filters/gzipfilter.py
+++ b/cherrypy/filters/gzipfilter.py
@@ -28,6 +28,8 @@ class GzipFilter(BaseFilter):
response.headers['Content-Encoding'] = 'gzip'
level = cherrypy.config.get('gzip_filter.compresslevel', 9)
response.body = self.zip_body(response.body, level)
+ # Delete Content-Length header so finalize() recalcs it.
+ response.headers.pop("Content-Length", None)
acceptable = cherrypy.request.headers.elements('Accept-Encoding')
if not acceptable:
diff --git a/cherrypy/filters/logdebuginfofilter.py b/cherrypy/filters/logdebuginfofilter.py
index 01cc4081..fd7ddce5 100644
--- a/cherrypy/filters/logdebuginfofilter.py
+++ b/cherrypy/filters/logdebuginfofilter.py
@@ -57,3 +57,5 @@ class LogDebugInfoFilter(BaseFilter):
debuginfo += '-->'
cherrypy.response.body = [body, debuginfo]
+ # Delete Content-Length header so finalize() recalcs it.
+ cherrypy.response.headers.pop("Content-Length", None)
diff --git a/cherrypy/filters/nsgmlsfilter.py b/cherrypy/filters/nsgmlsfilter.py
index 89ef11f8..0cb9210e 100644
--- a/cherrypy/filters/nsgmlsfilter.py
+++ b/cherrypy/filters/nsgmlsfilter.py
@@ -69,4 +69,6 @@ class NsgmlsFilter(BaseFilter):
new_body += "%03d - "%i + cgi.escape(line).replace('\t',' ').replace(' ','&nbsp;') + '<br />'
cherrypy.response.body = new_body
+ # Delete Content-Length header so finalize() recalcs it.
+ cherrypy.response.headers.pop("Content-Length", None)
diff --git a/cherrypy/filters/sessionauthenticatefilter.py b/cherrypy/filters/sessionauthenticatefilter.py
index 63d14141..ba0914bf 100644
--- a/cherrypy/filters/sessionauthenticatefilter.py
+++ b/cherrypy/filters/sessionauthenticatefilter.py
@@ -60,6 +60,8 @@ class SessionAuthenticateFilter(BaseFilter):
error_msg = check_login_and_password(login, password)
if error_msg:
cherrypy.response.body = login_screen(from_page, login = login, error_msg = error_msg)
+ # Delete Content-Length header so finalize() recalcs it.
+ cherrypy.response.headers.pop("Content-Length", None)
cherrypy.request.execute_main = False
else:
cherrypy.session[session_key] = login
@@ -78,6 +80,8 @@ class SessionAuthenticateFilter(BaseFilter):
temp_user = not_logged_in()
if (not cherrypy.session.get(session_key)) and not temp_user:
cherrypy.response.body = login_screen(cherrypy.request.browser_url)
+ # Delete Content-Length header so finalize() recalcs it.
+ cherrypy.response.headers.pop("Content-Length", None)
cherrypy.request.execute_main = False
return
diff --git a/cherrypy/filters/tidyfilter.py b/cherrypy/filters/tidyfilter.py
index f21cfda4..ffedf701 100644
--- a/cherrypy/filters/tidyfilter.py
+++ b/cherrypy/filters/tidyfilter.py
@@ -73,6 +73,8 @@ class TidyFilter(BaseFilter):
newBody += "%03d - "%i + cgi.escape(line).replace('\t',' ').replace(' ','&nbsp;') + '<br />'
cherrypy.response.body = newBody
+ # Delete Content-Length header so finalize() recalcs it.
+ cherrypy.response.headers.pop("Content-Length", None)
elif strictXml:
# The HTML is OK, but is it valid XML
@@ -93,6 +95,8 @@ class TidyFilter(BaseFilter):
bodyFile = StringIO.StringIO()
traceback.print_exc(file = bodyFile)
cherrypy.response.body = bodyFile.getvalue()
+ # Delete Content-Length header so finalize() recalcs it.
+ cherrypy.response.headers.pop("Content-Length", None)
newBody = "Wrong XML:<br />" + cgi.escape(bodyFile.getvalue().replace('\n','<br />'))
newBody += '<br /><br />'
@@ -102,4 +106,6 @@ class TidyFilter(BaseFilter):
newBody += "%03d - "%i + cgi.escape(line).replace('\t',' ').replace(' ','&nbsp;') + '<br />'
cherrypy.response.body = newBody
+ # Delete Content-Length header so finalize() recalcs it.
+ cherrypy.response.headers.pop("Content-Length", None)