CGI que devuelve contenido comprimido.
Chema Cortés
py en ch3m4.org
Jue Dic 2 10:13:14 CET 2004
Como el código tenía algunos fallos, lo reenvío corregido:
import os,gzip,cStringIO
def compressBuf(s):
zbuf=cStringIO.StringIO()
zfile=gzip.GzipFile(mode='wb', fileobj=zbuf, compresslevel=9)
zfile.write(s)
zfile.close()
return zbuf.getvalue()
body=make_the_body()
if not "gzip" in os.environ["HTTP_ACCEPT_ENCODING"]:
print "Content-Type: text/html"
print
print body
else:
print "Content-Type: text/html"
print "Content-Encoding: gzip"
print "Content-Length: %d"%len(body)
print
print compressBuf(body),
------------ próxima parte ------------
A non-text attachment was scrubbed...
Name: no disponible
Type: application/pgp-signature
Size: 189 bytes
Desc: no disponible
URL: <http://mail.python.org/pipermail/python-es/attachments/20041202/ad2f9628/attachment.pgp>
------------ próxima parte ------------
_______________________________________________
Python-es mailing list
Python-es en aditel.org
http://listas.aditel.org/listinfo/python-es
Más información sobre la lista de distribución Python-es