resource-timing-scope.py (679B)
1 import zlib 2 3 def main(request, response): 4 type = request.GET.first(b"type") 5 6 if type == "normal": 7 content = b"This is Navigation Preload Resource Timing test." 8 output = zlib.compress(content, 9) 9 headers = [(b"Content-type", b"text/plain"), 10 (b"Content-Encoding", b"deflate"), 11 (b"X-Decoded-Body-Size", len(content)), 12 (b"X-Encoded-Body-Size", len(output)), 13 (b"Content-Length", len(output))] 14 return headers, output 15 16 if type == b"redirect": 17 response.status = 302 18 response.headers.append(b"Location", b"redirect-redirected.html") 19 return b""