diff --git a/fetch.bs b/fetch.bs index cfaaf6693..dd8aeb4c1 100644 --- a/fetch.bs +++ b/fetch.bs @@ -1675,7 +1675,7 @@ Unless stated otherwise, it is unset.
"only-if-cached"
Fetch uses any response in the HTTP cache matching the request, not paying attention to - staleness. If there was no response, it returns a network error. (Can only be used when + staleness. If there was no response, it returns a network error. (Can only be used when request's mode is "same-origin". Any cached redirects will be followed assuming request's @@ -2018,6 +2018,14 @@ known as an aborted network errorheader list is always empty, and body is always null. +

To create a network error given +fetch params fetchParams, return a new network error with its +timing info set to the result of creating an opaque timing info with +fetchParams's timing info, and its +URL list set to a list containing fetchParams's +request's URL. + +


A filtered response is a limited view on a @@ -3790,8 +3798,9 @@ steps:

  • Let response be null.

  • If request's local-URLs-only flag is set and request's - current URL is not local, then set response to a - network error. + current URL is not local, then set response to + the result of creating a network error given + fetchParams.

  • Run report Content Security Policy violations for request. @@ -3800,7 +3809,8 @@ steps:

  • If should request be blocked due to a bad port, should fetching request be blocked as mixed content, or should request be blocked by Content Security Policy - returns blocked, then set response to a network error. + returns blocked, then set response to the result of + creating a network error given fetchParams..

  • If request's referrer policy is the empty string, then set request's referrer policy to request's @@ -3864,14 +3874,16 @@ steps:

    request's mode is "same-origin" -

    Return a network error. +

    Return the result of creating a network error given + fetchParams.

    request's mode is "no-cors"
    1. If request's redirect mode is not "follow", - then return a network error. + then return the result of creating a network error given + fetchParams.

    2. Set request's response tainting to @@ -3896,7 +3908,8 @@ steps:

      request's current URL's scheme is not an HTTP(S) scheme -

      Return a network error. +

      Return the result of creating a network error given + fetchParams.

      request's use-CORS-preflight flag is set
      request's unsafe-request flag is set and either request's @@ -4003,14 +4016,16 @@ steps:
    3. should internalResponse to request be blocked due to nosniff -

      then set response and internalResponse to a network error. +

      then set response and internalResponse to the result of creating a network error given + fetchParams.

    4. If response's type is "opaque", internalResponse's status is 206, internalResponse's range-requested flag is set, and request's header list does not contain `Range`, - then set response and internalResponse to a network error. + then set response and internalResponse to the result of + creating a network error given fetchParams.

      Traditionally, APIs accept a ranged response even if a range was not requested. This prevents @@ -4173,7 +4188,8 @@ steps: name is `Content-Type` and value is `text/html;charset=utf-8`, and body is the empty byte sequence. -

      Otherwise, return a network error. +

      Otherwise, return the result of creating a network error + given fetchParams.

      URLs such as "about:config" are handled during navigation and result in a network error in the context of @@ -4191,7 +4207,9 @@ steps:

    5. If request's method is not `GET` or - blob is not a {{Blob}} object, then return a network error. [[!FILEAPI]] + blob is not a {{Blob}} object, then return the result of + creating a network error given fetchParams. + [[!FILEAPI]]

      The `GET` method restriction serves no useful purpose other than being interoperable. @@ -4226,9 +4244,12 @@ steps:

      1. Let aborted be the termination's aborted flag. -

      2. If aborted is set, then return an aborted network error. +

      3. If aborted is set, then return the result of + creating an aborted network error given + fetchParams. -

      4. Return a network error. +

      5. Return the result of creating a network error given + fetchParams.

    @@ -4238,7 +4259,8 @@ steps:
  • Let dataURLStruct be the result of running the data: URL processor on request's current URL. -

  • If dataURLStruct is failure, then return a network error. +

  • If dataURLStruct is failure, then return the result of + creating a network error given fetchParams..

  • Return a response whose status message is `OK`, header list consist of a single header whose @@ -4253,14 +4275,16 @@ steps:

    For now, unfortunate as it is, file URLs are left as an exercise for the reader. -

    When in doubt, return a network error. +

    When in doubt, return the result of creating a network error given + fetchParams.

    HTTP(S) scheme

    Return the result of running HTTP fetch given fetchParams.

    Otherwise -

    Return a network error. +

    Return the result of creating a network error given + fetchParams. @@ -4361,7 +4385,8 @@ these steps: response's URL list has more than one item. -

    then return a network error. +

    then return the result of creating a network error given + fetchParams. @@ -4500,13 +4525,16 @@ run these steps:

  • If locationURL is null, then return response. -

  • If locationURL is failure, then return a network error. +

  • If locationURL is failure, then return the result of + creating a network error given fetchParams.

  • If locationURL's scheme is not an HTTP(S) scheme, then - return a network error. + return the result of creating a network error given + fetchParams.

  • If request's redirect count is - twenty, return a network error. + twenty, return the result of creating a network error given + fetchParams.

  • Increase request's redirect count by one. @@ -4514,17 +4542,20 @@ run these steps:

  • If request's mode is "cors", locationURL includes credentials, and request's origin is not same origin with locationURL's - origin, then return a network error. + origin, then the result of creating a + network error given fetchParams.

  • If request's response tainting is "cors" and - locationURL includes credentials, then return a network error. + locationURL includes credentials, then return the result of + creating a network error given fetchParams.

    This catches a cross-origin resource redirecting to a same-origin URL.

  • If actualResponse's status is not 303, request's body is non-null, and request's body's - source is null, then return a network error. + source is null, then return the result of + creating a network error given fetchParams.

  • If locationURL's origin is not same origin with request's current URL's origin and @@ -4718,7 +4749,8 @@ steps. They return a response.

  • If the sum of contentLength and inflightKeepaliveBytes is greater - than 64 kibibytes, then return a network error. + than 64 kibibytes, then return the result of creating a + network error given fetchParams.

    The above limit ensures that requests that are allowed to outlive the @@ -4964,9 +4996,12 @@ steps. They return a response.

    1. Let aborted be the termination's aborted flag. -

    2. If aborted is set, then return an aborted network error. +

    3. If aborted is set, then return the result of + creating an aborted network error given + fetchParams. -

    4. Return a network error. +

    5. Return the result of creating a network error given + fetchParams.

    @@ -4975,7 +5010,8 @@ steps. They return a response.
    1. If httpRequest's cache mode is - "only-if-cached", then return a network error. + "only-if-cached", then return the result of creating a + network error given fetchParams.

    2. Let forwardResponse be the result of running HTTP-network fetch given httpFetchParams, includeCredentials, and isNewConnectionFetch. @@ -5048,7 +5084,8 @@ steps. They return a response.

      1. If request's body's source is null, - then return a network error. + then return the result of creating a network error given + fetchParams.

      2. Set request's body to the first return value of safely extracting request's body's @@ -5066,9 +5103,12 @@ steps. They return a response.

        1. Let aborted be the termination's aborted flag. -

        2. If aborted is set, then return an aborted network error. +

        3. If aborted is set, then return the result of + creating an aborted network error given + fetchParams. -

        4. Return a network error. +

        5. Return the result of creating a network error given + fetchParams.

      3. Let username and password be the result of prompting the end user @@ -5091,7 +5131,8 @@ steps. They return a response.

        1. If request's window is - "no-window", then return a network error. + "no-window", then return the result of creating a + network error given fetchParams.

        2. Needs testing: multiple `Proxy-Authenticate` headers, missing, parsing issues. @@ -5102,9 +5143,12 @@ steps. They return a response.

          1. Let aborted be the termination's aborted flag. -

          2. If aborted is set, then return an aborted network error. +

          3. If aborted is set, then return the result of + creating an aborted network error given + fetchParams. -

          4. Return a network error. +

          5. Return the result of creating a network error given + fetchParams.

        3. @@ -5140,9 +5184,12 @@ steps. They return a response.
          1. Let aborted be the termination's aborted flag. -

          2. If aborted is set, then return an aborted network error. +

          3. If aborted is set, then return the result of + creating an aborted network error given + fetchParams. -

          4. Return a network error. +

          5. Return the result of creating a network error given + fetchParams.

        4. Set response to the result of running HTTP-network-or-cache fetch given @@ -5203,7 +5250,8 @@ optional boolean forceNewConnection (default false), run these steps:

          Run these steps, but abort when the ongoing fetch is terminated:

            -
          1. If connection is failure, then return a network error. +

          2. If connection is failure, then return the result of + creating a network error given fetchParams.

          3. Set timingInfo's final connection timing info to the result of calling clamp and coarsen connection timing info with @@ -5234,7 +5282,8 @@ optional boolean forceNewConnection (default false), run these steps: buffer of up to 64 kibibytes and store a part of request's body in that buffer. If the user agent reads from request's body beyond that buffer's size and the user agent needs to resend request, then instead - return a network error. + return the result of creating a network error given + fetchParams.

            The resending is needed when the connection is timed out, for example. @@ -5272,7 +5321,8 @@ optional boolean forceNewConnection (default false), run these steps:

            If request's header list contains `Transfer-Encoding`/`chunked` and response is transferred - via HTTP/1.0 or older, then return a network error. + via HTTP/1.0 or older, then return the result of creating a + network error given fetchParams.

            If the HTTP request results in a TLS client certificate dialog, then: @@ -5282,7 +5332,8 @@ optional boolean forceNewConnection (default false), run these steps: available in request's window. -

          4. Otherwise, return a network error. +

          5. Otherwise, return the result of creating a + network error given fetchParams.

          To transmit request's body body, run these steps: @@ -5352,9 +5403,12 @@ optional boolean forceNewConnection (default false), run these steps:

        5. If connection uses HTTP/2, then transmit an RST_STREAM frame. -

        6. If aborted is set, then return an aborted network error. +

        7. If aborted is set, then return the result of + creating an aborted network error given + fetchParams. -

        8. Return a network error. +

        9. Return the result of creating a network error given + fetchParams.

      4. Let pullAlgorithm be an action that resumes the @@ -5588,7 +5642,8 @@ number of these fetches. header list.

      5. If either methods or headerNames is failure, - return a network error. + return the result of creating a network error given + fetchParams.

      6. If methods is null and request's use-CORS-preflight flag @@ -5602,19 +5657,22 @@ number of these fetches.

      7. If request's method is not in methods, request's method is not a CORS-safelisted method, and request's credentials mode is "include" or - methods does not contain `*`, then return a network error. + methods does not contain `*`, then return the result of + creating a network error given fetchParams.

      8. If one of request's header list's names is a CORS non-wildcard request-header name and is not a byte-case-insensitive match for an item in headerNames, then - return a network error. + return the result of creating a network error given + fetchParams.

      9. For each unsafeName in the CORS-unsafe request-header names with request's header list, if unsafeName is not a byte-case-insensitive match for an item in headerNames and request's credentials mode is "include" or headerNames does not - contain `*`, return a network error. + contain `*`, return the result of creating a + network error given fetchParams.

      10. Let max-age be the result of extracting header list values given `Access-Control-Max-Age` and response's @@ -5647,7 +5705,8 @@ number of these fetches.

      11. Return response.

      -
    3. Otherwise, return a network error. +

    4. Otherwise, return the result of creating a network error + given fetchParams.

    @@ -7270,7 +7329,8 @@ constructor steps are:

    The static error() method steps are to return the -result of creating a {{Response}} object, given a new network error, +result of creating a {{Response}} object, given the result of +creating an network error given fetchParams, "immutable", and this's relevant Realm.

    The static @@ -7422,8 +7482,14 @@ method steps are: with p, request, and responseObject, and terminate these substeps. -

  • If response is a network error, then reject p - with a {{TypeError}} and terminate these substeps. +

  • If response is a network error, then: +

      +
    1. Reject p with a {{TypeError}}. + +

    2. Call handleFetchDone

      with response. + +
    3. terminate these substeps. +

  • Set responseObject to the result of creating a {{Response}} object, given response, "immutable", and relevantRealm.