diff --git a/fetch.bs b/fetch.bs index 4b1f0c2ca..fb383dc84 100644 --- a/fetch.bs +++ b/fetch.bs @@ -54,10 +54,28 @@ urlPrefix:https://tc39.es/ecma262/#;type:dfn;spec:ecma-262 url:realm;text:realm url:sec-list-and-record-specification-type;text:Record url:current-realm;text:current realm + +urlPrefix:https://www.ietf.org/archive/id/draft-annevk-johannhof-httpbis-cookies-00.html#;type:dfn;spec:cookies + url:name-cookie-store-and-limits;text:cookie store + url:name-parse-and-store-a-cookie;text:parse and store a cookie + url:name-parse-a-cookie;text:parse a cookie + url:name-store-a-cookie;text:store a cookie + url:name-retrieve-cookies;text:retrieve cookies + url:name-serialize-cookies;text:serialize cookies + + +urlPrefix:https://html.spec.whatwg.org#;type:dfn;spec:html + url:TODO;text:ancestry;for:environment + url:TODO;text:has storage access;for:environment
 {
+    "COOKIES": {
+      "authors": ["Johann Hofmann", "Anne van Kesteren"],
+      "href": "https://www.ietf.org/archive/id/draft-annevk-johannhof-httpbis-cookies-00.html",
+      "title": "Cookies: HTTP State Management Mechanism"
+    },
     "HTTP": {
         "aliasOf": "RFC9110"
     },
@@ -1938,6 +1956,10 @@ not always relevant and might require different behavior.
 "client" or an origin. Unless stated otherwise it is
 "client".
 
+

A request has an associated +top-level navigation +initiator origin, which is an origin or null. Unless stated otherwise it is null. +

"client" is changed to an origin during fetching. It provides a convenient way for standards to not have to set request's origin. @@ -2226,9 +2248,9 @@ or "object".


-

A request request has a -redirect-tainted origin if these steps -return true: +

A request has a redirect-taint, +which is "same-origin", "same-site", or "cross-site". +

To get request request's redirect-taint:

  1. Assert: request's origin is not @@ -2236,6 +2258,8 @@ return true:

  2. Let lastURL be null. +

  3. Let computedTaint be "same-origin". +

  4. For each url of request's URL list: @@ -2243,14 +2267,20 @@ return true:

  5. If lastURL is null, then set lastURL to url and continue. +

  6. If url's origin is not same site with + lastURL's origin and request's origin is + not same site with lastURL's origin, then return + "cross-site". +

  7. If url's origin is not same origin with lastURL's origin and request's origin is - not same origin with lastURL's origin, then return true. + not same origin with lastURL's origin, then set + computedTaint to "same-site".

  8. Set lastURL to url.
-
  • Return false. +
  • Return computedTaint.
  • @@ -2262,8 +2292,8 @@ run these steps:
  • Assert: request's origin is not "client". -

  • If request has a redirect-tainted origin, then return - "null". +

  • If request's redirect-taint is not "same-origin", + then return "null".

  • Return request's origin, serialized. @@ -2372,8 +2402,8 @@ source of security bugs. Please seek security review for features that deal with "credentialless", then return true.

  • If request's origin is same origin with - request's current URL's origin and request - does not have a redirect-tainted origin, then return true.

    + request's current URL's origin and request's + redirect-taint is not "same-origin", then return true.

  • Return false.

    @@ -2486,8 +2516,9 @@ this is also tracked internally using the request's timing allow service worker timing info (null or a service worker timing info), which is initially null. -

    A response has an associated has-cross-origin-redirects -(a boolean), which is initially false. +

    A response has an associated redirect taint +("same-origin", "same-site", or "cross-site", which is +initially "same-origin".


    @@ -4225,7 +4256,108 @@ indicates the request’s purpose is to fetch a resource that is anticipated to

    The server can use this to adjust the caching expiry for prefetches, to disallow the prefetch, or to treat it differently when counting page visits. +

    Cookies

    + + + +

    The `Cookie` header is largely defined in its own specification. [[COOKIES]]. +We define infrastructure to be able to use them conveniently here. + +

    +

    To append a request `Cookie` header, +given a request request, run these steps: + +

      +
    1. If the user-agent is configured to disable cookies for request, it should + return. + +

    2. Let |sameSite| be the result of [=determining the same-site mode=] for request. + +

    3. Let |isSecure| be false. + +

    4. If request's client is a secure context, then set + |isSecure| to true. + +

    5. Let |httpOnlyAllowed| be true. + +

      Fetch implies that the request is http-only, as opposed to document.cookie + +

    6. Let |cookies| be the result of running retrieve cookies given |isSecure|, + request's current URL's host, request's + current URL's path, |httpOnlyAllowed|, and |sameSite| + +

      It is expected that the cookie store returns an ordered list of cookies + +

    7. If |cookies| is empty, then return. + +
    8. Let |value| be the result of running serialize cookies given |cookies|. + +
    9. Append (`Cookie`, value) to + request's header list. +
    +
    + +
    +

    To parse and store response +`Set-Cookie` headers, given a request request and a response response, run these steps: + +

      +
    1. If the user-agent is configured to disable cookies for request, it should + return. +

    2. Let |allowNonHostOnlyCookieForPublicSuffix| be false. + +

    3. Let |isSecure| be false. + +

    4. If request's client is a secure context, set + |isSecure| to true. + +

    5. Let |httpOnlyAllowed| be true. + +

      Fetch implies that the request is http-only, as opposed to document.cookie + +

    6. Let |sameSiteStrictOrLaxAllowed| be true if the result of [=determine the same-site mode=] + for |request| is "StrictOrLess", and false otherwise. + +

    7. For each header of response's header + list: + +

        +
      1. If header's name is not a byte-case-insensitive match + for `Set-Cookie`, continue. + +

      2. Parse and store a cookie given header's value, + |isSecure|, request's current URL's host, + request's current URL's path, |httpOnlyAllowed|, + |allowNonHostOnlyCookieForPublicSuffix|, and |sameSiteStrictOrLaxAllowed| +

      +
    +
    + +
    +

    To determine the same-site mode for a given request request, +run these steps: + +

      +
    1. Assert: request's method is "GET" or "POST". + +

    2. If request's top-level navigation initiator origin is not + null and is not same site to request's URL's + origin, return "UnsetOrLess". + +

    3. If request's method is "GET" and request's destination is "document", return "LaxOrLess". + +

    4. If request's client's ancestry is + "cross-site", return "UnsetOrLess". + +

    5. If request's redirect-taint is "cross-site", + return "UnsetOrLess". + +

    6. Return "StrictOrLess". +

    +

    Fetching

    @@ -4680,8 +4812,8 @@ steps: -
  • If request has a redirect-tainted origin, then set - internalResponse's has-cross-origin-redirects to true. +

  • Set internalResponse's redirect taint to request's + redirect-taint.

  • If request's timing allow failed flag is unset, then set internalResponse's timing allow passed flag. @@ -4834,7 +4966,7 @@ steps:

  • If fetchParams's request's mode is not "navigate" or response's - has-cross-origin-redirects is false: + redirect taint is "same-origin":

    1. Set responseStatus to response's status. @@ -5710,21 +5842,7 @@ run these steps:

      If includeCredentials is true, then:

        -
      1. -

        If the user agent is not configured to block cookies for httpRequest (see - section 7 of - [[!COOKIES]]), then: - -

          -
        1. Let cookies be the result of running the "cookie-string" algorithm (see - section 5.4 of - [[!COOKIES]]) with the user agent's cookie store and httpRequest's - current URL. - -

        2. If cookies is not the empty string, then append - (`Cookie`, cookies) to httpRequest's - header list. -
        +
      2. Append a request `Cookie` header for httpRequest.

      3. If httpRequest's header list @@ -6288,14 +6406,9 @@ optional boolean forceNewConnection (default false), run these steps:

      4. Set response's body to a new body whose stream is stream. -

      5. If includeCredentials is true and the user agent is not - configured to block cookies for request (see - section 7 of - [[!COOKIES]]), then run the "set-cookie-string" parsing algorithm (see - section 5.2 of [[!COOKIES]]) on the - value of each header whose name is a - byte-case-insensitive match for `Set-Cookie` in response's - header list, if any, and request's current URL. +

      6. If includeCredentials is true, the user agent should parse and + store response `Set-Cookie` headers given request and + response.

      7. Run these steps in parallel: