Files
firefox/testing/web-platform/tests/resource-timing/resources/gzip_xml.py
T
Valentin Gosu 58b06d50a7 Bug 1392260 - Fix error in gzip_xml.py r=jgraham
Reviewed by jgraham in bug 919391 comment 9

MozReview-Commit-ID: 8db0q7QCJRT
2017-08-22 22:31:39 +02:00

21 lines
576 B
Python

import gzip as gzip_module
from cStringIO import StringIO
import os
def main(request, response):
dir_path = os.path.dirname(os.path.realpath(__file__))
file_path = os.path.join(dir_path, 'resource_timing_test0.xml')
f = open(file_path, 'r')
output = f.read()
out = StringIO()
with gzip_module.GzipFile(fileobj=out, mode="w") as f:
f.write(output)
output = out.getvalue()
headers = [("Content-type", "text/plain"),
("Content-Encoding", "gzip"),
("Content-Length", len(output))]
return headers, output