1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

Three CGI tests for content-encoding.

The output should be:
Two lines should be visible.
The second line.

All three tests fail currently when the ELinks is invoked like this:
$ elinks -no-connect path_to_chunked_test
This commit is contained in:
Witold Filipczyk 2008-01-21 14:44:10 +01:00 committed by Witold Filipczyk
parent 11821ecb0b
commit d14740af2e
3 changed files with 94 additions and 0 deletions

36
test/cgi/chunked_bzip2.py Executable file
View File

@ -0,0 +1,36 @@
#!/usr/bin/env python
import bz2, os
data1 = '<html><body>Two lines should be visible.<br/>'
data2 = 'The second line.</body></html>'
f1 = bz2.BZ2File("/tmp/1.bz2", mode = "wb")
f1.write(data1)
f1.close()
f2 = bz2.BZ2File("/tmp/2.bz2", mode = "wb")
f2.write(data2)
f2.close()
f = open("/tmp/1.bz2")
cd1 = f.read()
f.close()
f3 = open("/tmp/2.bz2")
cd2 = f3.read()
f3.close()
os.unlink("/tmp/1.bz2")
os.unlink("/tmp/2.bz2")
calosc = cd1 + cd2
length = len(calosc)
how_many = 40
len1 = hex(how_many)[2:]
len2 = hex(length - how_many)[2:]
os.write(1, "HTTP/1.0 200 OK\r\nDate: Sun, 20 Jan 2008 15:24:00 GMT\r\nServer: ddd\r\nTransfer-Encoding: chunked\r\nContent-Encoding: bzip2\r\nConnection: close\r\nContent-Type: text/html; charset=ISO-8859-1\r\n\r\n")
os.write(1, "%s\r\n" % len1)
os.write(1, calosc[:how_many])
os.write(1, "\r\n%s\r\n" % len2)
os.write(1, calosc[how_many:])
os.write(1, "\r\n0\r\n\r\n")

22
test/cgi/chunked_deflate.py Executable file
View File

@ -0,0 +1,22 @@
#!/usr/bin/env python
import os, zlib
data1 = '<html><body>Two lines should be visible.<br/>'
data2 = 'The second line.</body></html>'
cd1 = zlib.compress(data1)
cd2 = zlib.compress(data2)
calosc = cd1 + cd2
length = len(calosc)
how_many = 40
len1 = hex(how_many)[2:]
len2 = hex(length - how_many)[2:]
os.write(1, "HTTP/1.0 200 OK\r\nDate: 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\r\n")
os.write(1, "%s\r\n" % len1)
os.write(1, calosc[:how_many])
os.write(1, "\r\n%s\r\n" % len2)
os.write(1, calosc[how_many:])
os.write(1, "\r\n0\r\n\r\n")

36
test/cgi/chunked_gzip.py Executable file
View File

@ -0,0 +1,36 @@
#!/usr/bin/env python
import gzip, os
data1 = '<html><body>Two lines should be visible.<br/>'
data2 = 'The second line.</body></html>'
f1 = gzip.GzipFile("/tmp/1.gz", mode = "wb")
f1.write(data1)
f1.close()
f2 = gzip.GzipFile("/tmp/2.gz", mode = "wb")
f2.write(data2)
f2.close()
f = open("/tmp/1.gz")
cd1 = f.read()
f.close()
f3 = open("/tmp/2.gz")
cd2 = f3.read()
f3.close()
os.unlink("/tmp/1.gz")
os.unlink("/tmp/2.gz")
calosc = cd1 + cd2
length = len(calosc)
how_many = 40
len1 = hex(how_many)[2:]
len2 = hex(length - how_many)[2:]
os.write(1, "HTTP/1.0 200 OK\r\nDate: 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\r\n")
os.write(1, "%s\r\n" % len1)
os.write(1, calosc[:how_many])
os.write(1, "\r\n%s\r\n" % len2)
os.write(1, calosc[how_many:])
os.write(1, "\r\n0\r\n\r\n")