]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Don't keep the entire output in a cStringIO when gzipping chunks
authorBen Darnell <ben@bendarnell.com>
Wed, 6 Jul 2011 06:53:38 +0000 (23:53 -0700)
committerBen Darnell <ben@bendarnell.com>
Wed, 6 Jul 2011 06:53:38 +0000 (23:53 -0700)
tornado/web.py

index 497d7e9f56f8584550297caeb8e44e05a8174f55..b656178ea4d09c21927d4e9cfdc0a537a4f4b3d1 100644 (file)
@@ -1562,7 +1562,6 @@ class GZipContentEncoding(OutputTransform):
             headers["Content-Encoding"] = "gzip"
             self._gzip_value = BytesIO()
             self._gzip_file = gzip.GzipFile(mode="w", fileobj=self._gzip_value)
-            self._gzip_pos = 0
             chunk = self.transform_chunk(chunk, finishing)
             if "Content-Length" in headers:
                 headers["Content-Length"] = str(len(chunk))
@@ -1576,9 +1575,8 @@ class GZipContentEncoding(OutputTransform):
             else:
                 self._gzip_file.flush()
             chunk = self._gzip_value.getvalue()
-            if self._gzip_pos > 0:
-                chunk = chunk[self._gzip_pos:]
-            self._gzip_pos += len(chunk)
+            self._gzip_value.truncate(0)
+            self._gzip_value.seek(0)
         return chunk