summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/resource-timing/resources/resource-timing-content-length.py
blob: 6dbce047b72ef05976d5296ea38961e205a0f04e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
def main(request, response):
    content = request.GET.first(b"content")
    length = request.GET.first(b"length").decode("ascii")
    response.add_required_headers = False

    output =  b"HTTP/1.1 200 OK\r\n"
    output += b"Content-Type: text/plain;charset=UTF-8\r\n"
    if length == b"auto" :
        output += b"Content-Length:"
        output += "{0}".format(len(content)).encode("ascii")
        output += b"\r\n"
    elif length != b"none" :
        output += b"Content-Length:"
        output += "{0}".format(length).encode("ascii")
        output += b"\r\n"
    output += b"\r\n"
    output += content
    response.writer.write(output)
    response.close_connection = True