summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/xhr/resources/redirect-cors.py
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/xhr/resources/redirect-cors.py')
-rw-r--r--testing/web-platform/tests/xhr/resources/redirect-cors.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/testing/web-platform/tests/xhr/resources/redirect-cors.py b/testing/web-platform/tests/xhr/resources/redirect-cors.py
new file mode 100644
index 0000000000..5d030a6227
--- /dev/null
+++ b/testing/web-platform/tests/xhr/resources/redirect-cors.py
@@ -0,0 +1,20 @@
+def main(request, response):
+ location = request.GET.first(b"location")
+
+ if request.method == u"OPTIONS":
+ if b"redirect_preflight" in request.GET:
+ response.status = 302
+ response.headers.set(b"Location", location)
+ else:
+ response.status = 200
+ response.headers.set(b"Access-Control-Allow-Methods", b"GET")
+ response.headers.set(b"Access-Control-Max-Age", 1)
+ elif request.method == u"GET":
+ response.status = 302
+ response.headers.set(b"Location", location)
+
+ if b"allow_origin" in request.GET:
+ response.headers.set(b"Access-Control-Allow-Origin", request.headers.get(b"origin"))
+
+ if b"allow_header" in request.GET:
+ response.headers.set(b"Access-Control-Allow-Headers", request.GET.first(b"allow_header"))