summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/cookies/resources/drop.py
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/cookies/resources/drop.py')
-rw-r--r--testing/web-platform/tests/cookies/resources/drop.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/testing/web-platform/tests/cookies/resources/drop.py b/testing/web-platform/tests/cookies/resources/drop.py
new file mode 100644
index 0000000000..612add2169
--- /dev/null
+++ b/testing/web-platform/tests/cookies/resources/drop.py
@@ -0,0 +1,14 @@
+from cookies.resources.helpers import makeDropCookie, readParameter, setNoCacheAndCORSHeaders
+
+def main(request, response):
+ """Respond to `/cookie/drop?name={name}` by expiring the cookie named `{name}`."""
+ headers = setNoCacheAndCORSHeaders(request, response)
+ try:
+ # Expire the named cookie, and return a JSON-encoded success code.
+ name = readParameter(request, paramName=u"name", requireValue=True)
+ scheme = request.url_parts.scheme
+ headers.append(makeDropCookie(name, u"https" == scheme))
+ return headers, b'{"success": true}'
+ except:
+ return 500, headers, b'{"error" : "Empty or missing name parameter."}'
+