Skip to content

Commit 586b8c3

Browse files
author
Pierre Quentel
committed
Add HTTP compression test for big files
1 parent 128f6a6 commit 586b8c3

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

Lib/test/test_httpservers.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,14 @@ def setUp(self):
576576
with open(path, 'wb') as temp:
577577
temp.write(self.data)
578578

579+
# create big files, size > 2 << 18
580+
self.repeat = (2 << 19) // len(self.data)
581+
for ext in self.compressible_ext:
582+
path = os.path.join(self.tempdir, 'test_big.{}'.format(ext))
583+
with open(path, 'wb') as temp:
584+
for _ in range(self.repeat):
585+
temp.write(self.data)
586+
579587
def tearDown(self):
580588
try:
581589
os.chdir(self.cwd)
@@ -622,7 +630,14 @@ def test_header_set_supported_extension(self):
622630
headers={'Accept-Encoding': 'gzip'})
623631
self.assertTrue('Content-Encoding' in response.headers)
624632
self.assertEqual(gzip.decompress(response.read()), self.data)
625-
633+
634+
# same for big files
635+
for ext in self.compressible_ext:
636+
response = self.request(self.base_url + '/test_big.{}'.format(ext),
637+
headers={'Accept-Encoding': 'gzip'})
638+
self.assertTrue('Content-Encoding' in response.headers)
639+
self.assertEqual(gzip.decompress(response.read()),
640+
self.repeat * self.data)
626641

627642
cgi_file1 = """\
628643
#!%s

0 commit comments

Comments
 (0)