From c40898fb33ef729061227b0ba3616c56a3c16635 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Tue, 9 Mar 2021 13:07:19 +0200 Subject: [PATCH] [Resource-Timing] content-length/encodedBodySize Added tests for different scenarios of `Content-Length` header and how it affects `encodedBodySize`. Closes https://github.com/web-platform-tests/wpt/issues/27952 --- .../resource_timing_content_length.html | 35 +++++++++++++++++++ .../resource-timing-content-length.py | 19 ++++++++++ 2 files changed, 54 insertions(+) create mode 100644 resource-timing/resource_timing_content_length.html create mode 100644 resource-timing/resources/resource-timing-content-length.py diff --git a/resource-timing/resource_timing_content_length.html b/resource-timing/resource_timing_content_length.html new file mode 100644 index 00000000000000..7bb373fb7e9892 --- /dev/null +++ b/resource-timing/resource_timing_content_length.html @@ -0,0 +1,35 @@ + + + + +This test validates the value of encodedBodySize in certain situations. + + + + + + diff --git a/resource-timing/resources/resource-timing-content-length.py b/resource-timing/resources/resource-timing-content-length.py new file mode 100644 index 00000000000000..6dbce047b72ef0 --- /dev/null +++ b/resource-timing/resources/resource-timing-content-length.py @@ -0,0 +1,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