summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/worklets/resources/set-cookie.py
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/worklets/resources/set-cookie.py')
-rw-r--r--testing/web-platform/tests/worklets/resources/set-cookie.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/testing/web-platform/tests/worklets/resources/set-cookie.py b/testing/web-platform/tests/worklets/resources/set-cookie.py
new file mode 100644
index 0000000000..a36a69cce6
--- /dev/null
+++ b/testing/web-platform/tests/worklets/resources/set-cookie.py
@@ -0,0 +1,15 @@
+def main(request, response):
+ name = request.GET.first(b"name")
+ value = request.GET.first(b"value")
+ source_origin = request.headers.get(b"origin")
+ if source_origin is None:
+ # Same origin GET won't include origin header
+ source_origin = "%s://%s" % (request.url_parts.scheme,
+ request.url_parts.netloc)
+ if request.url_parts.port:
+ source_origin += ":%s" % request.url_parts.port
+
+ response_headers = [(b"Set-Cookie", name + b"=" + value),
+ (b"Access-Control-Allow-Origin", source_origin),
+ (b"Access-Control-Allow-Credentials", b"true")]
+ return (200, response_headers, u"")