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; } +
+spec:streams; type:dfn; + text:closed + text:errored + text:need more data + text:readable + text:disturbed + text:locked + text:cancel ++
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.
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.
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: - -
Let chunk be a {{Uint8Array}} object wrapping an {{ArrayBuffer}} object - containing bytes. If that threw an exception, error stream - with that exception and return.
Call - ReadableStreamDefaultControllerEnqueue(stream.\[[readableStreamController]], - chunk). -
To close a -{{ReadableStream}} object stream, run these steps: - -
Call - ReadableStreamDefaultControllerClose(stream.\[[readableStreamController]]). -
To error a -{{ReadableStream}} object stream with given reason, run these steps: - -
Call - ReadableStreamDefaultControllerError(stream.\[[readableStreamController]]), - reason). -
To
-construct a ReadableStream
object
-optionally with a highWaterMark, sizeAlgorithm algorithm, pull
-action, and cancel action, run these steps:
-
-
Let startAlgorithm be an algorithm that returns undefined. - -
If pull is not given, then set it to an action that does nothing. - -
Let pullAlgorithm be an algorithm that runs these steps: - -
Run pull. - -
Return a promise resolved with undefined. -
If cancel is not given, then set it to an action that does nothing. - -
Let cancelAlgorithm be an algorithm that runs these steps: - -
Run cancel. - -
Return a promise resolved with undefined. -
If highWaterMark is not given, then set it to 1. - -
If sizeAlgorithm is not given, then set it to an algorithm that returns 1. - -
Return [$CreateReadableStream$](startAlgorithm, pullAlgorithm, - cancelAlgorithm, highWaterMark, sizeAlgorithm). -
To get a reader from a -{{ReadableStream}} object stream, run these steps: - -
Let reader be the result of calling - AcquireReadableStreamDefaultReader(stream). - -
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: - -
Let promise be a new promise. - -
Let bytes be an empty byte sequence. - -
Read-loop given reader, bytes, and promise. - -
Return promise. -
To read-loop given reader, bytes, and promise: - -
Let readRequest be a new read request with the following - items: - -
Assert: chunk is a {{Uint8Array}} object. - -
Append chunk to bytes. - -
Read-loop given reader, bytes, and promise. -
Resolve promise with bytes.
Reject promise with e. -
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: - -
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: - -
stream is readable. - -
The result of calling - ReadableStreamDefaultControllerGetDesiredSize(stream.\[[readableStreamController]]) - is positive. -
A {{ReadableStream}} object stream is said to be -disturbed -if the result of calling -IsReadableStreamDisturbed(stream) is true. - -
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 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
Set response's aborted flag. -
If stream is readable, error
- stream with an "AbortError
" {{DOMException}}.
+
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:
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}}.
Let Content-Type be null. @@ -5741,10 +5564,10 @@ these steps:
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. -
When running action is done, close stream. +
When running action is done, close stream.
Let body be a body whose stream is @@ -5888,13 +5711,12 @@ the associated steps:
Let reader be the result of - getting a reader from stream. If that - threw an exception, then return a promise rejected with that exception. +
Let reader be the result of getting a reader from + stream. If that threw an exception, then return a promise rejected with that + exception.
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: - -
Let ws and rs be the writable side and readable side - of an identity transform stream, respectively.
Let promise be the result of calling - ReadableStreamPipeTo(inputBody, ws, false, - false, false, undefined). - -
This makes inputBody's stream - locked and disturbed immediately. -
Set promise.\[[PromiseIsHandled]] to true. - -
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.