From ff06f1d031be33fd4ea319f821b789ddacacbdf6 Mon Sep 17 00:00:00 2001 From: WPT Sync Bot Date: Wed, 14 Nov 2018 20:46:44 -0500 Subject: Update web-platform-tests to revision 6856483bcc86322198f10e0c42385a7f9127eb66 --- .../support/cached-with-validation.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 tests/wpt/web-platform-tests/network-error-logging/support/cached-with-validation.py (limited to 'tests/wpt/web-platform-tests/network-error-logging/support/cached-with-validation.py') diff --git a/tests/wpt/web-platform-tests/network-error-logging/support/cached-with-validation.py b/tests/wpt/web-platform-tests/network-error-logging/support/cached-with-validation.py new file mode 100644 index 00000000000..f98a503a51e --- /dev/null +++ b/tests/wpt/web-platform-tests/network-error-logging/support/cached-with-validation.py @@ -0,0 +1,17 @@ +ETAG = '"123abc"' +CONTENT_TYPE = "text/plain" +CONTENT = "lorem ipsum dolor sit amet" + +def main(request, response): + # let caching kick in if possible (conditional GET) + etag = request.headers.get("If-None-Match", None) + if etag == ETAG: + response.headers.set("X-HTTP-STATUS", 304) + response.status = (304, "Not Modified") + return "" + + # cache miss, so respond with the actual content + response.status = (200, "OK") + response.headers.set("ETag", ETAG) + response.headers.set("Content-Type", CONTENT_TYPE) + return CONTENT -- cgit v1.2.3