diff --git a/fetch.bs b/fetch.bs
index c135722ab..0d19e5c82 100644
--- a/fetch.bs
+++ b/fetch.bs
@@ -1189,38 +1189,48 @@ or "worker
".
In parallel, while true:
Wait for read to be fulfilled or rejected. -
If read is fulfilled with an object whose done
property is false
- and whose value
property is a Uint8Array
object, then run these steps:
+
Run these steps, but abort if the ongoing fetch is terminated:
Let bs be the byte sequence represented by the Uint8Array
- object.
+
Wait for read to be fulfilled or rejected.
Transmit bs. Whenever one or more bytes are transmitted, increase - body's transmitted bytes by the number of transmitted bytes and - queue a fetch task on request to process request body - for request. +
If read is fulfilled with an object whose done
property is false
+ and whose value
property is a Uint8Array
object, then run these
+ steps:
-
This step blocks until bs is fully transmitted. +
Let bs be the byte sequence represented by the
+ Uint8Array
object.
-
Set read to the result of reading a - chunk from body's stream with reader. -
Transmit bs. Whenever one or more bytes are transmitted, increase + body's transmitted bytes by the number of transmitted bytes and + queue a fetch task on request to process request body + for request. + +
This step blocks until bs is fully transmitted. + +
Set read to the result of reading a + chunk from body's stream with reader. +
Otherwise, if read is fulfilled with an object whose done
+ property is true, then queue a fetch task on request to
+ process request end-of-body for request and abort these in-parallel steps.
-
Otherwise, if read is fulfilled with an object whose done
property
- is true, then queue a fetch task on request to
- process request end-of-body for request and abort these steps.
+
Otherwise, if read is rejected with an
+ "AbortError
" {{DOMException}},
+ terminate the ongoing fetch with the aborted flag set.
-
Otherwise, terminate the ongoing fetch with reason - fatal and abort these steps. +
Otherwise, terminate the ongoing fetch. +
If the ongoing fetch is terminated, then abort these in-parallel steps. -
The result of fetch is a
@@ -1238,8 +1248,10 @@ evolves over time. That is, not all its fields are available straight away.
Unless stated otherwise, it is "default
".
A response can have an associated -termination reason -which is end-user abort, fatal, or timeout. +aborted flag, which is initially unset. + +
This indicates that the request was intentionally aborted by the developer or +end-user.
A response has an associated
url. It is a pointer to the
@@ -1277,6 +1289,10 @@ Unless stated otherwise it is `OK
`.
trailer (a
header list). Unless stated otherwise it is empty.
+
A response has an associated +trailer failed flag, which is +initially unset. +
A response has an associated
HTTPS state (an
HTTPS state value). Unless stated otherwise, it is
@@ -1310,6 +1326,10 @@ navigate algorithm. It ensures `Location
` has
A response whose
+type is "error
" and aborted flag is set is
+known as an aborted network error.
+
A response whose
type is "error
" is known as a
network error.
@@ -1472,7 +1492,7 @@ for each associated fetch record whose
keepalive flag is unset,
terminate the
fetch record's
-fetch with reason fatal.
+fetch.
If connection pool contains a - connection whose origin is origin and - credentials is credentials, return that +
If connection pool contains a connection whose origin is + origin and credentials is credentials, then return that connection. +
Let connection be null. +
Let connection be the result of establishing an HTTP connection to - origin. [[!HTTP]] [[!HTTP-SEMANTICS]] [[!HTTP-COND]] [[!HTTP-CACHING]] [[!HTTP-AUTH]] [[!TLS]] +
Run these steps, but abort if the ongoing fetch is terminated:
+ +Set connection to the result of establishing an HTTP connection to + origin. [[!HTTP]] [[!HTTP-SEMANTICS]] [[!HTTP-COND]] [[!HTTP-CACHING]] [[!HTTP-AUTH]] + [[!TLS]] -
If credentials is false, do not send a TLS client certificate. +
If credentials is false, then do not send a TLS client certificate. -
If establishing a connection does not succeed (e.g., a DNS, TCP, or TLS error), return failure. +
If establishing a connection does not succeed (e.g., a DNS, TCP, or TLS error), then return + failure. +
Add connection to the connection pool - with origin being origin and credentials being credentials. +
If the ongoing fetch is terminated, then: + +
If connection is not null, then close connection. + +
Return failure. +
Add connection to the connection pool with origin + being origin and credentials being credentials.
Return connection.
To cancel a -{{ReadableStream}} object with reader and reason, return the result of calling -ReadableStreamCancel(reader, reason). +{{ReadableStream}} object stream with reason, return the result of calling +ReadableStreamCancel(stream, reason).
Because the reader grants exclusive access, the actual mechanism of how
to read cannot be observed. Implementations could use more direct mechanism if convenient.
@@ -2278,9 +2315,8 @@ pertain to them. Also, considering "image
" was not compatible with
To perform a fetch using request, run the steps below. An ongoing fetch can be -terminated with reason -reason, which must be end-user abort, fatal, -timeout, or garbage collection. +terminated with flag aborted, +which is unset unless otherwise specified.
The user agent may be asked to suspend the ongoing fetch. @@ -2295,125 +2331,141 @@ the request. [[!HTTP-CACHING]]
If request's window is
- "client
", set request's
- window to request's
- client, if request's
- client's
- global object is a
- {{Window}} object, and to "no-window
"
- otherwise.
-
-
If request's origin is
- "client
", set request's
- origin to request's
- client's origin.
-
If request's header list
- does not contain `Accept
`, then:
+
Run these steps, but abort if the ongoing fetch is terminated:
Let value be `*/*
`.
+
If request's window is
+ "client
", set request's
+ window to request's
+ client, if request's
+ client's
+ global object is a
+ {{Window}} object, and to "no-window
"
+ otherwise.
-
If request is a navigation request, a user agent should set
- value to
- `text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
`.
+
If request's origin is
+ "client
", set request's
+ origin to request's
+ client's origin.
Otherwise, a user agent should set value to the first matching statement, if any, - switching on request's destination: - +
If request's header list
+ does not contain `Accept
`, then:
-
image
"
- image/png,image/svg+xml,image/*;q=0.8,*/*;q=0.5
`
+ Let value be `*/*
`.
-
style
"
- text/css,*/*;q=0.1
`
- If request is a navigation request, a user agent should set
+ value to
+ `text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
`.
-
Append
- `Accept
`/value to request's
- header list.
-
Otherwise, a user agent should set value to the first matching statement, if + any, switching on request's destination: + -
If request's header list
- does not contain `Accept-Language
`, user agents should
- append
- `Accept-Language
`/an appropriate value
- to request's header list.
+
image
"
+ image/png,image/svg+xml,image/*;q=0.8,*/*;q=0.5
`
- If request's priority is null, then use request's - initiator and destination appropriately in setting - request's priority to a user-agent-defined object. +
style
"
+ text/css,*/*;q=0.1
`
+ The user-agent-defined object could encompass stream weight and dependency - for HTTP/2, and equivalent information used to prioritize dispatch and processing of - HTTP/1 fetches. +
Append
+ `Accept
`/value to request's
+ header list.
+
If request is a navigation request, a user agent should, for each - header name (hintName) in the first column of the - following table, if request's header list - does not contain hintName, then - append - hintName/the value given in the same row on the second column, to request's - header list. - -
Name - | Value - |
---|---|
`dpr `
- | a suitable dpr value - |
`save-data `
- | a suitable save-data value - |
`viewport-width `
- | a suitable viewport-width value - |
If request's header list
+ does not contain `Accept-Language
`, user agents should
+ append
+ `Accept-Language
`/an appropriate value
+ to request's header list.
-
If request is a subresource request, run these substeps: +
If request's priority is null, then use request's + initiator and destination appropriately in setting + request's priority to a user-agent-defined object. + +
The user-agent-defined object could encompass stream weight and dependency + for HTTP/2, and equivalent information used to prioritize dispatch and processing of + HTTP/1 fetches. -
If request's client hints list is not empty, then run these - substeps for each hintName in the list: +
If request is a navigation request, a user agent should, for each + header name (hintName) in the first column of the + following table, if request's header list + does not contain hintName, then + append + hintName/the value given in the same row on the second column, to + request's header list. + +
Name + | Value + |
---|---|
`dpr `
+ | a suitable dpr value + |
`save-data `
+ | a suitable save-data value + |
`viewport-width `
+ | a suitable viewport-width value + |
If request is a subresource request, run these substeps:
Set value to the first matching statement, if any, switching on - hintName: +
If request's client hints list is not empty, then run these + substeps for each hintName in the list: + +
Set value to the first matching statement, if any, switching on + hintName: + +
dpr
"
+ save-data
"
+ viewport-width
"
+ width
"
+ Append hintName/value to + request's header list. +
Let record be a new + fetch record consisting of + request and this instance of the + fetch algorithm. + +
Append record to request's + client's + fetch group list of + fetch records. +
dpr
"
- save-data
"
- viewport-width
"
- width
"
- If the ongoing fetch is terminated, then: -
Append hintName/value to - request's header list. - +
Let aborted be the termination's aborted flag. -
Let record be a new - fetch record consisting of - request and this instance of the - fetch algorithm. +
If aborted is set, then return an aborted network error. -
Append record to request's - client's - fetch group list of - fetch records. +
Return a network error.
Return the result of performing a main fetch @@ -2432,81 +2484,98 @@ with a CORS flag and recursive flag, run these steps:
Let response be null. -
If request's local-URLs-only flag is set and - request's current url is - not local, set - response to a network error. +
Run these steps, but abort if the ongoing fetch is terminated:
-Execute Report Content Security Policy violations for request. - [[!CSP]] +
Upgrade request to a potentially secure URL, if appropriate. - [[!UPGRADE]] +
If request's local-URLs-only flag is set and + request's current url is + not local, set + response to a network error. -
If - should fetching request be blocked due to a bad port, - should fetching request be blocked as mixed content, - or - should fetching request be blocked by Content Security Policy - returns blocked, set response to a - network error. - [[!MIX]] - [[!CSP]] +
Execute Report Content Security Policy violations for request. + [[!CSP]] -
If request's referrer policy is the empty string and - request's client is non-null, then set request's - referrer policy to request's client's - referrer policy. - [[!REFERRER]] +
Upgrade request to a potentially secure URL, if appropriate. + [[!UPGRADE]] -
If request's referrer policy
- is the empty string, then set request's
- referrer policy to
- "no-referrer-when-downgrade
".
+
If + should fetching request be blocked due to a bad port, + should fetching request be blocked as mixed content, + or + should fetching request be blocked by Content Security Policy + returns blocked, set response to a + network error. + [[!MIX]] + [[!CSP]] -
We use "no-referrer-when-downgrade
" because it is the
- historical default.
+
If request's referrer policy is the empty string and + request's client is non-null, then set request's + referrer policy to request's client's + referrer policy. + [[!REFERRER]] -
If request's referrer
- is not "no-referrer
", set request's
- referrer to the result of invoking
- determine request's referrer.
- [[!REFERRER]]
+
If request's referrer policy
+ is the empty string, then set request's
+ referrer policy to
+ "no-referrer-when-downgrade
".
-
As stated in Referrer Policy, user agents can
- provide the end user with options to override request's
- referrer to "no-referrer
" or
- have it expose less sensitive information.
+
We use "no-referrer-when-downgrade
" because it is the
+ historical default.
-
If request's current URL's scheme is
- "ftp
", request's client's
- creation URL's scheme is not "ftp
", and
- request's reserved client is either null or an environment
- whose target browsing context is a nested browsing context, then set
- response to a network error.
+
If request's referrer
+ is not "no-referrer
", set request's
+ referrer to the result of invoking
+ determine request's referrer.
+ [[!REFERRER]]
-
Set request's current url's
- scheme to "https
" if
- all of the following conditions are true:
+
As stated in Referrer Policy, user agents can
+ provide the end user with options to override request's
+ referrer to "no-referrer
" or
+ have it expose less sensitive information.
-
http
"
- includeSubDomains
- directive or a congruent match (with or without an asserted includeSubDomains
- directive) [[!HSTS]]
- If request's current URL's scheme is
+ "ftp
", request's client's
+ creation URL's scheme is not "ftp
", and
+ request's reserved client is either null or an environment
+ whose target browsing context is a nested browsing context, then
+ set response to a network error.
+
+
Set request's current url's
+ scheme to "https
" if
+ all of the following conditions are true:
+
+
http
"
+ includeSubDomains
directive or a congruent match (with or without an asserted
+ includeSubDomains
directive) [[!HSTS]]
+ If the ongoing fetch is terminated, then: + +
Let aborted be the termination's aborted flag. + +
If aborted is set, then return an aborted network error. + +
Return a network error. +
If request's synchronous flag is unset and recursive flag is unset, run the remaining steps @@ -2696,13 +2765,11 @@ with a CORS flag and recursive flag, run these steps:
If response does not have a - termination reason and - response does not +
If response's body's stream has not + errored, and response does not match - request's integrity metadata, - set response and internalResponse to a - network error. + request's integrity metadata, set response and + internalResponse to a network error. [[!SRI]]
Queue a fetch task on request to process response end-of-body for response. -
Wait for internalResponse's trailer,
- if any. See
+ Wait for either internalResponse's trailer,
+ if any, or for the ongoing fetch to terminate. See
section 4.1.2 of
[[!HTTP]].
+ If the ongoing fetch is terminated, then set internalResponse's
+ trailer failed flag.
+
Set request's done flag.
Queue a fetch task on request to process response done
@@ -2788,44 +2858,56 @@ steps:
Let blob be request's
- current url's
- object.
-
If request's method is not
- ` Run these steps, but abort if the ongoing fetch is terminated:
- The ` Let blob be request's
+ current url's
+ object.
- Let response be a new
- response.
+ If request's method is not
+ ` Append
- ` The ` Append
- ` Let response be a new
+ response.
- Set response's
- HTTPS state to request's
- client's HTTPS state
- if request's client is non-null.
+ Append
+ ` Set response's body to
- the result of performing the read operation on
- blob.
-
+ Append
+ ` Return response.
+ Set response's
+ HTTPS state to request's
+ client's HTTPS state
+ if request's client is non-null.
+
+ Set response's body to
+ the result of performing the read operation on
+ blob.
+
+
+
+ Return response.
+ Let aborted be the termination's aborted flag.
+
+ If aborted is set, then return an aborted network error.
+
+ Return a network error.
Execute
- set response's CSP list
+ Execute set response's CSP list
on actualResponse. [[!CSP]]
@@ -3177,278 +3258,293 @@ Range Requests. [[HTTP-RANGE]] However, this is not widely supported by b
Let httpRequest be null.
- If request's window is " Otherwise, run these substeps:
+ Run these steps, but abort if the ongoing fetch is terminated: Set httpRequest to a copy of request except for its
- body.
+ If request's window is " Let body be request's body.
+ Otherwise, run these substeps:
- Set httpRequest's body to body.
+ Let body be request's body.
- request is copied as httpRequest here as we need
- to be able to add headers to httpRequest and read its body without
- affecting request. Namely, request can be reused with redirects,
- authentication, and proxy authentication. We copy rather than clone in order to reduce memory
- consumption. In case request's body's source is
- null, redirects and authentication will end up failing the fetch.
+ Set httpRequest's body to body.
- Let credentials flag be set if one of
+ If body is non-null, then set request's body to
+ a new body whose stream is null and whose source
+ is body's source.
+ request is copied as httpRequest here as we
+ need to be able to add headers to httpRequest and read its body
+ without affecting request. Namely, request can be reused with redirects,
+ authentication, and proxy authentication. We copy rather than clone in order to reduce memory
+ consumption. In case request's body's source is
+ null, redirects and authentication will end up failing the fetch.
- is true, and unset otherwise.
+ Let credentials flag be set if one of
- Let contentLengthValue be null.
+ If httpRequest's body is null and
- httpRequest's method is
- ` is true, and unset otherwise.
- If httpRequest's body is non-null and httpRequest's
- body's source is non-null, then set
- contentLengthValue to httpRequest's body's
- total bytes, UTF-8 encoded.
+ Let contentLengthValue be null.
- If contentLengthValue is non-null,
- append
- ` If httpRequest's body is null and
+ httpRequest's method is
+ ` If contentLengthValue is non-null and httpRequest's
- keepalive flag is set, then:
+ If httpRequest's body is non-null and httpRequest's
+ body's source is non-null, then set
+ contentLengthValue to httpRequest's body's
+ total bytes, UTF-8 encoded.
- Let inflightKeepaliveBytes be zero.
-
- Let group be httpRequest's client's fetch group.
-
- Let inflightRecords be the set of fetch records in
- group whose request has its
- keepalive flag set and done flag unset.
+ If contentLengthValue is non-null,
+ append
+ ` For each fetchRecord in inflightRecords:
+ If contentLengthValue is non-null and httpRequest's
+ keepalive flag is set, then:
Let inflightRequest be fetchRecord's
- request.
+ Let inflightKeepaliveBytes be zero.
- Increment inflightKeepaliveBytes by inflightRequest's
- body's total bytes.
- Let group be httpRequest's client's fetch group.
- If the sum of contentLengthValue and inflightKeepaliveBytes is
- greater than 64 kibibytes, then return a network error.
- Let inflightRecords be the set of fetch records in
+ group whose request has its
+ keepalive flag set and done flag unset.
- The above limit ensures that requests that are allowed to outlive the
- environment settings object and contain a body, have a bounded size and are not allowed to
- stay alive indefinitely.
-
- If httpRequest's referrer is a URL, then
- append ` If the CORS flag is set, httpRequest's method is
- neither ` For each fetchRecord in inflightRecords:
- If httpRequest's header list
- does not contain ` Let inflightRequest be fetchRecord's
+ request.
- If httpRequest's cache mode is " Increment inflightKeepaliveBytes by inflightRequest's
+ body's total bytes.
+ If httpRequest's cache mode is " If the sum of contentLengthValue and inflightKeepaliveBytes is
+ greater than 64 kibibytes, then return a network error.
+ If httpRequest's cache mode is
- " The above limit ensures that requests that are allowed to outlive the
+ environment settings object and contain a body, have a bounded size and are not allowed
+ to stay alive indefinitely.
- If httpRequest's header list
- does not contain ` If httpRequest's referrer is a URL, then
+ append ` If the CORS flag is set, httpRequest's method is
+ neither ` If httpRequest's header list
- does not contain ` If httpRequest's cache mode is " If httpRequest's cache mode is " Modify httpRequest's
- header list per HTTP.
-
- It would be great if we could make this more normative
- somehow. At this point headers such as
- ` ` ` If credentials flag is set, run these substeps:
- If the user agent is not configured to block cookies for httpRequest (see
- section 7 of
- [[!COOKIES]]), then run these substeps:
+ If httpRequest's cache mode is
+ " Let cookies be the result of running the "cookie-string" algorithm (see
- section 5.4 of
- [[!COOKIES]]) with the user agent's cookie store and
- httpRequest's current url.
+ If httpRequest's header list
+ does not contain ` If httpRequest's header list
+ does not contain ` If httpRequest's header list
- contains ` Let authorizationValue be null.
-
- If there's an authentication entry for httpRequest
- and either httpRequest's
- use-URL-credentials flag is
- unset or httpRequest's
- current url does not
- include credentials, set
- authorizationValue to authentication entry.
-
-
- Otherwise, if httpRequest's
- current url does
- include credentials and authentication-fetch flag is
- set, then set authorizationValue to httpRequest's
- current url,
- converted to an ` If authorizationValue is non-null,
- append
- ` Modify httpRequest's
+ header list per HTTP.
+
+ It would be great if we could make this more normative
+ somehow. At this point headers such as
+ ` ` ` If there's a proxy-authentication entry, use it as appropriate.
+ If credentials flag is set, run these substeps:
- This intentionally does not depend on
- httpRequest's
- credentials mode.
+ If the user agent is not configured to block cookies for httpRequest (see
+ section 7 of
+ [[!COOKIES]]), then run these substeps:
+
+ Let cookies be the result of running the "cookie-string" algorithm (see
+ section 5.4 of
+ [[!COOKIES]]) with the user agent's cookie store and
+ httpRequest's current url.
+
+ If httpRequest's header list
+ contains ` Let authorizationValue be null.
+
+ If there's an authentication entry for httpRequest
+ and either httpRequest's
+ use-URL-credentials flag is
+ unset or httpRequest's
+ current url does not
+ include credentials, set
+ authorizationValue to authentication entry.
+
+
+ Otherwise, if httpRequest's
+ current url does
+ include credentials and authentication-fetch flag is
+ set, then set authorizationValue to httpRequest's
+ current url,
+ converted to an ` If authorizationValue is non-null,
+ append
+ ` Let response and storedResponse be null.
+ If there's a proxy-authentication entry, use it as appropriate.
- Let the revalidatingFlag be unset.
+ This intentionally does not depend on
+ httpRequest's
+ credentials mode.
- If httpRequest's cache mode is neither " Let response and storedResponse be null.
+
+ Let the revalidatingFlag be unset.
- Set storedResponse to the result of selecting a response from the HTTP cache,
- possibly needing validation, as per the
- "Constructing Responses from Caches"
- chapter of HTTP Caching [[!HTTP-CACHING]], if any.
+ If httpRequest's cache mode is neither " If storedResponse is null, then abort these substeps.
+ Set storedResponse to the result of selecting a response from the HTTP cache,
+ possibly needing validation, as per the
+ "Constructing Responses from Caches"
+ chapter of HTTP Caching [[!HTTP-CACHING]], if any.
-
- If storedResponse requires validation (i.e., it is not fresh), then set the
- revalidatingFlag.
+ If storedResponse is null, then abort these substeps.
- If httpRequest's cache mode is " If storedResponse requires validation (i.e., it is not fresh), then set the
+ revalidatingFlag.
- As mandated by HTTP, this still takes the ` If the revalidatingFlag is set, then:
+ If httpRequest's cache mode is " If storedResponse's header list
- contains ` As mandated by HTTP, this still takes the ` If storedResponse's header list
- contains ` If the revalidatingFlag is set, then:
+
+ If storedResponse's header list
+ contains ` If storedResponse's header list
+ contains ` See also the
+ "Sending a Validation Request"
+ chapter of HTTP Caching [[!HTTP-CACHING]].
+
+ Otherwise, if the revalidatingFlag is unset, then set response to
+ storedResponse.
If the ongoing fetch is terminated, then:
+
+ Let aborted be the termination's aborted flag.
- See also the
- "Sending a Validation Request"
- chapter of HTTP Caching [[!HTTP-CACHING]].
+ If aborted is set, then return an aborted network error.
- Otherwise, if the revalidatingFlag is unset, then set response to
- storedResponse.
+ Return a network error.
If the ongoing fetch is terminated, then:
+
+ Let aborted be the termination's aborted flag.
+
+ If aborted is set, then return an aborted network error.
+
+ Return a network error.
+ Let username and password be the result of prompting the end user
for a username and password, respectively, in request's
window.
@@ -3561,6 +3668,17 @@ Range Requests. [[HTTP-RANGE]] However, this is not widely supported by b
Needs testing: multiple ` If the ongoing fetch is terminated, then:
+
+ Let aborted be the termination's aborted flag.
+
+ If aborted is set, then return an aborted network error.
+
+ Return a network error.
+ Prompt the end user as appropriate in request's
window and store the result as a
@@ -3590,6 +3708,8 @@ Range Requests. [[HTTP-RANGE]] However, this is not widely supported by b
Let credentials be true if credentials flag is set, and false otherwise.
+ Let response be null.
+
Switch on request's mode:
@@ -3606,70 +3726,85 @@ Range Requests. [[HTTP-RANGE]] However, this is not widely supported by b
origin and credentials.
- If connection is failure, return a
- network error.
-
- If connection is not an HTTP/2 connection, request's
- body is non-null, and request's body's
- source is null, then append
- ` Let response be the result of making an HTTP request over connection
- using request with the following caveats:
+ Run these steps, but abort if the ongoing fetch is terminated: Follow the relevant requirements from HTTP. [[!HTTP]] [[!HTTP-SEMANTICS]] [[!HTTP-COND]] [[!HTTP-CACHING]] [[!HTTP-AUTH]]
+ If connection is failure, return a
+ network error.
- Wait until all the headers are transmitted or
- fetch is being
- terminated with reason reason. If
- fetch is being
- terminated, then set response's
- termination reason to reason.
+ If connection is not an HTTP/2 connection, request's
+ body is non-null, and request's body's
+ source is null, then append
+ ` Any responses whose
- status is in the range Set response to the result of making an HTTP request over connection
+ using request with the following caveats:
- These kind of responses are
- eventually followed by a "final" response.
- Follow the relevant requirements from HTTP. [[!HTTP]] [[!HTTP-SEMANTICS]] [[!HTTP-COND]] [[!HTTP-CACHING]] [[!HTTP-AUTH]]
+
+ Wait until all the headers are transmitted.
+
+ Any responses whose
+ status is in the range The exact layering between Fetch and HTTP still needs to be sorted through and
- therefore response represents both a response and
- an HTTP response here.
+ These kind of responses are
+ eventually followed by a "final" response.
+ If request's header list contains
- ` The exact layering between Fetch and HTTP still needs to be sorted through and
+ therefore response represents both a response and
+ an HTTP response here.
- If the HTTP request results in a TLS client certificate dialog, run these substeps:
+ If request's header list contains
+ ` If request's window
- is an environment settings object, make the dialog
- available in request's
- window.
+ If the HTTP request results in a TLS client certificate dialog, run these substeps:
- Otherwise, return a network error.
+ If request's window
+ is an environment settings object, make the dialog
+ available in request's
+ window.
+
+ Otherwise, return a network error.
+ If response was retrieved over HTTPS, set its
+ HTTPS state to either
+ " The exact determination here is up to user agents for the
+ time being. User agents are strongly encouraged to only succeed HTTPS connections with
+ strong security properties and return
+ network errors otherwise. Using the
+ " Transmit body for request.
If response was retrieved over HTTPS, set its
- HTTPS state to either
- " If the ongoing fetch is terminated, then:
+
+ Let aborted be the termination's aborted flag.
+
+ If connection is an HTTP/2 connection, then transmit an
+ " The exact determination here is up to user agents for the
- time being. User agents are strongly encouraged to only succeed HTTPS connections with
- strong security properties and return
- network errors otherwise. Using the
- " If aborted is set, then return an aborted network error.
- Transmit body for request.
+ Return a network error.
+ Let strategy be an object. The user agent may choose any object.
@@ -3677,12 +3812,11 @@ Range Requests. [[HTTP-RANGE]] However, this is not widely supported by b
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 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 cancel be an action that terminates the
+ ongoing fetch with the aborted flag set.
Let stream be the result of
@@ -3691,132 +3825,160 @@ Range Requests. [[HTTP-RANGE]] However, this is not widely supported by b
pull and cancel.
This construction operation will not throw an exception.
- Set response's body to a new
- body whose stream is
- stream.
+ Run these steps, but abort if the ongoing fetch is terminated: If response has a payload body length, then set response's
- body's
- total bytes to that payload body length.
-
+ Set response's body to a new
+ body whose stream is
+ stream.
- Delete
- ` If response has a payload body length, then set response's
+ body's
+ total bytes to that payload body length.
+
- Extracting header list values given ` Extracting header list values given ` Delete
+ ` Extracting header list values given ` Extracting header list values given ` This deals with broken Apache configurations. Ideally HTTP would define
- this.
-
+ This deals with broken Apache configurations. Ideally HTTP would define
+ this.
+
- Gecko
- bug 1030660 looks
- into whether this quirk can be removed.
+ Gecko
+ bug 1030660 looks
+ into whether this quirk can be removed.
- Execute
- set response's CSP list
- on response. [[!CSP]]
+ Execute
+ set response's CSP list
+ on response. [[!CSP]]
- If response is not a
- network error and request's
- cache mode is not " If response is not a
+ network error and request's
+ cache mode is not " If credentials flag is set and the user agent is not configured to block cookies for
+ request (see section 7 of
+ [[!COOKIES]]), then run the "set-cookie-string" parsing algorithm (see section 5.2 of [[!COOKIES]]) on the value of each header whose name is a
+ byte-case-insensitive match for ` This is a fingerprinting vector.
+ If credentials flag is set and the user agent is not configured to block cookies for
- request (see section 7 of
- [[!COOKIES]]), then run the "set-cookie-string" parsing algorithm (see
- section 5.2 of
- [[!COOKIES]]) on the value
- of each header whose name is a byte-case-insensitive match for
- ` If the ongoing fetch is terminated, then:
+
+ Let aborted be the termination's aborted flag.
- This is a fingerprinting vector.
+ If aborted is set, then set response's
+ aborted flag.
+
+ Return response.
+ Run these substeps in parallel:
Whenever one or more bytes are transmitted from response's message body, let
- bytes be the transmitted bytes and run these subsubsteps:
-
+ While true, breaking if the ongoing fetch terminates:
Increase response's
- body's
- transmitted bytes with bytes'
- length.
+ If one or more bytes have been transmitted from response's message body, then:
- Let codings be the result of extracting header list values given
- ` Let bytes be the transmitted bytes.
- Set bytes to the result of handling
- content codings given codings and bytes.
+ Increase response's body's transmitted
+ bytes with bytes' length.
- This makes the ` Let codings be the result of extracting header list values given
+ ` Enqueue a If stream doesn't need more
- data and request's synchronous flag is unset, ask the user agent
- to suspend the ongoing fetch.
+ Set bytes to the result of handling content
+ codings given codings and bytes.
+
+ This makes the ` Enqueue a 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.
If at any point the bytes transmission for response's message body is done
- normally and stream is readable,
- then close stream.
-
+ The following steps can only occur if the ongoing fetch terminates.
+
+ Let aborted be the termination's aborted flag.
If at any point fetch is
- terminated with reason reason,
- run these subsubsteps:
+ If aborted is set, then:
Set response's termination
- reason to reason.
+ Set response's aborted flag.
- If stream is readable, error
+ stream with an " Otherwise, if stream is readable,
+ error stream with a If connection is an HTTP/2 connection, then transmit an
+ " Otherwise, the user agent should close connection unless it would be bad for
+ performance to do so.
+
+ For instance, the user agent could keep the connection open if it knows there's
+ only a few bytes of transfer remaining on a reusable connection. In this case it could be worse
+ to close the connection and go through the handshake process again for the next fetch.
These are run in parallel
- as at this point it is unclear whether response's
- body is relevant (response
- might be a redirect).
+ These are run in parallel as at this point it is unclear whether
+ response's body is relevant (response might be a
+ redirect).
- Return response. Typically
- response's body's
- stream is still being enqueued to after returning.
+ Return response. Typically response's
+ body's stream is still being enqueued to after
+ returning.
Let origin be the result of extracting header list values given
- ` Let origin be the result of extracting header list values given
+ ` The above will fail for network errors, as they have no headers.
If origin is null or failure, return failure.
@@ -4679,6 +4844,7 @@ interface Request {
readonly attribute RequestRedirect redirect;
readonly attribute DOMString integrity;
readonly attribute boolean keepalive;
+ readonly attribute AbortSignal signal;
[NewObject] Request clone();
};
@@ -4695,6 +4861,7 @@ dictionary RequestInit {
RequestRedirect redirect;
DOMString integrity;
boolean keepalive;
+ AbortSignal? signal;
any window; // can only be set to null
};
@@ -4716,6 +4883,9 @@ omitted from A {{Request}} object also has an associated headers (null or a
{{Headers}} object), initially null.
+ A {{Request}} object has an associated signal (an {{AbortSignal}} object),
+initially a new {{AbortSignal}} object.
+
A {{Request}} object's body is its
request's
body.
@@ -4736,6 +4906,8 @@ constructor must run these steps:
Let baseURL be current settings object's
API base URL.
+ Let signal be null.
+
If input is a string, then run these substeps:
@@ -4766,6 +4938,8 @@ constructor must run these steps:
Set request to input's
request.
+
+ Set signal to input's signal.
Let origin be current settings object's
@@ -4935,12 +5109,23 @@ constructor must run these steps:
to method.
If init's Let r be a new {{Request}} object associated with request.
Set r's headers to a new {{Headers}} object, whose
header list is request's header list, and
guard is " If signal is not null, then
+ add the following abort steps to signal:
+
+ Signal abort on r's signal.
+ Let headers be a copy of r's headers and its
associated header list.
@@ -5099,6 +5284,9 @@ must return request's
must return true if request's keepalive flag
is set, and false otherwise.
+ The The If context object's signal's aborted flag
+ is set, set clonedRequestObject signal's
+ aborted flag.
+
+ Otherwise, add the following abort steps to context object's
+ signal:
+
+ Signal abort on clonedRequestObject
+ signal.
+ Return clonedRequestObject.
Let p be a new promise.
- Let request be the associated
- request of the result of invoking the initial value of
- {{Request}} as constructor with input and
- init as arguments. If this throws an exception, reject
- p with it and return p.
+ Let requestObject be the result of invoking the initial value of {{Request}} as
+ constructor with input and init as arguments. If this throws an exception,
+ reject p with it and return p
+
+ Let request be requestObject's request.
+
+ If requestObject's signal's aborted flag
+ is set, then:
+
+ Abort fetch with p, request, and null.
+
+ Return p.
+ Let locallyAborted be false.
+
+ This lets us reject promises with predictable timing, when the request to abort
+ comes from the same thread as the call to fetch.
+
+ Add the following abort steps to requestObject's
+ signal:
+
+ Set locallyAborted to true.
+
+ Abort fetch with p, request, and
+ responseObject.
+
+ Terminate the ongoing fetch with the aborted flag set.
+ Run the following in parallel:
@@ -5389,9 +5619,14 @@ method, must run these steps:
To process response for response, run these substeps:
If response's type is
- " If locallyAborted is true, terminate these substeps.
+
+ If response's aborted flag is set, then abort fetch
+ with p, request, and responseObject, and terminate these
+ substeps.
+
+ If response is a network error, then reject p with a
+ Associate responseObject with response.
@@ -5401,9 +5636,25 @@ method, must run these steps:
To process response done for response, run these substeps:
If locallyAborted is true, terminate these substeps.
+
Let trailerObject be a new {{Headers}} object whose
guard is " If response's trailer failed flag is set, then:
+
+ If response's aborted flag is set, reject
+ responseObject's trailer promise with an
+ " Otherwise, reject responseObject's trailer promise with
+ a Terminate these substeps.
+ Associate trailerObject with response's
trailer.
@@ -5415,11 +5666,41 @@ method, must run these steps:
Return p.
To abort fetch with a promise, request, and
+responseObject, run these steps:
+
+ Let error be an " Reject promise with error.
+
+ This is a no-op if promise has already fulfilled.
+
+ If request's body is not null and is
+ readable, then cancel request's
+ body with error.
+
+ If responseObject is null, then return.
+
+ Reject responseObject's trailer promise with error.
+
+ This is a no-op if responseObject's trailer promise
+ has already fulfilled.
+
+ Let response be responseObject's response.
+
+ If response's body is not null and is
+ readable, then error
+ response's body with error.
+ The user agent may terminate an ongoing fetch with
-reason garbage collection if that termination is not observable through script.
+ The user agent may terminate an ongoing fetch with if that
+termination is not observable through script.
"Observable through script" means observable through
blob
"
-
GET
` or blob is null, then return a
- network error.
+ GET
` method restriction
- serves no useful purpose other than being interoperable.
+
+
+
+ GET
` or blob is null, then return a
+ network error.
- Content-Length
`/blob's
- {{Blob/size}} attribute value to
- response's
- header list.
+ GET
` method restriction
+ serves no useful purpose other than being interoperable.
- Content-Type
`/blob's
- {{Blob/type}} attribute value to
- response's
- header list.
+ Content-Length
`/blob's
+ {{Blob/size}} attribute value to
+ response's
+ header list.
- Content-Type
`/blob's
+ {{Blob/type}} attribute value to
+ response's
+ header list.
- data
"
@@ -2936,8 +3018,7 @@ optional CORS flag and CORS-preflight flag, run these steps:
url list has more than one item.
-
- no-window
" and
- request's redirect mode is "error
", then set
- httpRequest to request.
-
-
- no-window
" and
+ request's redirect mode is "error
", then set
+ httpRequest to request.
-
-
+ include
"
- same-origin
" and request's
- response tainting is "basic
"
-
+
- include
"
+ same-origin
" and request's
+ response tainting is "basic
"
+ POST
` or `PUT
`, then set contentLengthValue to
- `0
`.
-
+ Content-Length
`/contentLengthValue to
- httpRequest's
- header list.
+ POST
` or `PUT
`, then set contentLengthValue to
+ `0
`.
+
-
-
+ Content-Length
`/contentLengthValue to
+ httpRequest's
+ header list.
-
+ Referer
`/httpRequest's
- referrer, serialized and UTF-8 encoded, to
- httpRequest's header list.
-
-
- GET
` nor `HEAD
`, or httpRequest's
- mode is "websocket
", then append
- `Origin
`/httpRequest's origin,
- serialized and UTF-8 encoded, to
- httpRequest's header list.
-
+ User-Agent
`, then user agents should
- append
- `User-Agent
`/default `User-Agent
` value
- to httpRequest's header list.
+
+
- default
" and
- httpRequest's header list contains
- `If-Modified-Since
`,
- `If-None-Match
`,
- `If-Unmodified-Since
`,
- `If-Match
`, or
- `If-Range
`, then set httpRequest's
- cache mode to "no-store
".
+ no-cache
" and
- httpRequest's header list does not contain
- `Cache-Control
`, then append
- `Cache-Control
`/`max-age=0
` to
- httpRequest's header list.
+ no-store
" or "reload
", run these substeps:
+
-
-
- Pragma
`, then
- append `Pragma
`/`no-cache
` to
+ Referer
`/httpRequest's
+ referrer, serialized and UTF-8 encoded, to
httpRequest's header list.
+
+
+ GET
` nor `HEAD
`, or httpRequest's
+ mode is "websocket
", then append
+ `Origin
`/httpRequest's origin,
+ serialized and UTF-8 encoded, to
+ httpRequest's header list.
+
Cache-Control
`, then
- append `Cache-Control
`/`no-cache
` to
+ does not contain `User-Agent
`, then user agents should
+ append
+ `User-Agent
`/default `User-Agent
` value
+ to httpRequest's header list.
+
+ default
" and
+ httpRequest's header list contains
+ `If-Modified-Since
`,
+ `If-None-Match
`,
+ `If-Unmodified-Since
`,
+ `If-Match
`, or
+ `If-Range
`, then set httpRequest's
+ cache mode to "no-store
".
+
+ no-cache
" and
+ httpRequest's header list does not contain
+ `Cache-Control
`, then append
+ `Cache-Control
`/`max-age=0
` to
httpRequest's header list.
-
- Accept-Encoding
`,
- `Connection
`,
- `DNT
`, and
- `Host
`,
- are to be appended if necessary.
-
- Accept
`,
- `Accept-Charset
`, and
- `Accept-Language
` must not be included at this point.
-
- Accept
` and
- `Accept-Language
` are already included (unless
- fetch()
is used, which does not include the latter by
- default), and `Accept-Charset
` is a waste of bytes. See
- HTTP header layer division for more details.
-
-
+ no-store
" or "reload
", run these substeps:
-
- Pragma
`, then
+ append `Pragma
`/`no-cache
` to
+ httpRequest's header list.
- Cookie
`/cookies to httpRequest's
- header list.
+ Cache-Control
`, then
+ append `Cache-Control
`/`no-cache
` to
+ httpRequest's header list.
+
Authorization
`, then terminate these substeps.
-
-
- Authorization
` value.
-
- Authorization
`/authorizationValue to
- httpRequest's
- header list.
- Accept-Encoding
`,
+ `Connection
`,
+ `DNT
`, and
+ `Host
`,
+ are to be appended if necessary.
+
+ Accept
`,
+ `Accept-Charset
`, and
+ `Accept-Language
` must not be included at this point.
+
+ Accept
` and
+ `Accept-Language
` are already included (unless
+ fetch()
is used, which does not include the latter by
+ default), and `Accept-Charset
` is a waste of bytes. See
+ HTTP header layer division for more details.
-
+
-
+
+
+ Cookie
`/cookies to httpRequest's
+ header list.
+ Authorization
`, then terminate these substeps.
+
+
+ Authorization
` value.
+
+ Authorization
`/authorizationValue to
+ httpRequest's
+ header list.
+ no-store
"
- nor "reload
", run these substeps:
+
@@ -5367,11 +5568,21 @@ method, must run these steps:
no-store
"
+ nor "reload
", run these substeps:
-
+
+
+ force-cache
" or
- "only-if-cached
", then set response to storedResponse and
- abort these substeps.
+
+ Vary
` header
- into account.
-
- force-cache
" or
+ "only-if-cached
", then set response to storedResponse and
+ abort these substeps.
-
-
+ ETag
`, then append
- `If-None-Match
` with its value to httpRequest's
- header list.
+ Vary
`
+ header into account.
- Last-Modified
`, then
- append `If-Modified-Since
` with its value to
- httpRequest's header list.
+
+
+
+ ETag
`, then append
+ `If-None-Match
` with its value to httpRequest's
+ header list.
+
+ Last-Modified
`, then
+ append `If-Modified-Since
` with its value to
+ httpRequest's header list.
+
+
+
+
+
+
Proxy-Authenticate
` headers, missing,
parsing issues.
+
+
+
@@ -4066,9 +4228,12 @@ Entries may be removed before that moment arrives.
request and response, run these steps:
Transfer-Encoding
`/`chunked
` to request's
- header list.
-
+
+
Transfer-Encoding
`/`chunked
` to request's
+ header list.
100
to
- 199
, inclusive, and is not 101
, are to be ignored.
+
+
- 100
to
+ 199
, inclusive, and is not 101
, are to be ignored.
- Transfer-Encoding
`/`chunked
` and response is transferred
- via HTTP/1.0 or older, then return a network error.
+ Transfer-Encoding
`/`chunked
` and response is transferred
+ via HTTP/1.0 or older, then return a network error.
-
-
-
+
+
+ deprecated
" or "modern
".
+ [[!TLS]]
+
+ deprecated
" state value ought to be a temporary and last resort kind
+ of option.
+
+ deprecated
" or "modern
".
- [[!TLS]]
+
+
RST_STREAM
" to cancel the underlying stream.
- deprecated
" state value ought to be a temporary and last resort kind
- of option.
+
+
Content-Encoding
` from response's
- header list if one of the following
- conditions is true:
+
-
+ Content-Encoding
` and
- response's header list returns
- `gzip
`, and extracting header list values given `Content-Type
`
- and response's header list returns
- `application/gzip
`, `application/x-gunzip
`, or
- `application/x-gzip
`.
-
- Content-Encoding
` and
- response's header list returns `compress
`, and
- extracting header list values given `Content-Type
` and response's
- header list returns `application/compress
` or
- `application/x-compress
.
- Content-Encoding
` from response's
+ header list if one of the following
+ conditions is true:
+
+
+
- Content-Encoding
` and
+ response's header list returns
+ `gzip
`, and extracting header list values given `Content-Type
`
+ and response's header list returns
+ `application/gzip
`, `application/x-gunzip
`, or
+ `application/x-gzip
`.
+
+ Content-Encoding
` and
+ response's header list returns `compress
`, and
+ extracting header list values given `Content-Type
` and
+ response's header list returns
+ `application/compress
` or `application/x-compress
.
+ no-store
",
- update response in the HTTP cache for request.
-
+ no-store
",
+ update response in the HTTP cache for request.
+
+
+ Set-Cookie
` in response's header list, if any, and request's current url.
+
+ Set-Cookie
` in response's header list, if any, and
- request's current url.
+
+
-
-
- Content-Encoding
` and response's header list.
+
+
+
+ Content-Length
`
- header unreliable to the extent that it was reliable
- to begin with.
+ Content-Encoding
` and response's header list.
- Uint8Array
- object wrapping an ArrayBuffer
containing bytes to stream.
- If that threw an exception, terminate the ongoing
- fetch with fatal, error
- stream with that exception and abort these subsubsteps.
-
- Content-Length
` header
+ unreliable to the extent that it was reliable to begin with.
+
+ Uint8Array
object wrapping an
+ ArrayBuffer
containing bytes to stream. If that threw an
+ exception, terminate the ongoing fetch, and
+ error stream with that exception.
+
+
-
+
+ AbortError
" {{DOMException}}.
TypeError
.
+
+ RST_STREAM
" to cancel the underlying stream.
+
+
-
Access-Control-Allow-Origin
` and response's
- header list.
+ Access-Control-Allow-Origin
` and response's
+ header list.
+
+ RequestMode
as it cannot be used nor obser
signal
member is present, then set signal to
+ it.
+
request
".
+
+
+
signal
attribute's getter must return the
+associated signal.
+
clone()
method, when invoked, must
@@ -5120,6 +5308,19 @@ run these steps:
header list, and guard is context object's
headers' guard.
+
+
+
+
immutable
".
+
+
+
-
error
", reject p with a TypeError
and terminate
- these substeps.
+ TypeError
and terminate these substeps.
+
+immutable
".
+
+
+
AbortError
" {{DOMException}}.
+
+ TypeError
.
+
+
+
+
AbortError
" {{DOMException}}.
+
+ Garbage collection
-fetch()
's arguments and return value. Other ways, such as