summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/fetch/api/resources/bad-chunk-encoding.py
blob: 94a77adead858b48137e3988d0c674cd945a4270 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
import time

def main(request, response):
    delay = float(request.GET.first(b"ms", 1000)) / 1E3
    count = int(request.GET.first(b"count", 50))
    time.sleep(delay)
    response.headers.set(b"Transfer-Encoding", b"chunked")
    response.write_status_headers()
    time.sleep(delay)
    for i in range(count):
        response.writer.write_content(b"a\r\nTEST_CHUNK\r\n")
        time.sleep(delay)
    response.writer.write_content(b"garbage")