From: Ben Darnell Date: Wed, 6 Jul 2011 06:53:38 +0000 (-0700) Subject: Don't keep the entire output in a cStringIO when gzipping chunks X-Git-Tag: v2.1.0~105 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=30c1f269c10222d6d1952f225e34322cd1f9f143;p=thirdparty%2Ftornado.git Don't keep the entire output in a cStringIO when gzipping chunks --- diff --git a/tornado/web.py b/tornado/web.py index 497d7e9f5..b656178ea 100644 --- a/tornado/web.py +++ b/tornado/web.py @@ -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