testing/web-platform/tests/resource-timing/resources/gzip_xml.py
author Wes Kocher <wkocher@mozilla.com>
Wed, 15 Feb 2017 12:07:18 -0800
changeset 343121 fe960e54cc30c906643e94b2ff0a64cb51df74c6
parent 343119 c3a4bae5fc8db328f9f8559a65b28c235743bc10
child 376197 cae85787a705b8f5b839796b594169b63eff8157
permissions -rw-r--r--
Backed out 2 changesets (bug 919391) for failing test_resource_timing.html tests a=backout Backed out changeset c3a4bae5fc8d (bug 919391) Backed out changeset e776663ecbb4 (bug 919391) MozReview-Commit-ID: GwUBLZbKe6r

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