From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- .../tests/content-dpr/resources/dpr.py | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 testing/web-platform/tests/content-dpr/resources/dpr.py (limited to 'testing/web-platform/tests/content-dpr/resources/dpr.py') diff --git a/testing/web-platform/tests/content-dpr/resources/dpr.py b/testing/web-platform/tests/content-dpr/resources/dpr.py new file mode 100644 index 0000000000..969ac2458d --- /dev/null +++ b/testing/web-platform/tests/content-dpr/resources/dpr.py @@ -0,0 +1,26 @@ +from wptserve.utils import isomorphic_decode + +def main(request, response): + """ + Simple handler that sets a response header based on which client hint + request headers were received. + """ + + response.headers.append(b"Access-Control-Allow-Origin", b"*") + values = request.GET + name = values.first(b'name') + type = values.first(b'mimeType') + dpr = values.first(b'dpr') + double = None + if b'double' in values: + double = values.first(b'double') + image_path = request.doc_root + u"/".join(request.url_parts[2].split(u"/")[:-1]) + u"/" + isomorphic_decode(name) + f = open(image_path, "rb") + buff = f.read() + f.close() + response.headers.set(b"Content-Type", type) + response.headers.set(b"Content-DPR", dpr) + if double: + response.headers.append(b"Content-DPR", double) + response.headers.set(b"Content-Length", len(buff)) + response.content = buff -- cgit v1.2.3