Index: third_party/WebKit/LayoutTests/external/wpt/fetch/api/resources/inspect-headers.py |
diff --git a/third_party/WebKit/LayoutTests/external/wpt/fetch/api/resources/inspect-headers.py b/third_party/WebKit/LayoutTests/external/wpt/fetch/api/resources/inspect-headers.py |
new file mode 100644 |
index 0000000000000000000000000000000000000000..c4ace18ab64b11e9c09054c08be2d4d22f70264e |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/external/wpt/fetch/api/resources/inspect-headers.py |
@@ -0,0 +1,22 @@ |
+def main(request, response): |
+ headers = [] |
+ request_headers = [] |
+ if "headers" in request.GET: |
+ checked_headers = request.GET.first("headers").split("|") |
+ for header in checked_headers: |
+ if header in request.headers: |
+ headers.append(("x-request-" + header, request.headers.get(header, "") )) |
+ |
+ if "cors" in request.GET: |
+ if "Origin" in request.headers: |
+ headers.append(("Access-Control-Allow-Origin", request.headers.get("Origin", ""))) |
+ else: |
+ headers.append(("Access-Control-Allow-Origin", "*")) |
+ headers.append(("Access-Control-Allow-Credentials", "true")) |
+ headers.append(("Access-Control-Allow-Methods", "GET, POST, HEAD")) |
+ exposed_headers = ["x-request-" + header for header in checked_headers] |
+ headers.append(("Access-Control-Expose-Headers", ", ".join(exposed_headers))) |
+ headers.append(("Access-Control-Allow-Headers", ", ".join(request.headers))) |
+ |
+ headers.append(("content-type", "text/plain")) |
+ return headers, "" |