2020-01-01 10:07:14 -05:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
import gzip, os, time, six
|
2008-02-14 04:39:56 -05:00
|
|
|
|
2020-01-01 10:07:14 -05:00
|
|
|
output = six.BytesIO()
|
2008-01-21 08:44:10 -05:00
|
|
|
|
2020-01-01 10:07:14 -05:00
|
|
|
data1 = b'<html><body>Two lines should be visible.<br/>The second line.</body></html>'
|
2008-01-21 08:44:10 -05:00
|
|
|
|
2008-02-14 04:39:56 -05:00
|
|
|
f1 = gzip.GzipFile("/tmp/1.gz", mode = "wb", fileobj=output)
|
2008-01-21 08:44:10 -05:00
|
|
|
f1.write(data1)
|
|
|
|
f1.close()
|
|
|
|
|
2008-02-14 04:39:56 -05:00
|
|
|
cd1 = output.getvalue()
|
|
|
|
output.close()
|
2008-01-21 08:44:10 -05:00
|
|
|
|
2008-02-13 05:12:58 -05:00
|
|
|
length = len(cd1)
|
|
|
|
next_chunk = hex(length - 10)[2:]
|
2008-01-21 08:44:10 -05:00
|
|
|
|
2020-01-01 10:07:14 -05:00
|
|
|
os.write(1, b"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")
|
|
|
|
os.write(1, b"\r\na\r\n")
|
2008-02-13 05:12:58 -05:00
|
|
|
os.write(1, cd1[:10])
|
|
|
|
time.sleep(2)
|
2020-01-01 10:07:14 -05:00
|
|
|
os.write(1, b"\r\n")
|
|
|
|
os.write(1, bytes(next_chunk, 'iso8859-1'))
|
|
|
|
os.write(1, b"\r\n")
|
2008-02-13 05:12:58 -05:00
|
|
|
os.write(1, cd1[10:])
|
2020-01-01 10:07:14 -05:00
|
|
|
os.write(1, b"\r\n0\r\n")
|