summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/resource-timing/resources/gzip_xml.py
blob: 3346da6c969c5397a410ae342205e06a5196f87c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import gzip as gzip_module
from cStringIO import StringIO

def main(request, response):
    f = open('resource-timing/resources/resource_timing_test0.xml', '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