From da4db3d74e3cabd43dc8e938aac46b2cda7a685a Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Thu, 14 Oct 2021 17:17:28 +0300 Subject: [PATCH] Use controller for terminating --- fetch.bs | 121 +++++++++++++++++++++++++++---------------------------- 1 file changed, 59 insertions(+), 62 deletions(-) diff --git a/fetch.bs b/fetch.bs index 409ae80b9..a21c52144 100644 --- a/fetch.bs +++ b/fetch.bs @@ -204,6 +204,10 @@ lt="authentication entry">authentication entries (for HTTP authentication).
cross-origin isolated capability (default false)
A boolean. +
terminated flag +
aborted flag +
A flag, initially unset. +
timing info
A fetch timing info. @@ -254,6 +258,19 @@ given a fetch timing info timingInfo, return a new storedTimingInfo's decoded body size. +

A fetch controller is an object used to enable clients of an ongoing fetch +to perform certain actions in the context of that fetch instance. + +

A fetch controller has an associated fetch params +ongoing fetch params.

+ +

To terminate a fetch controller +controller given a flag aborted, which is unset unless otherwise specified, +set controller's ongoing fetch params +terminated flag, and set controller's +ongoing fetch params aborted flag if +aborted is set. +

To queue a fetch task, given an algorithm algorithm, a global object or a parallel queue taskDestination, run these steps: @@ -2064,6 +2081,10 @@ known as an aborted network errorheader list is always empty, and body is always null. +

To create the appropriate network error given fetch params +fetchParams, return an aborted network error if fetchParams's +aborted flag is set, otherwise return a network error. +


A filtered response is a limited view on a @@ -3682,10 +3703,6 @@ accepting a response. If given, processResponseEndOfBody algorithm accepting a response and null, failure, or a byte sequence. If given, processResponseDone must be an algorithm accepting a response. -

An ongoing fetch can be -terminated with flag aborted, -which is unset unless otherwise specified. -

The user agent may be asked to suspend the ongoing fetch. The user agent may either accept or ignore the suspension request. The suspended fetch can be @@ -3740,6 +3757,14 @@ the request. cross-origin isolated capability is crossOriginIsolatedCapability. +

  • Let controller be a new fetch controller with its + ongoing fetch params set to fetchParams.

  • + +

    If this instance of fetch is + terminated given flag aborted, + which is unset unless otherwise specified, terminate + controller with aborted. +

  • If request's body is a byte sequence, then set request's body to the first return value of safely extracting request's body. @@ -3821,6 +3846,8 @@ the request.

  • Run main fetch given fetchParams. + +

  • Return controller. @@ -4266,16 +4293,8 @@ steps:

  • Return response. -

  • -

    If aborted, then: - -

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

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

    3. Return a network error. -

    +
  • If aborted, then return the appropriate network error for + fetchParams.

  • "data" @@ -5004,16 +5023,9 @@ steps. They return a response. -
  • -

    If aborted, then: +

  • If aborted, then return the appropriate network error for + fetchParams.

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

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

    3. Return a network error. -

  • @@ -5106,16 +5118,8 @@ steps. They return a response. isAuthenticationFetch is true, then:
      -
    1. -

      If the ongoing fetch is terminated, then: - -

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

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

      3. Return a network error. -

      +
    2. If fetchParams's terminated flag is set, then + return the appropriate network error for fetchParams.

    3. Let username and password be the result of prompting the end user for a username and password, respectively, in request's @@ -5142,16 +5146,8 @@ steps. They return a response.

    4. Needs testing: multiple `Proxy-Authenticate` headers, missing, parsing issues. -

    5. -

      If the ongoing fetch is terminated, then: - -

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

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

      3. Return a network error. -

      +
    6. If fetchParams's terminated flag is set, then + return the appropriate network error for fetchParams.

    7. Prompt the end user as appropriate in request's @@ -5180,16 +5176,8 @@ steps. They return a response.

      then:

        -
      1. -

        If the ongoing fetch is terminated, then: - -

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

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

        3. Return a network error. -

        +
      2. If fetchParams's terminated flag is set, then + return the appropriate network error for fetchParams.

      3. Set response to the result of running HTTP-network-or-cache fetch given fetchParams, isAuthenticationFetch, and true. @@ -5246,7 +5234,8 @@ optional boolean forceNewConnection (default false), run these steps:

      4. -

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

        Run these steps, but abort when fetchParams's + terminated flag is set:

        1. If connection is failure, then return a network error. @@ -5348,7 +5337,8 @@ optional boolean forceNewConnection (default false), run these steps:

          Let processBodyChunk given bytes be these steps:

            -
          1. If the ongoing fetch is terminated, then abort these steps. +

          2. If fetchParams's terminated flag is set, then + abort these steps.

          3. Run this step in parallel: transmit bytes. @@ -5361,7 +5351,8 @@ optional boolean forceNewConnection (default false), run these steps:

            Let processEndOfBody be these steps:

              -
            1. If the ongoing fetch is terminated, then abort these steps. +

            2. If fetchParams's terminated flag is set, then + abort these steps.

            3. If fetchParams's process request end-of-body is non-null, then run fetchParams's @@ -5372,7 +5363,8 @@ optional boolean forceNewConnection (default false), run these steps:

              Let processBodyError given e be these steps:

                -
              1. If the ongoing fetch is terminated, then abort these steps. +

              2. If fetchParams's terminated flag is set, then + abort these steps.

              3. If e is an "AbortError" {{DOMException}}, then terminate the ongoing fetch with the aborted flag set. @@ -5394,7 +5386,8 @@ optional boolean forceNewConnection (default false), run these steps:

                If aborted, then:

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

                2. Let aborted be fetchParams's + aborted flag.

                3. If connection uses HTTP/2, then transmit an RST_STREAM frame. @@ -5423,7 +5416,8 @@ optional boolean forceNewConnection (default false), run these steps: sizeAlgorithm set to sizeAlgorithm.

                4. -

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

                  Run these steps, but abort when fetchParams's + terminated flag is set:

                  1. Set response's body to a new @@ -5452,7 +5446,8 @@ optional boolean forceNewConnection (default false), run these steps:

                    If aborted, then:

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

                    2. Let aborted be fetchParams's + aborted flag.

                    3. If aborted is set, then set response's aborted flag. @@ -5465,7 +5460,8 @@ optional boolean forceNewConnection (default false), run these steps:

                      1. -

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

                        Run these steps, but abort when fetchParams's + terminated flag is set:

                        1. @@ -5520,7 +5516,8 @@ optional boolean forceNewConnection (default false), run these steps:
                          1. Finalize response for fetchParams and response. -
                          2. Let aborted be the termination's aborted flag. +

                          3. Let aborted be fetchParams's + aborted flag.

                          4. If aborted is set, then: