diff --git a/fetch.bs b/fetch.bs index a317c5166..b836c9fda 100644 --- a/fetch.bs +++ b/fetch.bs @@ -1090,11 +1090,12 @@ outlawing forbidden methods and forbidden header names.
A request has an associated -body (null or a +body (null, a byte sequence, or a body). Unless stated otherwise it is null. -
This can be updated during redirects to null as described in -HTTP fetch. +
A byte sequence will be safely extracted +into a body early on in fetch. As part of HTTP fetch it is possible +for this field to be set to null due to certain redirects.
In this section, we define common operations for {{ReadableStream}} objects. [[!STREAMS]] -
To enqueue -chunk into a {{ReadableStream}} object stream, run these steps: +
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). @@ -2355,7 +2360,7 @@ run these steps:
To
-construct a ReadableStream
object
+construct a ReadableStream
object
optionally with a highWaterMark, sizeAlgorithm algorithm, pull
action, and cancel action, run these steps:
@@ -2392,23 +2397,6 @@ action, and cancel action, run these steps:
cancelAlgorithm, highWaterMark, sizeAlgorithm).
-
To
-construct a fixed ReadableStream
object
-with given chunks, run these steps:
-
-
Let stream be the result of - constructing a {{ReadableStream}} - object. - -
For each chunk in chunks, enqueue - chunk into stream. - -
Close stream. - -
To get a reader from a {{ReadableStream}} object stream, run these steps: @@ -2488,13 +2476,6 @@ object stream, run these steps:
Return the result of calling ReadableStreamTee(stream, true). -
An empty {{ReadableStream}} -object is the result of constructing a fixed -{{ReadableStream}} object with an empty list. - -
Constructing an empty {{ReadableStream}} object will not throw an -exception. -
A {{ReadableStream}} object stream is said to be readable if stream.\[[state]] is "readable". @@ -3435,6 +3416,16 @@ the request.
Run these steps, but abort when the ongoing fetch is terminated:
If request's body is a byte sequence, then: + +
Let body and ignoreType be the result of + safely extracting request's body. + +
Set request's body to body. +
If request's window is
"client
", set request's
window to request's
@@ -4925,10 +4916,8 @@ Range Requests. [[HTTP-RANGE]] However, this is not widely supported by b
ongoing fetch with the aborted flag set.
Let stream be the result of - constructing a {{ReadableStream}} - object with highWaterMark, sizeAlgorithm, pull, and - cancel. +
Let stream be the result of constructing a ReadableStream
object
+ with highWaterMark, sizeAlgorithm, pull, and cancel.
This construction operation will not throw an exception. @@ -5007,10 +4996,11 @@ Range Requests. [[HTTP-RANGE]] However, this is not widely supported by b
If bytes is failure, then terminate the ongoing fetch. -
Enqueue a Uint8Array
object wrapping an
- ArrayBuffer
containing bytes to stream. If that threw an
- exception, terminate the ongoing fetch, and
- error stream with that exception.
+
Enqueue bytes given bytes and + stream. + +
If stream doesn't need more data and request's synchronous flag is unset, ask the user agent to @@ -5659,7 +5649,7 @@ method steps are: sort and combine with this's header list. -
typedef (Blob or BufferSource or FormData or URLSearchParams or USVString) XMLHttpRequestBodyInit; @@ -5686,21 +5676,22 @@ typedef (ReadableStream or XMLHttpRequestBodyInit) BodyInit;
To extract a body and a
`Content-Type
` value from
-object, with an optional keepalive flag, run these steps:
+object, with an optional boolean keepalive (default false), run
+these steps:
Let stream be the result of - constructing a - {{ReadableStream}} object. +
Let stream be object if object is a {{ReadableStream}}
+ object; otherwise the result of constructing a ReadableStream
object.
Let Content-Type be null.
Let action be null. -
Let source be null. +
Let source be null if object is a {{ReadableStream}} object; otherwise + object.
Switch on object's type: +
Switch on object:
If object's {{Blob/type}} attribute is not the empty byte sequence, set Content-Type to its value. -
Set source to object. +
Set action to an action that returns object.
BufferSource
- Enqueue a Uint8Array
object
- wrapping an ArrayBuffer
containing a copy of the bytes held by object
- to stream and close
- stream. If that threw an exception,
- error stream with that exception.
-
-
Set source to object. +
Set action to an action that returns a + copy of the bytes held by object.
multipart/form-data
boundary string generated by the
multipart/form-data
encoding algorithm.
- Set source to object. -
Set action to an action that runs the @@ -5747,39 +5731,29 @@ typedef (ReadableStream or XMLHttpRequestBodyInit) BodyInit;
Set Content-Type to
`application/x-www-form-urlencoded;charset=UTF-8
`.
-
Set source to object. - -
USVString
+ Set action to an action that runs UTF-8 encode on object.
Set Content-Type to `text/plain;charset=UTF-8
`.
-
Set source to object. -
If the keepalive flag is set, then throw a {{TypeError}}. +
If keepalive is true, then throw a {{TypeError}}.
If object is disturbed or locked, then throw a {{TypeError}}. - -
Set stream to object.
If action is non-null, run action in parallel:
Whenever one or more bytes are available, let bytes be the bytes and
- enqueue a Uint8Array
object
- wrapping an ArrayBuffer
containing bytes to stream. If
- creating the ArrayBuffer
threw an exception,
- error stream with that exception
- and cancel running action.
-
-
When running action is done, - close stream. +
Whenever one or more bytes are available and stream is not + errored, enqueue bytes given the available + bytes and stream. + +
When running action is done, close stream.
Let body be a body whose stream is @@ -5789,6 +5763,8 @@ typedef (ReadableStream or XMLHttpRequestBodyInit) BodyInit;
interface mixin Body { readonly attribute ReadableStream? body; @@ -5911,17 +5887,24 @@ the associated steps:
If object is disturbed or locked, then return a promise rejected with a {{TypeError}}. -
Let stream be object's body's stream - if object's body is non-null; otherwise an empty - {{ReadableStream}} object. +
Let promise be a promise resolved with an empty + byte sequence. -
Let reader be the result of - getting a reader from stream. If that threw - an exception, return a promise rejected with that exception. +
If object's body is non-null, then: -
Let promise be the result of - reading all bytes from stream with - reader. +
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. +
Let steps be to return the result of package data with the first argument given, type, and object's MIME type. @@ -6458,7 +6441,7 @@ constructor steps are:
If init["{{RequestInit/keepalive}}"] exists and is true, then set body and Content-Type to the result of extracting - init["{{RequestInit/body}}"], with the keepalive flag set. + init["{{RequestInit/body}}"], with keepalive set to true.
Otherwise, set body and Content-Type to the result of extracting init["{{RequestInit/body}}"].