diff --git a/Overview.html b/Overview.html index 05eb513b4..e50ce8fe8 100644 --- a/Overview.html +++ b/Overview.html @@ -7,7 +7,7 @@
To wait for a response, wait for either end-of-file to have been -pushed to response's body or for -response to have a -termination reason. +
To wait for a response, if response's +body is non-null, wait for response's +body's stream to be +closed or +errored.
To read a request, if request's body is non-null, whenever request's body is read from (i.e. is transmitted or read by script), increase request's body's -transmitted with the amount of payload body +transmitted bytes with the amount of payload body bytes transmitted and then queue a fetch task on request to process request body for request. @@ -528,10 +528,37 @@
A body is a byte stream. It has an associated -transmitted which is an integer and initially 0, -length which is an integer and initially 0, and -error flag which is initially unset. +
A body consists of: + +
A stream (a
+ ReadableStream
object).
+
+
This might become a
+ ReadableByteStream
object. While the type might change, the behavior specified
+ will be equivalent since the hypothetical ReadableByteStream
object will have
+ the same members as the ReadableStream
object has today.
+
+
A transmitted bytes (an integer), initially 0. + +
A total bytes (an integer), initially 0. +
To clone a body +body, run these steps: + +
Let «out1, out2» be the result of + teeing body's + stream. Rethrow any exceptions. + +
Set body's stream to out1. + +
Return a body whose + stream is out2 and other members are copied from + body. +
To handle content codings given codings and bytes, run these substeps: @@ -964,6 +991,21 @@
See handle fetch for usage of these terms. [SW] +
To clone a request +request, run these steps: + +
Let newRequest be a copy of request, except for its + body. + +
If request's body is non-null, set + newRequest's body to the result of + cloning request's + body. Rethrow any exceptions. + +
Return newRequest. +
To clone a response +response, run these steps: + +
If response is a filtered response, + return a new identical filtered response whose internal + response is a clone of response's + internal response. Rethrow any exceptions. + +
Let newResponse be a copy of response, except for its + body. + +
If response's body is non-null, set + newResponse's body to the result of + cloning response's + body. Rethrow any exceptions. + +
Return newResponse. +
To error a
+ReadableStream
object stream with given
+reason, run these steps:
+
+
Call ErrorReadableStream
(stream,
+ reason). Rethrow any exceptions.
+
To construct a
ReadableStream
object with given strategy,
pull action and cancel action, all of which are optional, run these steps:
@@ -1296,23 +1367,7 @@
To construct a
-ReadableStream
object, given a byte stream
-byteStream, run these steps:
-
-
This operation is a workaround and will be deleted when we stop using byte streams. - -
Let stream be a ReadableStream
object
- such that consuming it will result in chunks each of which is a Uint8Array
- object wrapping an ArrayBuffer
and the result of concatenating them all will be
- equivalent to the byte sequence which would be read from byteStream. Rethrow any
- exceptions.
-
-
Return stream. -
To get a reader from a +
To get a reader from a
ReadableStream
object stream, run these steps:
Return reader.
To read all bytes from a +
To read all bytes from a
ReadableStream
object with reader, run these
steps:
@@ -1647,8 +1702,7 @@
That is, it either returns a response if request's synchronous flag is set, or it queues tasks annotated - process response, process response body, and - process response end-of-file for the + process response, and process response end-of-file for the response.
To capture uploads, if request's @@ -1934,7 +1988,7 @@
HEAD
` or `CONNECT
`, or internalResponse's
status is a null body status,
set internalResponse's body to
- null and disregard any pushing toward it (if any).
+ null and disregard any enqueuing toward it (if any).
This standardizes the error handling for servers that violate HTTP. @@ -1977,41 +2031,9 @@
Queue a fetch task on request to process response for response. -
If internalResponse's - body is null, run these substeps: - -
Queue a fetch-done task using request and - response. -
Otherwise, if internalResponse's - body is non-null, run these substeps: - -
Whenever internalResponse's - body's is pushed to, for and as long as - internalResponse has no - termination reason and - end-of-file has not been pushed, - queue a fetch task on request to - process response body for response. +
Wait for internalResponse. -
Once end-of-file has been pushed to internalResponse's - body or internalResponse has - a termination reason, - queue a fetch-done task using request and - response. - -
Ideally FTP/HTTP define this in more detail and this becomes a set of - simple hooks. -
Queue a fetch-done task using request and response. @@ -2403,8 +2425,8 @@
Return response. Typically - actualResponse's body is still being - pushed to after returning. + actualResponse's body's + stream is still being enqueued to after returning. @@ -2504,9 +2526,8 @@
no-window
" and request's
redirect mode is not
- "follow
", and a copy of request, with
- httpRequest's body being a tee
- of request's body, otherwise.
+ "follow
", and the result of cloning
+ request otherwise.
A request is typically copied as it needs to be possible to add headers and read its @@ -2525,7 +2546,7 @@
If httpRequest's body is non-null, set contentLengthValue to httpRequest's body's - length, + total bytes, utf-8 encoded. @@ -2747,8 +2768,8 @@
Return response. Typically - response's body is still being - pushed to after returning. + response's body's + stream is still being enqueued to after returning. @@ -2806,6 +2827,30 @@
Let strategy be an object. The user agent may choose any object. + +
strategy is used to control the queuing strategy of + stream constructed below. + +
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 reason + end-user abort. + +
Let stream be the result of
+ constructing a
+ ReadableStream
object with strategy,
+ pull and cancel.
+
This construction operation will not throw an exception. + +
Set response's body to a new + body whose stream is + stream. +
Delete
`Content-Encoding
` from response's
@@ -2866,9 +2911,8 @@
If response's body is - non-null, set response's - body's - length to response's + non-null, set response's body's + total bytes to response's body's payload body length. @@ -2879,7 +2923,7 @@
Increase response's body's - transmitted with bytes' + transmitted bytes with bytes' length.
Let codings be the result of @@ -2887,25 +2931,40 @@
Set bytes to the result of - handling content codings given - codings and bytes. +
Set bytes to the result of handling + content codings given codings and bytes. + +
This makes the `Content-Length
`
+ header unreliable to the extent that it was reliable
+ to begin with.
+
+
Enqueue a Uint8Array
+ object wrapping an ArrayBuffer
containing bytes to stream.
-
Push bytes to response's - body. - +
If stream doesn't need more + data and request's synchronous flag is unset, ask the user agent + to suspend the ongoing fetch. -
This means that the `Content-Length
`
- header is no longer reliable. A
- response will still include it, but it cannot be
- used, except for debugging and logging purposes.
+
If at any point the bytes transmission is done normally and stream is + readable, + close stream. + +
If at any point fetch is + terminated with reason reason, + run these subsubsteps: + +
Set response's termination + reason to reason. -
These are run in parallel @@ -2914,8 +2973,8 @@
Return response. Typically - response's body is still being - pushed to after returning. + response's body's + stream is still being enqueued to after returning. @@ -3516,14 +3575,17 @@
typedef any JSON; typedef (Blob or BufferSource or FormData or URLSearchParams or USVString) BodyInit;-
To extract a byte stream and a +
To extract a body and a
`Content-Type
` value from
object, run these steps:
Let stream be an empty byte stream. +
Let stream be the result of
+ constructing a
+ ReadableStream
object.
Let Content-Type be null. +
Let action be null.
Switch on object's type: @@ -3531,25 +3593,25 @@
Blob
Push a copy of object's contents to stream. +
Set action to an action that reads object. -
If object's
- type
attribute is not the
- empty byte sequence, set Content-Type to its value.
+
If object's type
+ attribute is not the empty byte sequence, set Content-Type to its value.
BufferSource
Push a - copy of - object to stream. +
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.
FormData
Push the result of running the +
Set action to an action that runs the
multipart/form-data
encoding algorithm,
with object as form data set and with
- utf-8 as the explicit character encoding, to
- stream.
+ utf-8 as the explicit character encoding.
@@ -3561,11 +3623,10 @@
URLSearchParams
Push the result of running the
- application/x-www-form-urlencoded
serializer,
- with object's
- list, to
- stream.
+
Set action to an action that runs the
+ application/x-www-form-urlencoded
+ serializer with object's
+ list.
Set Content-Type to @@ -3573,12 +3634,31 @@
USVString
Push the result of running utf-8 encode on - object to stream. +
Set action to an action that runs + utf-8 encode on object. +
Set Content-Type to `text/plain;charset=UTF-8
`.
Return stream and Content-Type. +
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. +
Return body and Content-Type.
Objects implementing the Body
mixin gain a
-MIME type (initially the empty byte sequence).
+
Objects implementing the Body
mixin gain an associated
+body (null or a body) and
+a MIME type (initially the empty byte sequence).
-
Objects implementing the Body
mixin must define an associated
-disturbed predicate and a
-consume body algorithm.
+
An object implementing the Body
mixin is said to be
+disturbed if body is
+non-null and its stream is
+disturbed.
+
+
An object implementing the Body
mixin is said to be
+locked if body is
+non-null and its stream is
+locked.
The bodyUsed
attribute's getter must
return true if disturbed, and false otherwise.
Objects implementing the Body
mixin also have an associated
-package data algorithm, which given
+package data algorithm, given
bytes, a type and a MIME type, switches on type, and
runs the associated steps:
@@ -3675,6 +3762,36 @@
Objects implementing the Body
mixin also have an associated
+consume body algorithm, given a type,
+runs these steps:
+
+
If this object is disturbed
+ or locked, return a new promise rejected with a
+ TypeError
.
+
+
Let stream be body's
+ stream if body is
+ non-null, or an empty
+ ReadableStream
object otherwise.
+
+
Let reader be the result of getting + a reader from stream. If that threw an exception, return a new promise rejected + with that exception. + +
Let promise be the result of + reading all bytes from + stream with reader. + +
Return the result of transforming promise by a fulfillment handler that + returns the result of the package data algorithm + with its first argument, type and this object's + MIME type. + +
The arrayBuffer()
method, when invoked, must return the result of running
consume body with ArrayBuffer.
@@ -3754,51 +3871,16 @@
A Request
object has an associated
-request (a
-request).
+
A Request
object has an associated request
+(a request).
A Request
object also has an associated Headers
object which
is itself associated with request's
header list.
-
A Request
object also has an associated
-disturbed flag which is initially unset.
-
-
A Request
object's disturbed predicate
-returns true if the associated request's
-body is not null and the associated
-disturbed flag is set.
-
-
A Request
object's consume body
-algorithm, given a type, runs these steps:
-
-
If this Request
object is disturbed,
- return a new promise rejected with a TypeError
.
-
-
Set disturbed flag. - -
Let p be a new promise. - -
Run these substeps in parallel: -
Let bytes be the empty byte sequence. - -
If request's - body is not null, set bytes to the result of - reading from request's - body until it returns end-of-stream. - -
Resolve p with the result of running the - package data algorithm with bytes, - type and MIME type. If that threw an - exception, reject p with that exception. -
Return p. -
A Request
object's body is its
+request's
+body.
If input is a Request
object and it is
- disturbed,
- throw a TypeError
.
-
-
Let temporaryBody be input's
- request's body
- if input is a Request
object, and null otherwise.
+ disturbed or
+ locked, throw a
+ TypeError
.
Let request be input's request, if input is a @@ -4043,8 +4122,12 @@
Fill r's
Headers
object with headers. Rethrow any exceptions.
+
Let inputBody be input's
+ request's body
+ if input is a Request
object, and null otherwise.
+
If either init's body
member is present and is non-null or
- temporaryBody is non-null, and request's
+ inputBody is non-null, and request's
method is `GET
` or
`HEAD
`, throw a
TypeError
.
@@ -4054,11 +4137,11 @@
Let stream and Content-Type be the result of
- extracting init's
- body
member.
+
Let Content-Type be null. -
Set temporaryBody to stream. +
Set inputBody and Content-Type to the result of
+ extracting init's
+ body
member. Rethrow any exceptions.
If Content-Type is non-null and r's request's @@ -4070,7 +4153,7 @@
Set r's request's - body to temporaryBody. + body to inputBody.
Set r's MIME type to @@ -4084,13 +4167,35 @@
Let dummyStream be an empty
+ ReadableStream
object.
+
Set input's request's - body to an empty byte stream. + body to a new body whose + stream is dummyStream. + +
Let reader be the result of getting a reader + from dummyStream. +
This operation will not throw an exception. -
Set input's - disturbed flag. +
Read all bytes from + dummyStream with reader. +
This operation makes dummyStream disturbed.
These substeps are meant to produce the observable equivalent of
+ "piping" input's body's
+ stream into r. That is, input is
+ left with a body with a
+ ReadableStream
object that is
+ disturbed and
+ locked, while the data readable from
+ r's body's
+ stream is now equal to what used to be input's,
+ if input's original body is non-null.
+
Return r.
If this Request
object is disturbed
+ or locked,
throw a TypeError
.
-
Let newRequest be a copy of - request, with - newRequest's body being a tee of - request's - body. - - -
Let r be a new Request
object associated with
- newRequest and a new Headers
object whose
+
Return a new Request
object associated with the result of
+ cloning
+ request and a new Headers
object whose
guard is
context object's Headers
'
guard.
-
-
Return r.
A Response
object also has an associated
-readable stream which is null or a
-ReadableStream
object. Its initial value is null.
-
-
This might become a
-ReadableByteStream
object. While the type might change, the behavior specified will
-be equivalent since the hypothetical ReadableByteStream
object will have the same
-members as the ReadableStream
object has today.
-
-
A Response
object is said to be locked if
-the associated readable stream is not null and
-it is locked.
-
-
A Response
object's disturbed predicate
-returns true if the associated readable stream
-is not null and it is disturbed.
-
-
A Response
object's consume body
-algorithm, given a type, runs these steps:
-
-
If this Response
object is disturbed
- or locked, return a new promise rejected with a
- TypeError
.
-
-
Let stream be readable - stream. - -
If stream is null, set stream to an
- empty
- ReadableStream
object.
-
-
Let reader be the result of getting - a reader from stream. If that threw an exception, return a new promise rejected - with that exception. - -
Let promise be the result of - reading all bytes from - stream with reader. - -
Return the result of transforming promise by a fulfillment handler that - returns the result of the package data algorithm - with its first argument, type and MIME type. - -
A Response
object's body is its
+response's body.
The
Response(body, init)
@@ -4309,14 +4363,11 @@
101
is included in
null body status due to its use elsewhere. It does not affect this step.
-
Let byteStream and Content-Type be the result of - extracting body. +
Let Content-Type be null. -
Set r's
- readable stream to the result of
- constructing a
- ReadableStream
object with byteStream.
- Rethrow any exceptions.
+
Set r's response's + body and Content-Type to the result of + extracting body. Rethrow any exceptions.
If Content-Type is non-null and r's response's @@ -4416,8 +4467,9 @@
The headers
attribute's getter must
return the associated Headers
object.
-
The body
attribute's getter must return the
-associated readable stream.
+
The body
attribute's getter must return null if
+the associated body is null and the associated
+body's stream otherwise.
If this Response
object is disturbed
- or locked, throw a
- TypeError
.
-
-
Let newResponse be a copy of
- response except its
- body.
+ or locked,
+ throw a TypeError
.
-
Let r be a new Response
object associated with
- newResponse and a new Headers
object whose
+
Return a new Response
object associated with the result of
+ cloning
+ response and a new Headers
object whose
guard is
context object's Headers
'
guard.
-
-
If readable stream is null, Return - r. - -
Let «out1, out2» be the result of - teeing - readable stream. Rethrow any exceptions. - -
Set readable stream to out1. - -
Set r's readable stream to - out2. - -
Return r.
error
", reject p with a TypeError
and terminate
these substeps.
- Let responseObject be a new Response
object associated with
+
Resolve p with a new Response
object associated with
response and a new Headers
object whose
guard is "immutable
".
-
-
If response's body is null, resolve - p with responseObject and terminate these substeps. - -
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 reason - end-user abort. - -
Let strategy be an object. The user agent may choose any object. -
strategy is used to control the queuing strategy of - stream constructed below. - -
Set stream to the result of
- constructing a
- ReadableStream
object with strategy,
- pull and cancel. If that threw an exception, run the following
- subsubsteps and terminate these substeps:
-
-
Reject p with that exception. - -
Terminate the ongoing fetch with reason - fatal. -
Set responseObject's readable - stream to stream. - -
Resolve p with responseObject. -
To process response body for response, run these substeps: - -
If stream is null, terminate these substeps. - -
Enqueue a Uint8Array
- object wrapping an ArrayBuffer
containing the result of reading
- response's body into stream. If
- that threw an exception, run the following subsubsteps and terminate these substeps:
-
-
Reject p with that exception. - -
Terminate the ongoing fetch with reason - fatal. -
If stream doesn't - need more data, ask the user agent to - suspend the ongoing fetch. -
To process response end-of-file for response, - close stream - if stream is not null. -
Return p. diff --git a/Overview.src.html b/Overview.src.html index 566ddca06..c2f5cfcc5 100644 --- a/Overview.src.html +++ b/Overview.src.html @@ -160,7 +160,6 @@
To wait for a response, wait for either end-of-file to have been -pushed to response's body or for -response to have a -termination reason. +
To wait for a response, if response's +body is non-null, wait for response's +body's stream to be +closed or +errored.
To read a request, if request's body is non-null, whenever request's body is read from (i.e. is transmitted or read by script), increase request's body's -transmitted with the amount of payload body +transmitted bytes with the amount of payload body bytes transmitted and then queue a fetch task on request to process request body for request. @@ -466,10 +466,37 @@
A body is a byte stream. It has an associated -transmitted which is an integer and initially 0, -length which is an integer and initially 0, and -error flag which is initially unset. +
A body consists of: + +
A stream (a
+ ReadableStream
object).
+
+
This might become a
+ ReadableByteStream
object. While the type might change, the behavior specified
+ will be equivalent since the hypothetical ReadableByteStream
object will have
+ the same members as the ReadableStream
object has today.
+
+
A transmitted bytes (an integer), initially 0. + +
A total bytes (an integer), initially 0. +
To clone a body +body, run these steps: + +
Let «out1, out2» be the result of + teeing body's + stream. Rethrow any exceptions. + +
Set body's stream to out1. + +
Return a body whose + stream is out2 and other members are copied from + body. +
To handle content codings given codings and bytes, run these substeps: @@ -902,6 +929,21 @@
See handle fetch for usage of these terms. SW +
To clone a request +request, run these steps: + +
Let newRequest be a copy of request, except for its + body. + +
If request's body is non-null, set + newRequest's body to the result of + cloning request's + body. Rethrow any exceptions. + +
Return newRequest. +
To clone a response +response, run these steps: + +
If response is a filtered response, + return a new identical filtered response whose internal + response is a clone of response's + internal response. Rethrow any exceptions. + +
Let newResponse be a copy of response, except for its + body. + +
If response's body is non-null, set + newResponse's body to the result of + cloning response's + body. Rethrow any exceptions. + +
Return newResponse. +
To error a
+ReadableStream
object stream with given
+reason, run these steps:
+
+
Call ErrorReadableStream
(stream,
+ reason). Rethrow any exceptions.
+
To construct a
ReadableStream
object with given strategy,
pull action and cancel action, all of which are optional, run these steps:
@@ -1234,23 +1305,7 @@
To construct a
-ReadableStream
object, given a byte stream
-byteStream, run these steps:
-
-
This operation is a workaround and will be deleted when we stop using byte streams. - -
Let stream be a ReadableStream
object
- such that consuming it will result in chunks each of which is a Uint8Array
- object wrapping an ArrayBuffer
and the result of concatenating them all will be
- equivalent to the byte sequence which would be read from byteStream. Rethrow any
- exceptions.
-
-
Return stream. -
To get a reader from a +
To get a reader from a
ReadableStream
object stream, run these steps:
Return reader.
To read all bytes from a +
To read all bytes from a
ReadableStream
object with reader, run these
steps:
@@ -1585,8 +1640,7 @@
That is, it either returns a response if request's synchronous flag is set, or it queues tasks annotated - process response, process response body, and - process response end-of-file for the + process response, and process response end-of-file for the response.
To capture uploads, if request's @@ -1872,7 +1926,7 @@
HEAD
` or `CONNECT
`, or internalResponse's
status is a null body status,
set internalResponse's body to
- null and disregard any pushing toward it (if any).
+ null and disregard any enqueuing toward it (if any).
This standardizes the error handling for servers that violate HTTP. @@ -1915,41 +1969,9 @@
Queue a fetch task on request to process response for response. -
If internalResponse's - body is null, run these substeps: - -
Queue a fetch-done task using request and - response. -
Otherwise, if internalResponse's - body is non-null, run these substeps: - -
Whenever internalResponse's - body's is pushed to, for and as long as - internalResponse has no - termination reason and - end-of-file has not been pushed, - queue a fetch task on request to - process response body for response. +
Wait for internalResponse. -
Once end-of-file has been pushed to internalResponse's - body or internalResponse has - a termination reason, - queue a fetch-done task using request and - response. - -
Ideally FTP/HTTP define this in more detail and this becomes a set of - simple hooks. -
Queue a fetch-done task using request and response. @@ -2341,8 +2363,8 @@
Return response. Typically - actualResponse's body is still being - pushed to after returning. + actualResponse's body's + stream is still being enqueued to after returning. @@ -2442,9 +2464,8 @@
no-window
" and request's
redirect mode is not
- "follow
", and a copy of request, with
- httpRequest's body being a tee
- of request's body, otherwise.
+ "follow
", and the result of cloning
+ request otherwise.
A request is typically copied as it needs to be possible to add headers and read its @@ -2463,7 +2484,7 @@
If httpRequest's body is non-null, set contentLengthValue to httpRequest's body's - length, + total bytes, utf-8 encoded. @@ -2685,8 +2706,8 @@
Return response. Typically - response's body is still being - pushed to after returning. + response's body's + stream is still being enqueued to after returning. @@ -2744,6 +2765,30 @@
Read request. +
Let strategy be an object. The user agent may choose any object. + +
strategy is used to control the queuing strategy of + stream constructed below. + +
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 reason + end-user abort. + +
Let stream be the result of
+ constructing a
+ ReadableStream
object with strategy,
+ pull and cancel.
+
This construction operation will not throw an exception. + +
Set response's body to a new + body whose stream is + stream. +
Delete
`Content-Encoding
` from response's
@@ -2804,9 +2849,8 @@
If response's body is - non-null, set response's - body's - length to response's + non-null, set response's body's + total bytes to response's body's payload body length. @@ -2817,7 +2861,7 @@
Increase response's body's - transmitted with bytes' + transmitted bytes with bytes' length.
Let codings be the result of @@ -2825,25 +2869,40 @@
Set bytes to the result of - handling content codings given - codings and bytes. +
Set bytes to the result of handling + content codings given codings and bytes. + +
This makes the `Content-Length
`
+ header unreliable to the extent that it was reliable
+ to begin with.
+
+
Enqueue a Uint8Array
+ object wrapping an ArrayBuffer
containing bytes to stream.
-
Push bytes to response's - body. - +
If stream doesn't need more + data and request's synchronous flag is unset, ask the user agent + to suspend the ongoing fetch.
This means that the `Content-Length
`
- header is no longer reliable. A
- response will still include it, but it cannot be
- used, except for debugging and logging purposes.
+
If at any point the bytes transmission is done normally and stream is + readable, + close stream. + +
If at any point fetch is + terminated with reason reason, + run these subsubsteps: + +
Set response's termination + reason to reason. -
If stream is readable,
+ error stream with a
+ TypeError
.
+
These are run in parallel @@ -2852,8 +2911,8 @@
Return response. Typically - response's body is still being - pushed to after returning. + response's body's + stream is still being enqueued to after returning. @@ -3454,14 +3513,17 @@
typedef any JSON; typedef (Blob or BufferSource or FormData or URLSearchParams or USVString) BodyInit;-
To extract a byte stream and a +
To extract a body and a
`Content-Type
` value from
object, run these steps:
Let stream be an empty byte stream. +
Let stream be the result of
+ constructing a
+ ReadableStream
object.
Let Content-Type be null. +
Let action be null.
Switch on object's type: @@ -3469,25 +3531,25 @@
Blob
Push a copy of object's contents to stream. +
Set action to an action that reads object. -
If object's
- type
attribute is not the
- empty byte sequence, set Content-Type to its value.
+
If object's type
+ attribute is not the empty byte sequence, set Content-Type to its value.
BufferSource
Push a - copy of - object to stream. +
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.
FormData
Push the result of running the +
Set action to an action that runs the
multipart/form-data
encoding algorithm,
with object as form data set and with
- utf-8 as the explicit character encoding, to
- stream.
+ utf-8 as the explicit character encoding.
@@ -3499,11 +3561,10 @@
URLSearchParams
Push the result of running the
- application/x-www-form-urlencoded
serializer,
- with object's
- list, to
- stream.
+
Set action to an action that runs the
+ application/x-www-form-urlencoded
+ serializer with object's
+ list.
Set Content-Type to @@ -3511,12 +3572,31 @@
USVString
Push the result of running utf-8 encode on - object to stream. +
Set action to an action that runs + utf-8 encode on object. +
Set Content-Type to `text/plain;charset=UTF-8
`.
Return stream and Content-Type. +
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. +
Let body be a body whose + stream is stream. + +
Return body and Content-Type.
Objects implementing the Body
mixin gain a
-MIME type (initially the empty byte sequence).
+
Objects implementing the Body
mixin gain an associated
+body (null or a body) and
+a MIME type (initially the empty byte sequence).
-
Objects implementing the Body
mixin must define an associated
-disturbed predicate and a
-consume body algorithm.
+
An object implementing the Body
mixin is said to be
+disturbed if body is
+non-null and its stream is
+disturbed.
+
+
An object implementing the Body
mixin is said to be
+locked if body is
+non-null and its stream is
+locked.
The bodyUsed
attribute's getter must
-return true if disturbed, and false otherwise.
+return true if disturbed, and false otherwise.
Objects implementing the Body
mixin also have an associated
-package data algorithm, which given
+package data algorithm, given
bytes, a type and a MIME type, switches on type, and
runs the associated steps:
@@ -3613,6 +3700,36 @@
Objects implementing the Body
mixin also have an associated
+consume body algorithm, given a type,
+runs these steps:
+
+
If this object is disturbed
+ or locked, return a new promise rejected with a
+ TypeError
.
+
+
Let stream be body's
+ stream if body is
+ non-null, or an empty
+ ReadableStream
object otherwise.
+
+
Let reader be the result of getting + a reader from stream. If that threw an exception, return a new promise rejected + with that exception. + +
Let promise be the result of + reading all bytes from + stream with reader. + +
Return the result of transforming promise by a fulfillment handler that + returns the result of the package data algorithm + with its first argument, type and this object's + MIME type. + +
The arrayBuffer()
method, when invoked, must return the result of running
consume body with ArrayBuffer.
@@ -3692,51 +3809,16 @@
A Request
object has an associated
-request (a
-request).
+
A Request
object has an associated request
+(a request).
A Request
object also has an associated Headers
object which
is itself associated with request's
header list.
-
A Request
object also has an associated
-disturbed flag which is initially unset.
-
-
A Request
object's disturbed predicate
-returns true if the associated request's
-body is not null and the associated
-disturbed flag is set.
-
-
A Request
object's consume body
-algorithm, given a type, runs these steps:
-
-
If this Request
object is disturbed,
- return a new promise rejected with a TypeError
.
-
-
Set disturbed flag. - -
Let p be a new promise. - -
Run these substeps in parallel: -
Let bytes be the empty byte sequence. - -
If request's - body is not null, set bytes to the result of - reading from request's - body until it returns end-of-stream. - -
Resolve p with the result of running the - package data algorithm with bytes, - type and MIME type. If that threw an - exception, reject p with that exception. -
Return p. -
A Request
object's body is its
+request's
+body.
If input is a Request
object and it is
- disturbed,
- throw a TypeError
.
-
-
Let temporaryBody be input's
- request's body
- if input is a Request
object, and null otherwise.
+ disturbed or
+ locked, throw a
+ TypeError
.
Let request be input's request, if input is a @@ -3981,8 +4060,12 @@
Fill r's
Headers
object with headers. Rethrow any exceptions.
+
Let inputBody be input's
+ request's body
+ if input is a Request
object, and null otherwise.
+
If either init's body
member is present and is non-null or
- temporaryBody is non-null, and request's
+ inputBody is non-null, and request's
method is `GET
` or
`HEAD
`, throw a
TypeError
.
@@ -3992,11 +4075,11 @@
Let stream and Content-Type be the result of
- extracting init's
- body
member.
+
Let Content-Type be null. -
Set temporaryBody to stream. +
Set inputBody and Content-Type to the result of
+ extracting init's
+ body
member. Rethrow any exceptions.
If Content-Type is non-null and r's request's @@ -4008,7 +4091,7 @@
Set r's request's - body to temporaryBody. + body to inputBody.
Set r's MIME type to @@ -4022,13 +4105,35 @@
Let dummyStream be an empty
+ ReadableStream
object.
+
Set input's request's - body to an empty byte stream. + body to a new body whose + stream is dummyStream. + +
Let reader be the result of getting a reader + from dummyStream. +
This operation will not throw an exception. -
Set input's - disturbed flag. +
Read all bytes from + dummyStream with reader. +
This operation makes dummyStream disturbed.
These substeps are meant to produce the observable equivalent of
+ "piping" input's body's
+ stream into r. That is, input is
+ left with a body with a
+ ReadableStream
object that is
+ disturbed and
+ locked, while the data readable from
+ r's body's
+ stream is now equal to what used to be input's,
+ if input's original body is non-null.
+
Return r.
If this Request
object is disturbed,
+
If this Request
object is disturbed
+ or locked,
throw a TypeError
.
-
Let newRequest be a copy of - request, with - newRequest's body being a tee of - request's - body. - - -
Let r be a new Request
object associated with
- newRequest and a new Headers
object whose
+
Return a new Request
object associated with the result of
+ cloning
+ request and a new Headers
object whose
guard is
context object's Headers
'
guard.
-
-
Return r.
A Response
object also has an associated
-readable stream which is null or a
-ReadableStream
object. Its initial value is null.
-
-
This might become a
-ReadableByteStream
object. While the type might change, the behavior specified will
-be equivalent since the hypothetical ReadableByteStream
object will have the same
-members as the ReadableStream
object has today.
-
-
A Response
object is said to be locked if
-the associated readable stream is not null and
-it is locked.
-
-
A Response
object's disturbed predicate
-returns true if the associated readable stream
-is not null and it is disturbed.
-
-
A Response
object's consume body
-algorithm, given a type, runs these steps:
-
-
If this Response
object is disturbed
- or locked, return a new promise rejected with a
- TypeError
.
-
-
Let stream be readable - stream. - -
If stream is null, set stream to an
- empty
- ReadableStream
object.
-
-
Let reader be the result of getting - a reader from stream. If that threw an exception, return a new promise rejected - with that exception. - -
Let promise be the result of - reading all bytes from - stream with reader. - -
Return the result of transforming promise by a fulfillment handler that - returns the result of the package data algorithm - with its first argument, type and MIME type. - -
A Response
object's body is its
+response's body.
The
Response(body, init)
@@ -4247,14 +4301,11 @@
101
is included in
null body status due to its use elsewhere. It does not affect this step.
-
Let byteStream and Content-Type be the result of - extracting body. +
Let Content-Type be null. -
Set r's
- readable stream to the result of
- constructing a
- ReadableStream
object with byteStream.
- Rethrow any exceptions.
+
Set r's response's + body and Content-Type to the result of + extracting body. Rethrow any exceptions.
If Content-Type is non-null and r's response's @@ -4354,8 +4405,9 @@
The headers
attribute's getter must
return the associated Headers
object.
-
The body
attribute's getter must return the
-associated readable stream.
+
The body
attribute's getter must return null if
+the associated body is null and the associated
+body's stream otherwise.
If this Response
object is disturbed
- or locked, throw a
- TypeError
.
-
-
Let newResponse be a copy of
- response except its
- body.
+ or locked,
+ throw a TypeError
.
-
Let r be a new Response
object associated with
- newResponse and a new Headers
object whose
+
Return a new Response
object associated with the result of
+ cloning
+ response and a new Headers
object whose
guard is
context object's Headers
'
guard.
-
-
If readable stream is null, Return - r. - -
Let «out1, out2» be the result of - teeing - readable stream. Rethrow any exceptions. - -
Set readable stream to out1. - -
Set r's readable stream to - out2. - -
Return r.
error
", reject p with a TypeError
and terminate
these substeps.
- Let responseObject be a new Response
object associated with
+
Resolve p with a new Response
object associated with
response and a new Headers
object whose
guard is "immutable
".
-
-
If response's body is null, resolve - p with responseObject and terminate these substeps. - -
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 reason - end-user abort. - -
Let strategy be an object. The user agent may choose any object. -
strategy is used to control the queuing strategy of - stream constructed below. - -
Set stream to the result of
- constructing a
- ReadableStream
object with strategy,
- pull and cancel. If that threw an exception, run the following
- subsubsteps and terminate these substeps:
-
-
Reject p with that exception. - -
Terminate the ongoing fetch with reason - fatal. -
Set responseObject's readable - stream to stream. - -
Resolve p with responseObject. -
To process response body for response, run these substeps: - -
If stream is null, terminate these substeps. - -
Enqueue a Uint8Array
- object wrapping an ArrayBuffer
containing the result of reading
- response's body into stream. If
- that threw an exception, run the following subsubsteps and terminate these substeps:
-
-
Reject p with that exception. - -
Terminate the ongoing fetch with reason - fatal. -
If stream doesn't - need more data, ask the user agent to - suspend the ongoing fetch. -
To process response end-of-file for response, - close stream - if stream is not null. -
Return p.