Bug 1554539 - Fix access-control-basic-options-not-supported.py to consistently fail if the Origin header is unexpectedly missing; r=jgraham

Differential Revision: https://phabricator.services.mozilla.com/D32653

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Ehsan Akhgari 2019-05-28 14:50:11 +00:00
Родитель 245c6a0c97
Коммит eb5865bd87
2 изменённых файлов: 9 добавлений и 2 удалений

Просмотреть файл

@ -0,0 +1,4 @@
[access-control-basic-post-with-non-cors-safelisted-content-type.htm]
[Same-origin request with non-safelisted content type succeeds]
expected: FAIL

Просмотреть файл

@ -3,7 +3,10 @@ def main(request, response):
# Allow simple requests, but deny preflight
if request.method != "OPTIONS":
response.headers.set("Access-Control-Allow-Credentials", "true")
response.headers.set("Access-Control-Allow-Origin", request.headers.get("origin"))
if "origin" in request.headers:
response.headers.set("Access-Control-Allow-Credentials", "true")
response.headers.set("Access-Control-Allow-Origin", request.headers["origin"])
else:
response.status = 500
else:
response.status = 400