Removed code using pipes for decompression and simplified decompress_data.
[elinks.git] / test / cgi / chunked_raw_deflate.py
blob6a762636a82e00c23e2b0894887c74788778179e
1 #!/usr/bin/env python
2 import os, time
3 from zlib import *
5 # According to section 3.5 of RFC 2616, "Content-Encoding: deflate"
6 # requires a ZLIB header. However, Microsoft-IIS/6.0 sends a raw
7 # DEFLATE stream instead. This CGI tests how ELinks handles that.
9 data1 = '<html><body>Two lines should be visible.<br/>The second line.</body></html>'
10 ob = compressobj(Z_DEFAULT_COMPRESSION, DEFLATED, -MAX_WBITS)
11 cd1 = ob.compress(data1)
12 cd1 += ob.flush()
13 length = len(cd1)
14 next_chunk = hex(length - 10)[2:]
16 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")
17 os.write(1, "\r\na\r\n")
18 os.write(1, cd1[:10])
19 time.sleep(2)
20 os.write(1, "\r\n%s\r\n" % next_chunk)
21 os.write(1, cd1[10:])
22 os.write(1, "\r\n0\r\n")