summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/resource-timing/resources/header-delay.h2.py
blob: 27b6fd5bfbb70445454ed7ec0735b662b4c15091 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from time import sleep

def handle_headers(frame, request, response):
    delay = int(request.GET.first(b"delay")) / 1000

    if b"with100" in request.GET:
        sleep(delay)
        response.writer.write_raw_header_frame(headers=[(b":status", b"103")], end_headers=True)

    if b"with103" in request.GET:
        sleep(delay)
        response.writer.write_raw_header_frame(headers=[(b":status", b"103")], end_headers=True)

    sleep(delay)
    response.status = 200

    if b"tao" in request.GET:
        response.headers[b"timing-allow-origin"] = "*"

    response.headers[b"content-type"] = "text/plain"
    response.headers[b"access-control-allow-origin"] = "*"
    response.write_status_headers()

def main(request, response):
    response.writer.write_data(item="Hello World", last=True)