Sync web-platform-tests up to revision a5b95cb31914507088a4eda16f7674bbc6f3313f
[WebKit-https.git] / LayoutTests / imported / w3c / web-platform-tests / XMLHttpRequest / resources / corsenabled.py
1 import time
2
3 def main(request, response):
4     headers = [("Access-Control-Allow-Origin", "*"),
5                ("Access-Control-Allow-Credentials", "true"),
6                ("Access-Control-Allow-Methods", "GET, POST, PUT, FOO"),
7                ("Access-Control-Allow-Headers", "x-test, x-foo"),
8                ("Access-Control-Expose-Headers", "x-request-method, x-request-content-type, x-request-query, x-request-content-length, x-request-data")]
9
10     if "delay" in request.GET:
11         delay = int(request.GET.first("delay"))
12         time.sleep(delay)
13
14     if "safelist_content_type" in request.GET:
15         headers.append(("Access-Control-Allow-Headers", "content-type"))
16
17     headers.append(("X-Request-Method", request.method))
18     headers.append(("X-Request-Query", request.url_parts.query if request.url_parts.query else "NO"))
19     headers.append(("X-Request-Content-Length", request.headers.get("Content-Length", "NO")))
20     headers.append(("X-Request-Content-Type", request.headers.get("Content-Type", "NO")))
21     headers.append(("X-Request-Data", request.body))
22
23     return headers, "Test"