summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/loading/early-hints/resources/early-hints-delay.h2.py
blob: ba8796bc11a136fa9652fbf6b07612c929c1c9b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import time

def handle_headers(frame, request, response):
    early_hints = [
        (b":status", b"103"),
        (b"link", b"</empty.js>; rel=preload; as=script"),
    ]

    time.sleep(int(request.GET.first(b"delay1")) / 1000)
    response.writer.write_raw_header_frame(headers=early_hints,
                                           end_headers=True)

    time.sleep(int(request.GET.first(b"delay2")) / 1000)
    response.status = 200
    response.headers[b"content-type"] = "text/html"
    response.write_status_headers()


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