[Twisted-Python] gzip with web
Itamar Shtull-Trauring
twisted at itamarst.org
Sun Mar 9 20:48:53 EST 2003
On 08 Mar 2003 22:11:15 +0100
William Dode <wilk-ml at flibuste.net> wrote:
> encoding = request.getHeader("accept-encoding")
> if encoding and encoding.find("gzip")>=0:
> import cStringIO,gzip
> zbuf = cStringIO.StringIO()
> zfile = gzip.GzipFile(None, 'wb', 9, zbuf)
> zfile.write(content)
> zfile.close()
> request.setHeader("Content-encoding","gzip")
> return zbuf.getvalue()
> else:
> return content
I think ideally you'd want this to be in twisted.protocols.http, and
deal with write()s and so on instead of assuming it's all one string.
I'd be happy to accept a patch!
More information about the Twisted-Python
mailing list