From 925806a70826f8a11b6da3da03a17ba67571af3c Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Thu, 14 Oct 2021 17:17:28 +0300 Subject: [PATCH 01/16] Use controller for terminating --- fetch.bs | 122 +++++++++++++++++++++++++++---------------------------- 1 file changed, 60 insertions(+), 62 deletions(-) diff --git a/fetch.bs b/fetch.bs index afa26221d..2ddff693f 100644 --- a/fetch.bs +++ b/fetch.bs @@ -210,6 +210,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. @@ -260,6 +264,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: @@ -2104,6 +2121,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 @@ -3757,10 +3778,6 @@ an integer representing the number of bytes transmitted. If given, given, processResponseConsumeBody must be an algorithm accepting a response and null, failure, or a byte sequence. -

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 @@ -3816,6 +3833,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. @@ -3897,6 +3922,8 @@ the request.

  • Run main fetch given fetchParams. + +

  • Return controller. @@ -4385,16 +4412,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" @@ -5127,16 +5146,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. -

  • @@ -5232,16 +5244,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 @@ -5268,16 +5272,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 @@ -5306,16 +5302,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. @@ -5372,7 +5360,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. @@ -5474,7 +5463,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. @@ -5488,7 +5478,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 @@ -5499,7 +5490,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. @@ -5521,7 +5513,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. @@ -5550,7 +5543,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 @@ -5579,7 +5573,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. @@ -5592,7 +5587,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. @@ -5644,7 +5640,9 @@ 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: From f4d1a55ded02e192c1b326acb192f9e8885619b8 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Thu, 21 Oct 2021 18:13:08 +0300 Subject: [PATCH 02/16] Use enum instead of flag --- fetch.bs | 127 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 72 insertions(+), 55 deletions(-) diff --git a/fetch.bs b/fetch.bs index 2ddff693f..fff18e187 100644 --- a/fetch.bs +++ b/fetch.bs @@ -210,9 +210,8 @@ lt="authentication entry">authentication entries (for HTTP authentication).

                            cross-origin isolated capability (default false)
                            A boolean. -
                            terminated flag -
                            aborted flag -
                            A flag, initially unset. +
                            fetch state +
                            "ongoing", "terminated", or "aborted".
                            timing info
                            A fetch timing info. @@ -264,6 +263,15 @@ given a fetch timing info timingInfo, return a new storedTimingInfo's decoded body size.
                          +

                          To abort a fetch params fetchParams, +set fetchParams's fetch state to "aborted". + +

                          To terminate a fetch params fetchParams, +set fetchParams's fetch state to "terminated". + +

                          A fetch params fetchParams is terminated if +its fetch state is "aborted" or "terminated". +

                          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. @@ -271,11 +279,12 @@ to perform certain actions in the context of that fetch instance. 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. +controller, terminate controller's +ongoing fetch params. + +

                          To abort a fetch controller +controller, abort controller's +ongoing fetch params.

                          To queue a fetch task, given an algorithm algorithm, a global object or a parallel queue taskDestination, run these @@ -2123,7 +2132,8 @@ known as an aborted network errorTo 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. +fetch state is "aborted"; otherwise return a +network error.


                          @@ -2307,14 +2317,14 @@ functionality.

                          A fetch record has an associated fetch (a -fetch algorithm or null). +fetch controller or null).


                          When a fetch group is terminated, for each associated fetch record whose request's done flag is -unset or keepalive is false, terminate the +unset or keepalive is false, terminate fetch record's fetch. @@ -3839,7 +3849,13 @@ the request.

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

                          The above exported function is to be replaced by + terminating or + aborting the fetch controller + returned by this algorithm.

                        2. If request's body is a byte sequence, then set request's body to the first return value of @@ -3915,7 +3931,7 @@ the request.

                          1. Let record be a new fetch record consisting of - request and this instance of the fetch algorithm. + request and controller.

                          2. Append record to request's client's fetch group list of fetch records. @@ -4381,7 +4397,8 @@ steps:

                            1. -

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

                              Run these steps, but abort when fetchParams is + terminated:

                              1. Let blob be request's current URL's @@ -4480,10 +4497,11 @@ these steps:

                                Let transformAlgorithm given chunk be these steps:

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

                                2. If fetchParams's fetch state is not + "ongoing", then abort these steps.

                                3. If chunk is not a {{Uint8Array}} object, then - terminate the ongoing fetch. + terminate fetchParams.

                                4. Otherwise, enqueue chunk. The user agent may split the chunk into implementation-defined practical sizes and @@ -4812,7 +4830,8 @@ steps. They return a response.

                                5. Let the revalidatingFlag be unset.

                                6. -

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

                                  Run these steps, but abort when fetchParams is + terminated:

                                  1. If request's window is "no-window" and @@ -5244,8 +5263,8 @@ steps. They return a response. isAuthenticationFetch is true, then:

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

                                    2. +
                                    3. If fetchParams is terminated, then return the + appropriate network error for fetchParams.

                                    4. Let username and password be the result of prompting the end user for a username and password, respectively, in request's @@ -5272,7 +5291,7 @@ steps. They return a response.

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

                                    6. If fetchParams's terminated flag is set, then +

                                    7. If fetchParams is terminated, then return the appropriate network error for fetchParams.

                                    8. @@ -5302,7 +5321,7 @@ steps. They return a response.

                                      then:

                                        -
                                      1. If fetchParams's terminated flag is set, then +

                                      2. If fetchParams is terminated, then return the appropriate network error for fetchParams.

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

                                      4. -

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

                                        Run these steps, but abort when fetchParams is + terminated:

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

                                          Let processBodyChunk given bytes be these steps:

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

                                          2. If fetchParams is terminated, then abort these + steps.

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

                                            Let processEndOfBody be these steps:

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

                                            2. If fetchParams is terminated, then abort these + steps.

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

                                              Let processBodyError given e be these steps:

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

                                              2. If fetchParams is terminated, then abort these + steps.

                                              3. If e is an "AbortError" {{DOMException}}, - then terminate the ongoing fetch with the aborted flag set. + then abort fetchParams. -

                                              4. Otherwise, terminate the ongoing fetch. +

                                              5. Otherwise, terminate fetchParams.

                                            4. Incrementally read request's body given @@ -5513,21 +5532,15 @@ optional boolean forceNewConnection (default false), run these steps:

                                              If aborted, then:

                                                -
                                              1. Let aborted be fetchParams's - aborted flag. -

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

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

                                              4. Return a network error. +

                                              5. Return the appropriate network error for fetchParams.

                                            5. Let pullAlgorithm be an action that resumes the ongoing fetch if it is suspended. -

                                            6. Let cancelAlgorithm be an action that terminates - the ongoing fetch with the aborted flag set. +

                                            7. Let cancelAlgorithm be to abort fetchParams.

                                            8. Let highWaterMark be a non-negative, non-NaN number, chosen by the user agent. @@ -5543,8 +5556,8 @@ optional boolean forceNewConnection (default false), run these steps: sizeAlgorithm set to sizeAlgorithm.

                                            9. -

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

                                              Run these steps, but abort when fetchParams is + terminated:

                                              1. Set response's body to a new @@ -5573,10 +5586,10 @@ optional boolean forceNewConnection (default false), run these steps:

                                                If aborted, then:

                                                  -
                                                1. Let aborted be fetchParams's - aborted flag. +

                                                2. Let state be fetchParams's + fetch state. -

                                                3. If aborted is set, then set response's +

                                                4. If state is "aborted", then set response's aborted flag.

                                                5. Return response. @@ -5587,8 +5600,8 @@ optional boolean forceNewConnection (default false), run these steps:

                                                  1. -

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

                                                    Run these steps, but abort when fetchParams is + terminated:

                                                    1. @@ -5617,14 +5630,14 @@ optional boolean forceNewConnection (default false), run these steps:
                                                    2. Increase timingInfo's decoded body size by bytes's length. -

                                                    3. If bytes is failure, then terminate the - ongoing fetch. +

                                                    4. If bytes is failure, then terminate + fetchParams.

                                                    5. Enqueue a {{Uint8Array}} wrapping an {{ArrayBuffer}} containing bytes into stream.

                                                    6. If stream is errored, then - terminate the ongoing fetch. + terminate fetchParams.

                                                    7. If stream doesn't need more data ask the user agent to suspend the ongoing fetch. @@ -5641,11 +5654,11 @@ optional boolean forceNewConnection (default false), run these steps:

                                                        -
                                                      1. Let aborted be fetchParams's - aborted flag. +

                                                      2. Let state be fetchParams's + fetch state.

                                                      3. -

                                                        If aborted is set, then: +

                                                        If state is "aborted", then:

                                                        1. Set response's aborted flag. @@ -7571,6 +7584,8 @@ method steps are:

                                                          This lets us reject promises with predictable timing, when the request to abort comes from the same thread as the call to fetch. +

                                                        2. Let controller be null. +

                                                        3. Add the following abort steps to requestObject's signal: @@ -7580,7 +7595,8 @@ method steps are:

                                                        4. Abort fetch with p, request, and responseObject. -

                                                        5. Terminate the ongoing fetch with the aborted flag set. +

                                                        6. If controller is not null, then abort + controller.

                                                      4. Let handleFetchDone given response response be to @@ -7588,7 +7604,8 @@ method steps are: "fetch".

                                                      5. -

                                                        Fetch request with processResponseEndOfBody set to +

                                                        Set controller to the result of calling fetch given + request, with processResponseEndOfBody set to handleFetchDone, and processResponse given response being these substeps: @@ -7638,7 +7655,7 @@ method steps are:

                                                        Garbage collection

                                                        -

                                                        The user agent may terminate an ongoing fetch if that termination +

                                                        The user agent may terminate an ongoing fetch if that termination is not observable through script.

                                                        "Observable through script" means observable through From 643aaa128eee6e9a3ec74a5d37976a7e7fe7ff99 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Fri, 22 Oct 2021 15:33:49 +0300 Subject: [PATCH 03/16] Rename terminated to canceled, remove note --- fetch.bs | 54 +++++++++++++++++++----------------------------------- 1 file changed, 19 insertions(+), 35 deletions(-) diff --git a/fetch.bs b/fetch.bs index fff18e187..9885886a2 100644 --- a/fetch.bs +++ b/fetch.bs @@ -269,7 +269,7 @@ set fetchParams's fetch state to "abo

                                                        To terminate a fetch params fetchParams, set fetchParams's fetch state to "terminated". -

                                                        A fetch params fetchParams is terminated if +

                                                        A fetch params fetchParams is canceled if its fetch state is "aborted" or "terminated".

                                                        A fetch controller is an object used to enable clients of an ongoing fetch @@ -278,9 +278,9 @@ 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, terminate controller's -ongoing fetch params. +

                                                        To terminate a +fetch controller controller, terminate +controller's ongoing fetch params.

                                                        To abort a fetch controller controller, abort controller's @@ -3846,17 +3846,6 @@ the request.

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

                                                      7. -

                                                        If this instance of fetch is - terminated given flag aborted, - which is unset unless otherwise specified, terminate - controller if aborted is set, otherwise abort - controller. - -

                                                        The above exported function is to be replaced by - terminating or - aborting the fetch controller - returned by this algorithm. -

                                                      8. If request's body is a byte sequence, then set request's body to the first return value of safely extracting request's body. @@ -4398,7 +4387,7 @@ steps:

                                                        1. Run these steps, but abort when fetchParams is - terminated: + canceled:

                                                          1. Let blob be request's current URL's @@ -4831,7 +4820,7 @@ steps. They return a response.

                                                          2. Run these steps, but abort when fetchParams is - terminated: + canceled:

                                                            1. If request's window is "no-window" and @@ -5263,7 +5252,7 @@ steps. They return a response. isAuthenticationFetch is true, then:

                                                                -
                                                              1. If fetchParams is terminated, then return the +

                                                              2. If fetchParams is canceled, then return the appropriate network error for fetchParams.

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

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

                                                              5. If fetchParams is terminated, then +

                                                              6. If fetchParams is canceled, then return the appropriate network error for fetchParams.

                                                              7. @@ -5321,7 +5310,7 @@ steps. They return a response.

                                                                then:

                                                                  -
                                                                1. If fetchParams is terminated, then +

                                                                2. If fetchParams is canceled, then return the appropriate network error for fetchParams.

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

                                                                4. Run these steps, but abort when fetchParams is - terminated: + canceled:

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

                                                                    Let processBodyChunk given bytes be these steps:

                                                                      -
                                                                    1. If fetchParams is terminated, then abort these +

                                                                    2. If fetchParams is canceled, then abort these steps.

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

                                                                      Let processEndOfBody be these steps:

                                                                        -
                                                                      1. If fetchParams is terminated, then abort these +

                                                                      2. If fetchParams is canceled, then abort these steps.

                                                                      3. If fetchParams's process request end-of-body is @@ -5509,7 +5498,7 @@ optional boolean forceNewConnection (default false), run these steps:

                                                                        Let processBodyError given e be these steps:

                                                                          -
                                                                        1. If fetchParams is terminated, then abort these +

                                                                        2. If fetchParams is canceled, then abort these steps.

                                                                        3. If e is an "AbortError" {{DOMException}}, @@ -5557,7 +5546,7 @@ optional boolean forceNewConnection (default false), run these steps:

                                                                        4. Run these steps, but abort when fetchParams is - terminated: + canceled:

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

                                                                            If aborted, then:

                                                                              -
                                                                            1. Let state be fetchParams's - fetch state. - -

                                                                            2. If state is "aborted", then set response's - aborted flag. +

                                                                            3. If fetchParams's fetch state is + "aborted", then set response's aborted flag.

                                                                            4. Return response.

                                                                            @@ -5601,7 +5587,7 @@ optional boolean forceNewConnection (default false), run these steps:
                                                                            1. Run these steps, but abort when fetchParams is - terminated: + canceled:

                                                                              1. @@ -5654,11 +5640,9 @@ optional boolean forceNewConnection (default false), run these steps:
                                                                                  -
                                                                                1. Let state be fetchParams's - fetch state. -

                                                                                2. -

                                                                                  If state is "aborted", then: +

                                                                                  If fetchParams's fetch state is + "aborted", then:

                                                                                  1. Set response's aborted flag. From b634ecdadf810d6fe8df1db2d0c626aa0e281f8c Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Fri, 22 Oct 2021 15:41:24 +0300 Subject: [PATCH 04/16] Add some prose --- fetch.bs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fetch.bs b/fetch.bs index 9885886a2..5596172e0 100644 --- a/fetch.bs +++ b/fetch.bs @@ -269,7 +269,7 @@ set fetchParams's fetch state to "abo

                                                                                    To terminate a fetch params fetchParams, set fetchParams's fetch state to "terminated". -

                                                                                    A fetch params fetchParams is canceled if +

                                                                                    A fetch params fetchParams is canceled if its fetch state is "aborted" or "terminated".

                                                                                    A fetch controller is an object used to enable clients of an ongoing fetch @@ -8073,6 +8073,11 @@ in a parallel queue if useParallelQueue is as arguments will be invoked. Hopefully most standards will not need this. +

                                                                                    When invoked, the fetch operation returns a fetch controller. +The controller is used for performing actions on a fetch operation that has already started, +such as aborting the operation by the user or page logic, or +terminating it due to a browser-internal circumstance. +

                                                                                    Acknowledgments

                                                                                    From 2f5922c3299806bd2e916f5a4becd52adf473fd6 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Fri, 22 Oct 2021 15:51:03 +0300 Subject: [PATCH 05/16] nits --- fetch.bs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fetch.bs b/fetch.bs index 5596172e0..c52235233 100644 --- a/fetch.bs +++ b/fetch.bs @@ -2324,7 +2324,7 @@ functionality.

                                                                                    When a fetch group is terminated, for each associated fetch record whose request's done flag is -unset or keepalive is false, terminate +unset or keepalive is false, terminate the fetch record's fetch. @@ -4486,8 +4486,8 @@ these steps:

                                                                                    Let transformAlgorithm given chunk be these steps:

                                                                                      -
                                                                                    1. If fetchParams's fetch state is not - "ongoing", then abort these steps. +

                                                                                    2. If fetchParams is canceled, then abort these + steps.

                                                                                    3. If chunk is not a {{Uint8Array}} object, then terminate fetchParams. From 010c0d333141af5a6ed79941ec680b10182efda6 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Fri, 22 Oct 2021 15:52:57 +0300 Subject: [PATCH 06/16] nits --- fetch.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fetch.bs b/fetch.bs index c52235233..33c72ed61 100644 --- a/fetch.bs +++ b/fetch.bs @@ -278,7 +278,7 @@ 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 +

                                                                                      To terminate a fetch controller controller, terminate controller's ongoing fetch params. From 2014a3bad9173601da55e578f1085a4ec307a595 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Wed, 27 Oct 2021 19:39:45 +0300 Subject: [PATCH 07/16] Fix many CR comments --- fetch.bs | 44 +++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/fetch.bs b/fetch.bs index 33c72ed61..cb4894a84 100644 --- a/fetch.bs +++ b/fetch.bs @@ -210,7 +210,7 @@ lt="authentication entry">authentication entries (for HTTP authentication).

                                                                                      cross-origin isolated capability (default false)
                                                                                      A boolean. -
                                                                                      fetch state +
                                                                                      fetch state (default "ongoing")
                                                                                      "ongoing", "terminated", or "aborted".
                                                                                      timing info @@ -272,19 +272,19 @@ set fetchParams's fetch state to "ter

                                                                                      A fetch params fetchParams is canceled if its fetch state is "aborted" or "terminated". -

                                                                                      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 is a struct 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.

                                                                                      +internal fetch params.

                                                                                      To terminate a fetch controller controller, terminate -controller's ongoing fetch params. +controller's internal fetch params.

                                                                                      To abort a fetch controller controller, abort controller's -ongoing fetch params. +internal fetch params.

                                                                                      To queue a fetch task, given an algorithm algorithm, a global object or a parallel queue taskDestination, run these @@ -2131,9 +2131,15 @@ known as an aborted network errorbody is always null.

                                                                                      To create the appropriate network error given fetch params -fetchParams, return an aborted network error if fetchParams's -fetch state is "aborted"; otherwise return a -network error. +fetchParams: + +

                                                                                        +
                                                                                      1. Assert: fetchParams is canceled.

                                                                                      2. + +
                                                                                      3. Return an aborted network error if fetchParams's + fetch state is "aborted"; otherwise return a + network error. +


                                                                                      @@ -2316,16 +2322,18 @@ functionality. request).

                                                                                      A fetch record has an associated -fetch (a +controller (a fetch controller or null).


                                                                                      When a fetch group is terminated, for each associated -fetch record whose request's done flag is -unset or keepalive is false, terminate the -fetch record's fetch. +fetch record whose +fetch record's controller is not null, and whose +request's done flag is unset or keepalive is +false, terminate the fetch record's +controller.

                                                                                      Resolving domains

                                                                                      @@ -3844,7 +3852,7 @@ the request. crossOriginIsolatedCapability.
                                                                                    4. Let controller be a new fetch controller with its - ongoing fetch params set to fetchParams.

                                                                                    5. + internal fetch params set to fetchParams.

                                                                                    6. If request's body is a byte sequence, then set request's body to the first return value of @@ -3919,8 +3927,9 @@ the request.

                                                                                      If request is a subresource request, then:

                                                                                        -
                                                                                      1. Let record be a new fetch record consisting of - request and controller. +

                                                                                      2. Let record be a new fetch record whose + request is request and + controller is controller.

                                                                                      3. Append record to request's client's fetch group list of fetch records. @@ -5529,7 +5538,8 @@ optional boolean forceNewConnection (default false), run these steps:

                                                                                      4. Let pullAlgorithm be an action that resumes the ongoing fetch if it is suspended. -

                                                                                      5. Let cancelAlgorithm be to abort fetchParams. +

                                                                                      6. Let cancelAlgorithm be an algorithm that + aborts fetchParams.

                                                                                      7. Let highWaterMark be a non-negative, non-NaN number, chosen by the user agent. From a04508934c17beed15f26675ac2411b0a893ff55 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Tue, 2 Nov 2021 15:29:09 +0200 Subject: [PATCH 08/16] Invert controller to include only state --- fetch.bs | 88 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/fetch.bs b/fetch.bs index cb4894a84..d67e25c91 100644 --- a/fetch.bs +++ b/fetch.bs @@ -210,13 +210,36 @@ lt="authentication entry">authentication entries (for HTTP authentication).

                                                                                        cross-origin isolated capability (default false)
                                                                                        A boolean. -
                                                                                        fetch state (default "ongoing") -
                                                                                        "ongoing", "terminated", or "aborted". +
                                                                                        controller (default a new fetch controller) +
                                                                                        A fetch controller.
                                                                                        timing info
                                                                                        A fetch timing info. +

                                                                                        A fetch controller is a struct used to enable callers of +fetch to perform certain operations on it after it has started. It has the following +items: + +

                                                                                        +
                                                                                        state (default "ongoing") +
                                                                                        "ongoing", "terminated", or "aborted" +
                                                                                        + +

                                                                                        To abort a fetch controller controller, +set controller's state to "aborted". + +

                                                                                        To terminate a fetch controller controller, +set controller's state to "terminated". + +

                                                                                        A fetch params fetchParams is aborted if +its controller's state is +"aborted". + +

                                                                                        A fetch params fetchParams is canceled if +its controller's state is +"aborted" or "terminated". +

                                                                                        A fetch timing info is a struct used to maintain timing information needed by Resource Timing and Navigation Timing. It has the following items: [[RESOURCE-TIMING]] [[NAVIGATION-TIMING]] @@ -263,29 +286,6 @@ given a fetch timing info timingInfo, return a new storedTimingInfo's decoded body size.

                                                                                      -

                                                                                      To abort a fetch params fetchParams, -set fetchParams's fetch state to "aborted". - -

                                                                                      To terminate a fetch params fetchParams, -set fetchParams's fetch state to "terminated". - -

                                                                                      A fetch params fetchParams is canceled if -its fetch state is "aborted" or "terminated". - -

                                                                                      A fetch controller is a struct 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 -internal fetch params.

                                                                                      - -

                                                                                      To terminate a -fetch controller controller, terminate -controller's internal fetch params. - -

                                                                                      To abort a fetch controller -controller, abort controller's -internal fetch params. -

                                                                                      To queue a fetch task, given an algorithm algorithm, a global object or a parallel queue taskDestination, run these steps: @@ -2136,9 +2136,8 @@ known as an aborted network error

                                                                                    7. Assert: fetchParams is canceled.

                                                                                    8. -
                                                                                    9. Return an aborted network error if fetchParams's - fetch state is "aborted"; otherwise return a - network error. +

                                                                                    10. Return an aborted network error if fetchParams is + aborted; otherwise return a network error.


                                                                                    @@ -3851,9 +3850,6 @@ the request. cross-origin isolated capability is crossOriginIsolatedCapability. -
                                                                                  2. Let controller be a new fetch controller with its - internal fetch params set to fetchParams.

                                                                                  3. -
                                                                                  4. If request's body is a byte sequence, then set request's body to the first return value of safely extracting request's body. @@ -3929,7 +3925,8 @@ the request.

                                                                                    1. Let record be a new fetch record whose request is request and - controller is controller. + controller is fetchParams's + controller.

                                                                                    2. Append record to request's client's fetch group list of fetch records. @@ -3937,7 +3934,7 @@ the request.

                                                                                    3. Run main fetch given fetchParams. -

                                                                                    4. Return controller. +

                                                                                    5. Return fetchParams's controller.

                                                                                    @@ -4499,7 +4496,8 @@ these steps: steps.
                                                                                  5. If chunk is not a {{Uint8Array}} object, then - terminate fetchParams. + terminate fetchParams's + controller.

                                                                                  6. Otherwise, enqueue chunk. The user agent may split the chunk into implementation-defined practical sizes and @@ -5511,9 +5509,11 @@ optional boolean forceNewConnection (default false), run these steps: steps.

                                                                                  7. If e is an "AbortError" {{DOMException}}, - then abort fetchParams. + then abort fetchParams's + controller. -

                                                                                  8. Otherwise, terminate fetchParams. +

                                                                                  9. Otherwise, terminate fetchParams's + controller.

                                                                                3. Incrementally read request's body given @@ -5539,7 +5539,7 @@ optional boolean forceNewConnection (default false), run these steps: ongoing fetch if it is suspended.

                                                                                4. Let cancelAlgorithm be an algorithm that - aborts fetchParams. + aborts fetchParams's controller.

                                                                                5. Let highWaterMark be a non-negative, non-NaN number, chosen by the user agent. @@ -5585,8 +5585,8 @@ optional boolean forceNewConnection (default false), run these steps:

                                                                                  If aborted, then:

                                                                                    -
                                                                                  1. If fetchParams's fetch state is - "aborted", then set response's aborted flag. +

                                                                                  2. If fetchParams is aborted, then set + response's aborted flag.

                                                                                  3. Return response.

                                                                                  @@ -5626,14 +5626,15 @@ optional boolean forceNewConnection (default false), run these steps:
                                                                                6. Increase timingInfo's decoded body size by bytes's length. -

                                                                                7. If bytes is failure, then terminate - fetchParams. +

                                                                                8. If bytes is failure, then terminate + fetchParams's controller.

                                                                                9. Enqueue a {{Uint8Array}} wrapping an {{ArrayBuffer}} containing bytes into stream.

                                                                                10. If stream is errored, then - terminate fetchParams. + terminate fetchParams.'s + controller.

                                                                                11. If stream doesn't need more data ask the user agent to suspend the ongoing fetch. @@ -5651,8 +5652,7 @@ optional boolean forceNewConnection (default false), run these steps:

                                                                                  1. -

                                                                                    If fetchParams's fetch state is - "aborted", then: +

                                                                                    If fetchParams is aborted, then:

                                                                                    1. Set response's aborted flag. From 3402759d6599212a0428a41fcaad7b432f4df856 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Wed, 17 Nov 2021 18:49:43 +0200 Subject: [PATCH 09/16] Pass controller to SW --- fetch.bs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fetch.bs b/fetch.bs index d67e25c91..70f16c1f2 100644 --- a/fetch.bs +++ b/fetch.bs @@ -4521,7 +4521,9 @@ these steps: given fetchParams's cross-origin isolated capability.

                                                                                    2. Set response to the result of invoking handle fetch for - requestForServiceWorker. [[!HTML]] [[!SW]] + requestForServiceWorker, with fetchParams's + cross-origin isolated capability and fetchParams's + controller. [[!HTML]] [[!SW]]

                                                                                    3. If response is not null, then: From ec4c5431d41d11f7aac902ab27ae1da9b74b0082 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Fri, 19 Nov 2021 14:57:53 +0200 Subject: [PATCH 10/16] Switch up order of parameters --- fetch.bs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fetch.bs b/fetch.bs index 70f16c1f2..e6eb6d834 100644 --- a/fetch.bs +++ b/fetch.bs @@ -4522,8 +4522,8 @@ these steps:

                                                                                    4. Set response to the result of invoking handle fetch for requestForServiceWorker, with fetchParams's - cross-origin isolated capability and fetchParams's - controller. [[!HTML]] [[!SW]] + controller and fetchParams's + cross-origin isolated capability and . [[!HTML]] [[!SW]]

                                                                                    5. If response is not null, then: From 8be225f50ec3427ac7ac030cd814f4e5b2d2221c Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Mon, 14 Feb 2022 15:37:31 +0200 Subject: [PATCH 11/16] Update fetch.bs Co-authored-by: Anne van Kesteren --- fetch.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fetch.bs b/fetch.bs index e6eb6d834..fdd9a9e0a 100644 --- a/fetch.bs +++ b/fetch.bs @@ -2134,7 +2134,7 @@ known as an aborted network errorfetchParams:

                                                                                        -
                                                                                      1. Assert: fetchParams is canceled.

                                                                                      2. +
                                                                                      3. Assert: fetchParams is canceled.

                                                                                      4. Return an aborted network error if fetchParams is aborted; otherwise return a network error. From 6a9f4d02bf51e3103752644bafbf9a8374a0616c Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Mon, 14 Feb 2022 15:37:45 +0200 Subject: [PATCH 12/16] Update fetch.bs Co-authored-by: Anne van Kesteren --- fetch.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fetch.bs b/fetch.bs index fdd9a9e0a..32c49a15e 100644 --- a/fetch.bs +++ b/fetch.bs @@ -5541,7 +5541,7 @@ optional boolean forceNewConnection (default false), run these steps: ongoing fetch if it is suspended.

                                                                                      5. Let cancelAlgorithm be an algorithm that - aborts fetchParams's controller. + aborts fetchParams's controller.

                                                                                      6. Let highWaterMark be a non-negative, non-NaN number, chosen by the user agent. From 06fe6b99b8ed38cdf0947f1ae00bc382efea0fd7 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Mon, 14 Feb 2022 15:40:35 +0200 Subject: [PATCH 13/16] Update fetch.bs Co-authored-by: Anne van Kesteren --- fetch.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fetch.bs b/fetch.bs index 32c49a15e..695a3fe6a 100644 --- a/fetch.bs +++ b/fetch.bs @@ -4523,7 +4523,7 @@ these steps:

                                                                                      7. Set response to the result of invoking handle fetch for requestForServiceWorker, with fetchParams's controller and fetchParams's - cross-origin isolated capability and . [[!HTML]] [[!SW]] + cross-origin isolated capability. [[!HTML]] [[!SW]]

                                                                                      8. If response is not null, then: From 7899e798af47fa9ea5ed169447b5cb18bc3b902b Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Mon, 14 Feb 2022 15:41:41 +0200 Subject: [PATCH 14/16] Fix lt --- fetch.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fetch.bs b/fetch.bs index 695a3fe6a..b557b0a73 100644 --- a/fetch.bs +++ b/fetch.bs @@ -8088,7 +8088,7 @@ in a parallel queue if useParallelQueue is

                                                                                        When invoked, the fetch operation returns a fetch controller. The controller is used for performing actions on a fetch operation that has already started, such as aborting the operation by the user or page logic, or -terminating it due to a browser-internal circumstance. +terminating it due to a browser-internal circumstance.

                                                                                        Acknowledgments

                                                                                        From 445af05f56602d500b5fb9d8e532dacef77465d2 Mon Sep 17 00:00:00 2001 From: Jake Archibald Date: Thu, 10 Mar 2022 09:56:16 +0000 Subject: [PATCH 15/16] kicking build From dc7f07cb5fa652a56730d22436d356b3a7f45e39 Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Fri, 11 Mar 2022 11:11:37 +0100 Subject: [PATCH 16/16] formatting nits --- fetch.bs | 53 ++++++++++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/fetch.bs b/fetch.bs index b557b0a73..2d9713621 100644 --- a/fetch.bs +++ b/fetch.bs @@ -226,11 +226,13 @@ lt="authentication entry">authentication entries (for HTTP authentication).
                                                                                        "ongoing", "terminated", or "aborted" -

                                                                                        To abort a fetch controller controller, -set controller's state to "aborted". +

                                                                                        To abort a fetch controller +controller, set controller's state to +"aborted". -

                                                                                        To terminate a fetch controller controller, -set controller's state to "terminated". +

                                                                                        To terminate a fetch controller +controller, set controller's state to +"terminated".

                                                                                        A fetch params fetchParams is aborted if its controller's state is @@ -2134,7 +2136,7 @@ known as an aborted network errorfetchParams:

                                                                                          -
                                                                                        1. Assert: fetchParams is canceled.

                                                                                        2. +
                                                                                        3. Assert: fetchParams is canceled.

                                                                                        4. Return an aborted network error if fetchParams is aborted; otherwise return a network error. @@ -2328,10 +2330,10 @@ functionality.

                                                                                          When a fetch group is terminated, for each associated -fetch record whose -fetch record's controller is not null, and whose -request's done flag is unset or keepalive is -false, terminate the fetch record's +fetch record whose fetch record's +controller is not null, and whose request's +done flag is unset or keepalive is false, +terminate the fetch record's controller. @@ -3924,9 +3926,8 @@ the request.

                                                                                          1. Let record be a new fetch record whose - request is request and - controller is fetchParams's - controller. + request is request and controller + is fetchParams's controller.

                                                                                          2. Append record to request's client's fetch group list of fetch records. @@ -4425,7 +4426,7 @@ steps:

                                                                                        5. If aborted, then return the appropriate network error for - fetchParams.

                                                                                        6. + fetchParams.
                                                                                        "data" @@ -5164,7 +5165,7 @@ steps. They return a response.
                                                                                    6. If aborted, then return the appropriate network error for - fetchParams.

                                                                                    7. + fetchParams. @@ -5262,7 +5263,7 @@ steps. They return a response.
                                                                                      1. If fetchParams is canceled, then return the - appropriate network error for fetchParams.

                                                                                      2. + 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 @@ -5289,8 +5290,8 @@ steps. They return a response.

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

                                                                                      5. If fetchParams is canceled, then - return the appropriate network error for fetchParams.

                                                                                      6. +
                                                                                      7. If fetchParams is canceled, then return the + appropriate network error for fetchParams.

                                                                                      8. Prompt the end user as appropriate in request's @@ -5319,8 +5320,8 @@ steps. They return a response.

                                                                                        then:

                                                                                          -
                                                                                        1. If fetchParams is canceled, then - return the appropriate network error for fetchParams.

                                                                                        2. +
                                                                                        3. If fetchParams is canceled, then return the + appropriate network error for fetchParams.

                                                                                        4. Set response to the result of running HTTP-network-or-cache fetch given fetchParams, isAuthenticationFetch, and true. @@ -5537,11 +5538,11 @@ optional boolean forceNewConnection (default false), run these steps:

                                                                                        5. Return the appropriate network error for fetchParams.

                                                                                        -
                                                                                      9. Let pullAlgorithm be an action that resumes the +

                                                                                      10. Let pullAlgorithm be an algorithm that resumes the ongoing fetch if it is suspended. -

                                                                                      11. Let cancelAlgorithm be an algorithm that - aborts fetchParams's controller. +

                                                                                      12. Let cancelAlgorithm be an algorithm that aborts + fetchParams's controller.

                                                                                      13. Let highWaterMark be a non-negative, non-NaN number, chosen by the user agent. @@ -8017,6 +8018,7 @@ resource — for non-CORS requests as well as CORS requests — and do not use `Vary`. +

                                                                                        Using fetch in other standards

                                                                                        In its essence fetching is an exchange of a request for a @@ -8085,12 +8087,13 @@ in a parallel queue if useParallelQueue is as arguments will be invoked. Hopefully most standards will not need this. -

                                                                                        When invoked, the fetch operation returns a fetch controller. -The controller is used for performing actions on a fetch operation that has already started, -such as aborting the operation by the user or page logic, or +

                                                                                        When invoked, the fetch operation returns a fetch controller. The +controller is used for performing actions on a fetch operation that has already started, such as +aborting the operation by the user or page logic, or terminating it due to a browser-internal circumstance. +

                                                                                        Acknowledgments

                                                                                        Thanks to