header-delay.h2.py (799B)
1 from time import sleep 2 3 def handle_headers(frame, request, response): 4 delay = int(request.GET.first(b"delay")) / 1000 5 6 if b"with100" in request.GET: 7 sleep(delay) 8 response.writer.write_raw_header_frame(headers=[(b":status", b"103")], end_headers=True) 9 10 if b"with103" in request.GET: 11 sleep(delay) 12 response.writer.write_raw_header_frame(headers=[(b":status", b"103")], end_headers=True) 13 14 sleep(delay) 15 response.status = 200 16 17 if b"tao" in request.GET: 18 response.headers[b"timing-allow-origin"] = "*" 19 20 response.headers[b"content-type"] = "text/plain" 21 response.headers[b"access-control-allow-origin"] = "*" 22 response.write_status_headers() 23 24 def main(request, response): 25 response.writer.write_data(item="Hello World", last=True)