summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/resource-timing/resources/resource-timing-content-length.py
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/resource-timing/resources/resource-timing-content-length.py')
-rw-r--r--testing/web-platform/tests/resource-timing/resources/resource-timing-content-length.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/testing/web-platform/tests/resource-timing/resources/resource-timing-content-length.py b/testing/web-platform/tests/resource-timing/resources/resource-timing-content-length.py
new file mode 100644
index 0000000000..6dbce047b7
--- /dev/null
+++ b/testing/web-platform/tests/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