diff --git a/fetch.bs b/fetch.bs index 84fc66f3c..e4a08647d 100644 --- a/fetch.bs +++ b/fetch.bs @@ -92,6 +92,17 @@ url:https://tools.ietf.org/html/draft-ietf-httpbis-header-structure#section-4.2; } + +

Goals

@@ -1024,8 +1035,8 @@ user-agent-defined value for the body body, run these steps:
    -
  1. Let «out1, out2» be the result of - teeing body's stream. +

  2. Let « out1, out2 » be the result of teeing + body's stream.

  3. Set body's stream to out1. @@ -1662,8 +1673,8 @@ is to return the result of serializing a request origin with request process request end-of-body for request and abort these steps.

  4. -

    Let reader be the result of getting - a reader from body's stream. +

    Let reader be the result of getting a reader for + body's stream.

    This operation cannot throw an exception. @@ -1727,8 +1738,8 @@ is to return the result of serializing a request origin with request

-
  • Read a chunk from body's - stream with reader given readRequest. +

  • Read a chunk from reader given + readRequest.


    @@ -2315,196 +2326,6 @@ run these steps: -

    Streams

    - -

    This section might be integrated into other standards, such as -Streams itself. See -whatwg/streams#372. - -

    In this section, we define common operations for {{ReadableStream}} objects. [[!STREAMS]] - -

    To enqueue bytes, given a -byte sequence bytes and a {{ReadableStream}} object stream: - -

      -
    1. Let chunk be a {{Uint8Array}} object wrapping an {{ArrayBuffer}} object - containing bytes. If that threw an exception, error stream - with that exception and return.

    2. - -
    3. Call - ReadableStreamDefaultControllerEnqueue(stream.\[[readableStreamController]], - chunk). -

    - -

    To close a -{{ReadableStream}} object stream, run these steps: - -

      -
    1. Call - ReadableStreamDefaultControllerClose(stream.\[[readableStreamController]]). -

    - -

    To error a -{{ReadableStream}} object stream with given reason, run these steps: - -

      -
    1. Call - ReadableStreamDefaultControllerError(stream.\[[readableStreamController]]), - reason). -

    - -

    To -construct a ReadableStream object -optionally with a highWaterMark, sizeAlgorithm algorithm, pull -action, and cancel action, run these steps: - -

      -
    1. Let startAlgorithm be an algorithm that returns undefined. - -

    2. If pull is not given, then set it to an action that does nothing. - -

    3. -

      Let pullAlgorithm be an algorithm that runs these steps: - -

        -
      1. Run pull. - -

      2. Return a promise resolved with undefined. -

      - -
    4. If cancel is not given, then set it to an action that does nothing. - -

    5. -

      Let cancelAlgorithm be an algorithm that runs these steps: - -

        -
      1. Run cancel. - -

      2. Return a promise resolved with undefined. -

      - -
    6. If highWaterMark is not given, then set it to 1. - -

    7. If sizeAlgorithm is not given, then set it to an algorithm that returns 1. - -

    8. Return [$CreateReadableStream$](startAlgorithm, pullAlgorithm, - cancelAlgorithm, highWaterMark, sizeAlgorithm). -

    - -

    To get a reader from a -{{ReadableStream}} object stream, run these steps: - -

      -
    1. Let reader be the result of calling - AcquireReadableStreamDefaultReader(stream). - -

    2. Return reader. -

    - -

    To -read a chunk from a -{{ReadableStream}} object with reader, given a read request -readRequest, perform -ReadableStreamDefaultReaderRead(reader, readRequest). - -

    To -read all bytes -from a {{ReadableStream}} object with reader, run these steps: - -

      -
    1. Let promise be a new promise. - -

    2. Let bytes be an empty byte sequence. - -

    3. Read-loop given reader, bytes, and promise. - -

    4. Return promise. -

    - -

    To read-loop given reader, bytes, and promise: - -

      -
    1. -

      Let readRequest be a new read request with the following - items: - -

      -
      chunk steps, given chunk -
      -
        -
      1. Assert: chunk is a {{Uint8Array}} object. - -

      2. Append chunk to bytes. - -

      3. Read-loop given reader, bytes, and promise. -

      - -
      close steps -
      -
        -
      1. Resolve promise with bytes.

      2. -
      - -
      error steps, given e -
      -
        -
      1. Reject promise with e. -

      -
      - -
    2. Perform ReadableStreamDefaultReaderRead(reader, - readRequest). -

    - -

    Because the reader grants exclusive access, the actual mechanism of how -to read cannot be observed. Implementations could use more direct mechanism if convenient. - -

    To cancel a -{{ReadableStream}} object stream with reason, return the result of calling -ReadableStreamCancel(stream, reason). - -

    To tee a {{ReadableStream}} -object stream, run these steps: - -

      -
    1. Return the result of calling ReadableStreamTee(stream, true). -

    - -

    A {{ReadableStream}} object stream is said to be -readable if -stream.\[[state]] is "readable". - -

    A {{ReadableStream}} object stream is said to be -closed if -stream.\[[state]] is "closed". - -

    A {{ReadableStream}} object stream is said to be -errored if -stream.\[[state]] is "errored". - -

    A {{ReadableStream}} object stream is said to be -locked if the -result of calling IsReadableStreamLocked(stream) is -true. - -

    A {{ReadableStream}} object stream is said to -need more data -if the following conditions hold: - -

    - -

    A {{ReadableStream}} object stream is said to be -disturbed -if the result of calling -IsReadableStreamDisturbed(stream) is true. - -

    HTTP extensions

    @@ -4897,22 +4718,23 @@ Range Requests. [[HTTP-RANGE]] However, this is not widely supported by b
  • Return a network error. +

  • Let pullAlgorithm be an action that resumes the + ongoing fetch if it is suspended. + +

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

  • Let highWaterMark be a non-negative, non-NaN number, chosen by the user agent.

  • Let sizeAlgorithm be an algorithm that accepts a chunk object and returns a non-negative, non-NaN, non-infinite number, chosen by the user agent. -

  • Let pull be an action that resumes the ongoing fetch - if it is suspended. - -

  • Let cancel be an action that terminates the - ongoing fetch with the aborted flag set. - -

  • -

    Let stream be the result of constructing a ReadableStream object - with highWaterMark, sizeAlgorithm, pull, and cancel. - -

    This construction operation will not throw an exception. +

  • Let stream be the result of creating a + {{ReadableStream}} with pullAlgorithm set to + pullAlgorithm, cancelAlgorithm set to + cancelAlgorithm, highWaterMark set to + highWaterMark, and sizeAlgorithm set to + sizeAlgorithm.

  • Run these steps, but abort when the ongoing fetch is terminated: @@ -4989,20 +4811,20 @@ Range Requests. [[HTTP-RANGE]] However, this is not widely supported by b

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

  • Enqueue bytes given bytes and - stream. +

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

  • If stream is errored, then terminate the ongoing fetch. -

  • If stream doesn't need more - data and request's synchronous flag is unset, ask the user agent to +

  • If stream doesn't need more data and + request's synchronous flag is unset, ask the user agent to suspend the ongoing fetch.

  • Otherwise, if the bytes transmission for response's message body is done normally and stream is readable, then - close stream and abort these in-parallel steps. + close stream and abort these in-parallel steps. @@ -5018,12 +4840,13 @@ Range Requests. [[HTTP-RANGE]] However, this is not widely supported by b

    1. Set response's aborted flag. -

    2. If stream is readable, error - stream with an "AbortError" {{DOMException}}. +

    3. If stream is readable, + error stream with an + "AbortError" {{DOMException}}.

  • Otherwise, if stream is readable, - error stream with a {{TypeError}}. + error stream with a {{TypeError}}.

  • If connection uses HTTP/2, then transmit an RST_STREAM frame. @@ -5672,7 +5495,7 @@ these steps:

    1. Let stream be object if object is a {{ReadableStream}} - object; otherwise the result of constructing a ReadableStream object. + object; otherwise the result of creating a {{ReadableStream}}.

    2. Let Content-Type be null. @@ -5741,10 +5564,10 @@ these steps:

      1. Whenever one or more bytes are available and stream is not - errored, enqueue bytes given the available - bytes and stream. + errored, enqueue a {{Uint8Array}} wrapping an + {{ArrayBuffer}} containing the available bytes into stream. -

      2. When running action is done, close stream. +

      3. When running action is done, close stream.

    3. Let body be a body whose stream is @@ -5888,13 +5711,12 @@ the associated steps:

    4. Let stream be object's body's stream. -

    5. Let reader be the result of - getting a reader from stream. If that - threw an exception, then return a promise rejected with that exception. +

    6. Let reader be the result of getting a reader from + stream. If that threw an exception, then return a promise rejected with that + exception.

    7. Set promise to the result of - reading all bytes from stream with - reader. + reading all bytes from reader.

  • Let steps be to return the result of package data with the first argument @@ -6459,28 +6281,9 @@ constructor steps are: -

  • -

    If inputBody is body and inputBody is non-null, then: - -

      -
    1. Let ws and rs be the writable side and readable side - of an identity transform stream, respectively.

    2. - -
    3. -

      Let promise be the result of calling - ReadableStreamPipeTo(inputBody, ws, false, - false, false, undefined). - -

      This makes inputBody's stream - locked and disturbed immediately. -

    4. - -
    5. Set promise.\[[PromiseIsHandled]] to true. - -

    6. Set body to a new body whose stream is - rs, whose source is inputBody's source, and - whose total bytes is inputBody's total bytes. -

    +
  • If inputBody is body and inputBody is non-null, then set + body to the result of creating a proxy for + inputBody.

  • Set this's request's body to body. @@ -6880,8 +6683,8 @@ method steps are:

  • Let response be responseObject's response.

  • If response's body is not null and is - readable, then error - response's body with error. + readable, then error response's + body with error.