aboutsummaryrefslogtreecommitdiffstats
path: root/tests/wpt/web-platform-tests/network-error-logging/support/cached-with-validation.py
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2018-11-15 11:17:18 -0500
committerGitHub <noreply@github.com>2018-11-15 11:17:18 -0500
commit13e322183df9836ea1330e64756a7fddf7da972f (patch)
tree7089c8dedad5e1173185e96be651917707b57857 /tests/wpt/web-platform-tests/network-error-logging/support/cached-with-validation.py
parent359ec7a76f1eb5d70360ff2b8c49923e9383eca7 (diff)
parentff06f1d031be33fd4ea319f821b789ddacacbdf6 (diff)
downloadservo-13e322183df9836ea1330e64756a7fddf7da972f.tar.gz
servo-13e322183df9836ea1330e64756a7fddf7da972f.zip
Auto merge of #22199 - servo-wpt-sync:wpt_update_14-11-2018, r=jdm
Sync WPT with upstream (14-11-2018) Automated downstream sync of changes from upstream as of 14-11-2018. [no-wpt-sync] <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22199) <!-- Reviewable:end -->
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