summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/cookies/resources/set.py
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/cookies/resources/set.py')
-rw-r--r--testing/web-platform/tests/cookies/resources/set.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/testing/web-platform/tests/cookies/resources/set.py b/testing/web-platform/tests/cookies/resources/set.py
new file mode 100644
index 0000000000..eda9338c92
--- /dev/null
+++ b/testing/web-platform/tests/cookies/resources/set.py
@@ -0,0 +1,15 @@
+from cookies.resources import helpers
+from urllib.parse import unquote
+
+from wptserve.utils import isomorphic_encode
+
+def main(request, response):
+ """Respond to `/cookie/set?{cookie}` by echoing `{cookie}` as a `Set-Cookie` header."""
+ headers = helpers.setNoCacheAndCORSHeaders(request, response)
+
+ # Cookies may require whitespace (e.g. in the `Expires` attribute), so the
+ # query string should be decoded.
+ cookie = unquote(request.url_parts.query)
+ headers.append((b"Set-Cookie", isomorphic_encode(cookie)))
+
+ return headers, b'{"success": true}'