summaryrefslogtreecommitdiff
path: root/paste/gzipper.py
diff options
context:
space:
mode:
authorianb <devnull@localhost>2006-11-12 19:00:54 +0000
committerianb <devnull@localhost>2006-11-12 19:00:54 +0000
commit4b5acac85beb579b20baef393762525913e88ba9 (patch)
treebbefd7d61f2684642d53a22ec7b2aec2e0905949 /paste/gzipper.py
parent2eb140361265ca568b504613d134f4684eb48817 (diff)
downloadpaste-4b5acac85beb579b20baef393762525913e88ba9.tar.gz
Fix for Content-Length in gzip response from Brad Clements. Also gzip test
Diffstat (limited to 'paste/gzipper.py')
-rw-r--r--paste/gzipper.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/paste/gzipper.py b/paste/gzipper.py
index 5ec2efe..48165fe 100644
--- a/paste/gzipper.py
+++ b/paste/gzipper.py
@@ -12,6 +12,7 @@ Gzip-encodes the response.
import gzip
from paste.response import header_value
+from paste.httpheaders import CONTENT_LENGTH
try:
from cStringIO import StringIO
@@ -47,8 +48,10 @@ class GzipResponse(object):
self.compress_level = compress_level
self.buffer = StringIO()
self.compressible = False
+ self.headers = None
def gzip_start_response(self, status, headers, exc_info=None):
+ self.headers = headers
ct = header_value(headers,'content-type')
ce = header_value(headers,'content-encoding')
self.compressible = False
@@ -66,6 +69,8 @@ class GzipResponse(object):
out.seek(0)
s = out.getvalue()
out.close()
+ if self.compressible and self.headers is not None:
+ CONTENT_LENGTH.update(self.headers, str(len(s)))
return [s]
def finish_response(self, app_iter):