Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Unified Diff: third_party/WebKit/LayoutTests/external/wpt/fetch/api/resources/cache.py

Issue 2778753002: Import //fetch from Web Platform Tests. (Closed)
Patch Set: Baselines. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/external/wpt/fetch/api/resources/cache.py
diff --git a/third_party/WebKit/LayoutTests/external/wpt/fetch/api/resources/cache.py b/third_party/WebKit/LayoutTests/external/wpt/fetch/api/resources/cache.py
new file mode 100644
index 0000000000000000000000000000000000000000..899638716a100a66c06cebbf92c31de7c705498b
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/external/wpt/fetch/api/resources/cache.py
@@ -0,0 +1,18 @@
+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

Powered by Google App Engine
This is Rietveld 408576698