From 55f96ecc3f44ec3ec7702569078a80ced6ae2b44 Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Wed, 13 Feb 2008 11:12:58 +0100 Subject: [PATCH] chunked encoding tests: All these tests fail. --- test/cgi/chunked_bzip2.py | 61 +++++++++++++++++++-------------------------- test/cgi/chunked_deflate.py | 38 ++++++++++++---------------- test/cgi/chunked_gzip.py | 61 +++++++++++++++++++-------------------------- 3 files changed, 66 insertions(+), 94 deletions(-) rewrite test/cgi/chunked_bzip2.py (81%) rewrite test/cgi/chunked_deflate.py (92%) rewrite test/cgi/chunked_gzip.py (81%) diff --git a/test/cgi/chunked_bzip2.py b/test/cgi/chunked_bzip2.py dissimilarity index 81% index c34dc132..0c8dfb00 100755 --- a/test/cgi/chunked_bzip2.py +++ b/test/cgi/chunked_bzip2.py @@ -1,36 +1,25 @@ -#!/usr/bin/env python -import bz2, os - -data1 = 'Two lines should be visible.
' -data2 = 'The second line.' - -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") +#!/usr/bin/env python +import bz2, os, time + +data1 = 'Two lines should be visible.
The second line.' + +f1 = bz2.BZ2File("/tmp/1.bz2", mode = "wb") +f1.write(data1) +f1.close() + +f = open("/tmp/1.bz2") +cd1 = f.read() +f.close() + +os.unlink("/tmp/1.bz2") + +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: bzip2\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") diff --git a/test/cgi/chunked_deflate.py b/test/cgi/chunked_deflate.py dissimilarity index 92% index 59d7ee0b..45f06828 100755 --- a/test/cgi/chunked_deflate.py +++ b/test/cgi/chunked_deflate.py @@ -1,22 +1,16 @@ -#!/usr/bin/env python -import os, zlib - -data1 = 'Two lines should be visible.
' -data2 = 'The second line.' - -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") +#!/usr/bin/env python +import os, time, zlib + +data1 = 'Two lines should be visible.
The second line.' +cd1 = zlib.compress(data1) + +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") diff --git a/test/cgi/chunked_gzip.py b/test/cgi/chunked_gzip.py dissimilarity index 81% index 411fa99f..cd20c9f8 100755 --- a/test/cgi/chunked_gzip.py +++ b/test/cgi/chunked_gzip.py @@ -1,36 +1,25 @@ -#!/usr/bin/env python -import gzip, os - -data1 = 'Two lines should be visible.
' -data2 = 'The second line.' - -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") +#!/usr/bin/env python +import gzip, os, time + +data1 = 'Two lines should be visible.
The second line.' + +f1 = gzip.GzipFile("/tmp/1.gz", mode = "wb") +f1.write(data1) +f1.close() + +f = open("/tmp/1.gz") +cd1 = f.read() +f.close() + +os.unlink("/tmp/1.gz") + +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: gzip\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") -- 2.11.4.GIT