summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/cookies/resources/echo-json.py
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/cookies/resources/echo-json.py')
-rw-r--r--testing/web-platform/tests/cookies/resources/echo-json.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/testing/web-platform/tests/cookies/resources/echo-json.py b/testing/web-platform/tests/cookies/resources/echo-json.py
new file mode 100644
index 000000000..8f82aa1e9
--- /dev/null
+++ b/testing/web-platform/tests/cookies/resources/echo-json.py
@@ -0,0 +1,15 @@
+import json
+
+def main(request, response):
+ headers = [("Content-Type", "application/json"),
+ ("Access-Control-Allow-Credentials", "true")]
+
+ if "origin" in request.headers:
+ headers.append(("Access-Control-Allow-Origin", request.headers["origin"]))
+
+ values = []
+ for key in request.cookies:
+ for value in request.cookies.get_list(key):
+ values.append("\"%s\": \"%s\"" % (key, value))
+ body = "{ %s }" % ",".join(values)
+ return headers, body