OLD | NEW |
(Empty) | |
| 1 def main(request, response): |
| 2 headers = [] |
| 3 request_headers = [] |
| 4 if "headers" in request.GET: |
| 5 checked_headers = request.GET.first("headers").split("|") |
| 6 for header in checked_headers: |
| 7 if header in request.headers: |
| 8 headers.append(("x-request-" + header, request.headers.get(header,
"") )) |
| 9 |
| 10 if "cors" in request.GET: |
| 11 if "Origin" in request.headers: |
| 12 headers.append(("Access-Control-Allow-Origin", request.headers.get("
Origin", ""))) |
| 13 else: |
| 14 headers.append(("Access-Control-Allow-Origin", "*")) |
| 15 headers.append(("Access-Control-Allow-Credentials", "true")) |
| 16 headers.append(("Access-Control-Allow-Methods", "GET, POST, HEAD")) |
| 17 exposed_headers = ["x-request-" + header for header in checked_headers] |
| 18 headers.append(("Access-Control-Expose-Headers", ", ".join(exposed_heade
rs))) |
| 19 headers.append(("Access-Control-Allow-Headers", ", ".join(request.header
s))) |
| 20 |
| 21 headers.append(("content-type", "text/plain")) |
| 22 return headers, "" |
OLD | NEW |