Removed code using pipes for decompression and simplified decompress_data.
[elinks.git] / test / cgi / chunked_gzip.py
blobe01f6070c66ec07580968b96070d48791135c521
1 #!/usr/bin/env python
2 import gzip, os, time, StringIO
4 output = StringIO.StringIO()
6 data1 = '<html><body>Two lines should be visible.<br/>The second line.</body></html>'
8 f1 = gzip.GzipFile("/tmp/1.gz", mode = "wb", fileobj=output)
9 f1.write(data1)
10 f1.close()
12 cd1 = output.getvalue()
13 output.close()
15 length = len(cd1)
16 next_chunk = hex(length - 10)[2:]
18 os.write(1, "Date: Sun, 20 Jan 2008 15:24:00 GMT\r\nServer: ddd\r\nTransfer-Encoding: chunked\r\nContent-Encoding: gzip\r\nConnection: close\r\nContent-Type: text/html; charset=ISO-8859-1\r\n")
19 os.write(1, "\r\na\r\n")
20 os.write(1, cd1[:10])
21 time.sleep(2)
22 os.write(1, "\r\n%s\r\n" % next_chunk)
23 os.write(1, cd1[10:])
24 os.write(1, "\r\n0\r\n")