aboutsummaryrefslogtreecommitdiffstats
path: root/tests/wpt/web-platform-tests/network-error-logging/support/cached-with-validation.py
diff options
context:
space:
mode:
authorWPT Sync Bot <josh+wptsync@joshmatthews.net>2018-11-14 20:46:44 -0500
committerWPT Sync Bot <josh+wptsync@joshmatthews.net>2018-11-14 22:29:47 -0500
commitff06f1d031be33fd4ea319f821b789ddacacbdf6 (patch)
treea041c783523c9366455123e33bd0d9e126853811 /tests/wpt/web-platform-tests/network-error-logging/support/cached-with-validation.py
parentb1a2b6b5bfe72440059834c67dc28ad422b89a82 (diff)
downloadservo-ff06f1d031be33fd4ea319f821b789ddacacbdf6.tar.gz
servo-ff06f1d031be33fd4ea319f821b789ddacacbdf6.zip
Update web-platform-tests to revision 6856483bcc86322198f10e0c42385a7f9127eb66
Diffstat (limited to 'tests/wpt/web-platform-tests/network-error-logging/support/cached-with-validation.py')
-rw-r--r--tests/wpt/web-platform-tests/network-error-logging/support/cached-with-validation.py17
1 files changed, 17 insertions, 0 deletions
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