1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-07-07 13:34:34 -04:00
elinks/test/cgi/chunked_deflate.py
Witold Filipczyk ac48b3e4e6 test: raw deflate
(cherry picked from commit c48dc625e3)
2008-03-01 15:27:04 +02:00

19 lines
646 B
Python
Executable File

#!/usr/bin/env python
import os, time
from zlib import *
data1 = '<html><body>Two lines should be visible.<br/>The second line.</body></html>'
ob = compressobj(Z_DEFAULT_COMPRESSION, DEFLATED, -MAX_WBITS)
cd1 = ob.compress(data1)
cd1 += ob.flush()
length = len(cd1)
next_chunk = hex(length - 10)[2:]
os.write(1, "Date: Sun, 20 Jan 2008 15:24:00 GMT\r\nServer: ddd\r\nTransfer-Encoding: chunked\r\nContent-Encoding: deflate\r\nConnection: close\r\nContent-Type: text/html; charset=ISO-8859-1\r\n")
os.write(1, "\r\na\r\n")
os.write(1, cd1[:10])
time.sleep(2)
os.write(1, "\r\n%s\r\n" % next_chunk)
os.write(1, cd1[10:])
os.write(1, "\r\n0\r\n")