Revision 9936e8c644dfcfc1c02ba53fa26c501d64eccc11 authored by Yutaka Hirano on 21 November 2017, 10:42:44 UTC, committed by Chromium WPT Sync on 21 November 2017, 10:42:44 UTC
This CL introduces a mime type parser and stringifier to
wpt/XMLHttpRequest/send-content-type-charset in order to accept
implementations that are actually conforming to the spec but were rejected
by the test due to some text representation errors.

Bug: https://github.com/whatwg/mimesniff/issues/39
Change-Id: I99466e2e596bb9c1b7f11267ad4ff0a886913086
1 parent 93f495e
Raw File
credentials.py
# Returns a valid response when a request has appropriate credentials.
def main(request, response):
    credentials_mode = request.GET.first("mode")
    cookie = request.cookies.first("cookieName", None)
    source_origin = request.headers.get("origin", None);
    is_cross_origin = request.GET.first("is_cross_origin", False)

    # The request with the default WorkletOptions should not include the cookie.
    if credentials_mode is "default" and cookie is not None:
        return (404)

    # The request with "credentials=omit" should not include the cookie.
    if credentials_mode is "omit" and cookie is not None:
        return (404)

    if credentials_mode is "same-origin":
        # The cross-origin request with "credentials=same-origin" should not
        # include the cookie.
        if is_cross_origin and cookie is not None:
          return (404)
        # The same-origin request with "credentials=same-origin" should include
        # the cookie.
        if not is_cross_origin and cookie is None:
          return (404)

    # The request with "credentials=include" should include the cookie.
    if credentials_mode is "include" and cookie is None:
        return (404)

    return (200, [("Content-Type", "text/javascript"),
                  ("Access-Control-Allow-Origin", source_origin),
                  ("Access-Control-Allow-Credentials", "true")], "")
back to top