|
Line 0
a/LayoutTests/http/wpt/service-workers/resources/cross-origin-allow-for-beacon.py_sec1
|
|
|
1 |
def main(request, response): |
| 2 |
token = request.GET.first(b"token", None) |
| 3 |
if request.method == u'OPTIONS': |
| 4 |
headers = request.headers.get("Access-Control-Request-Headers", "none") |
| 5 |
if "cache-control" in str(headers): |
| 6 |
request.server.stash.put(token, "preflight ko, got cache-control") |
| 7 |
return 404, [(b"Cache-Control", b"no-store")], u"cache-control in preflight" |
| 8 |
if "content-type" not in str(headers): |
| 9 |
request.server.stash.put(token, "preflight ko got content-type") |
| 10 |
return 404, [(b"Cache-Control", b"no-store")], u"content-type not in preflight" |
| 11 |
request.server.stash.put(token, "preflight ok") |
| 12 |
return 200, [(b"Cache-Control", b"no-store"), (b"Content-Type", b"text/ascii"), (b"Access-Control-Allow-Origin", b"http://localhost:8800"), (b"Access-Control-Allow-Credentials", b"true"), (b"Access-Control-Allow-Headers", b"content-type"), (b"Access-Control-Allow-Methods", b"*")], u"ok" |
| 13 |
if request.method == u'GET': |
| 14 |
return 200, [(b"Content-Type", b"text/ascii")], request.server.stash.take(token) |
| 15 |
return 200, [(b"Content-Type", b"text/ascii"), (b"Access-Control-Allow-Origin", b"http://localhost:8800"), (b"Access-Control-Allow-Credentials", b"true")], u"post ok" |