diff --git a/fetch.bs b/fetch.bs index 9f09743e5..e35485f38 100644 --- a/fetch.bs +++ b/fetch.bs @@ -194,8 +194,74 @@ lt="authentication entry">authentication entries (for HTTP authentication).
A fetch timing info is a struct used to maintain timing information +later required by the resource timing and navigation timing specs. It has the following +items: +
A connection timing info is a struct used to maintain timing +information pertaining to the process of obtaining a connection. It has the following +items: +
DOMHighResTimeStamp and +unsafe shared current time +are defined in [[HR-TIME]]. + +
Note that timestamps in this spec are usually unsafe, and are meant to be coarsened +and normalized to a global object prior to being exposed. + +
To clamp connection timing info, given connection timing info +timingInfo and DOMHighResTimeStamp defaultStartTime, run these +steps: +
If timingInfo's connection start time is + greater than defaultStartTime, then return timingInfo. +
Otherwise, return a new connection timing info, with + domain lookup start time set to defaultStartTime, + domain lookup end time set to defaultStartTime, + connection start time set to defaultStartTime, + connection end time set to defaultStartTime, + secure connection start time set to + defaultStartTime, and alpn negotiated protocol + set to timingInfo's alpn negotiated protocol. +
To queue a fetch task, given an algorithm algorithm, a global object or a parallel queue taskDestination, run these steps: @@ -1107,8 +1173,10 @@ must be an algorithm accepting an exception.
Queue a fetch task given processEndOfBody and - taskDestination.
Queue a fetch task given processEndOfBody and + taskDestination. +
Queue a fetch task to run processBodyError given e,
@@ -1855,6 +1923,9 @@ Unless stated otherwise, it is "default
".
This indicates that the request was intentionally aborted by the developer or end-user. +
A response can have an associated fetch timing info +timing info, initially null. +
A response has an associated URL. It is a pointer to the last URL in response's URL list and null if @@ -2144,6 +2215,9 @@ unset or keepalive is false, termi identified by a key (a network partition key), an origin (an origin), and credentials (a boolean). +
Each connection has an associated connection timing info +timingInfo, initially a new connection timing info. +
To obtain a connection, given a key, origin, credentials, an optional boolean forceNew (default false), an optional boolean http3Only (default @@ -2168,15 +2242,14 @@ false), and an optional boolean dedic
Let connection be null. -
Run these steps, but abort when 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]] + origin, while recording connnection timing info for connection. + [[!HTTP]] [[!HTTP-SEMANTICS]] [[!HTTP-COND]] [[!HTTP-CACHING]] [[!HTTP-AUTH]] [[!TLS]]
If http3Only is true, then establish an HTTP/3 connection. [[!HTTP3]] @@ -2215,6 +2288,86 @@ clearly stipulates that connections are keyed on +
When recording connnection timing info given a connection, perform the +following steps: +
Let timingInfo be connection's timingInfo. +
Example: Suppose the user agent establishes an HTTP/2 connection
+ over TLS 1.3 to send a GET request and a POST request. It sends the ClientHello
+ at time t1
and then sends the GET request with early data. The
+ POST request is not safe [[HTTP-SEMANTICS]] (section 4.2.1), so the user agent waits
+ to complete the handshake at time t2
before sending it. Although
+ both requests used the same connection, the GET request reports a connectEnd
+ value of t1
, while the POST request reports a connectEnd value for
+ t2
.
When a proxy is configured, if a tunnel connection is established then this attribute + MUST return the ALPN Protocol ID of the tunneled protocol, otherwise it MUST return the ALPN + Protocol ID of the first hop to the proxy. +
Octets in the ALPN protocol MUST NOT be percent-encoded if they are valid token + characters except "%", and when using percent-encoding, uppercase hex digits MUST be used. +
Formally registered ALPN protocol IDs are documented by + IANA. +
In case the user agent is using an experimental, non-registered protocol, the user + agent MUST use the ALPN negotiated value if any. If ALPN was not used for protocol + negotiations, the user agent MAY use another descriptive string. +
The "h3" ALPN ID is defined for the final version + of the HTTP/3 protocol in the + HTTP/3 + Internet Draft. +
Note that alpn negotiated protocol is + intended to identify the network protocol in use for the fetch regardless of how it was + actually negotiated; that is, even if ALPN is not used to negotiate the network protocol, + this attribute still uses the ALPN Protocol IDs to indicate the protocol in use. +
Let fetchParams be a new fetch params whose request is request, + timing info is a new fetch timing info, process request body is processRequestBody, process request end-of-body is processRequestEndOfBody, process response is processResponse, @@ -3439,6 +3593,10 @@ steps:
Let response be null. +
Set fetchParams's timing info's + fetch start time to the result of calling + unsafe shared current time. +
If request's local-URLs-only flag is set and request's current URL is not local, then set response to a network error. @@ -3763,11 +3921,41 @@ steps:
Wait for either response's body to be null, or response's body's stream to be - closed or errored, and then set - request's done flag. - + closed or errored, and perform the following steps: +
Set request's done flag. + +
To handle response end, given fetch params fetchParams and +response response, perform the following steps: +
"report"
+ "document"
+ "frame"
+ TODO: enqueue in [[resource-timing]] with timingInfo, + requestedURL and globalObject. See + Issue #252. +
Let actualResponse be null. +
Let timingInfo be fetchParams's timing info +
If request's service-workers mode is "all
", then:
@@ -4031,8 +4221,9 @@ these steps:
internal response is actualResponse.
follow
"
- Set response to the result of running HTTP-redirect fetch given - fetchParams and response. +
Set timingInfo's redirect start time to + timingInfo's fetch start time, and set response to + the result of running HTTP-redirect fetch given fetchParams and response. @@ -4122,6 +4313,9 @@ run these steps:
request's body's source's nullity has already been checked. +
Set fetchParams's timing info's + redirect end time to the unsafe shared current time. +
Append locationURL to request's URL list. @@ -4710,6 +4904,8 @@ optional boolean forceNewConnection (default false), run these steps:
Let response be null. +
Let timingInfo be fetchParams's timing info. +
Let httpCache be the result of determining the HTTP cache partition, given httpRequest. @@ -4735,6 +4931,11 @@ optional boolean forceNewConnection (default false), run these steps: includeCredentials, and forceNewConnection. +
Run these steps, but abort when the ongoing fetch is terminated:
@@ -4748,6 +4949,9 @@ optional boolean forceNewConnection (default false), run these steps:
`Transfer-Encoding
`/`chunked
` to request's
header list.
+
Set response to the result of making an HTTP request over connection
using request with the following caveats:
@@ -4773,6 +4977,9 @@ optional boolean forceNewConnection (default false), run these steps:
`Transfer-Encoding
`/`chunked
` and response is transferred
via HTTP/1.0 or older, then return a network error.
+
Set timingInfo's response start time to + the unsafe shared current time. +
If the HTTP request results in a TLS client certificate dialog, then:
Let timingInfo be the fetchParams's timing info. +
Run these steps, but abort when the ongoing fetch is terminated: @@ -4938,6 +5147,12 @@ optional boolean forceNewConnection (default false), run these steps:
Let codings be the result of extracting header list values given
`Content-Encoding
` and response's header list.
+
Increase timingInfo's encoded body size + by bytes's length. + +
TODO: add tests to verify that this works in the case where the
+ `Content-Length
` headercontent-length is missing or incorrect.
+
Set bytes to the result of handling content codings given codings and bytes. @@ -4945,6 +5160,9 @@ optional boolean forceNewConnection (default false), run these steps:
This makes the `Content-Length
` header
unreliable to the extent that it was reliable to begin with.
+
Increase timingInfo's decoded body size by + bytes's length. +
If bytes is failure, then terminate the ongoing fetch. @@ -4960,10 +5178,10 @@ optional boolean forceNewConnection (default false), run these steps:
Otherwise, if the bytes transmission for response's message body is done normally and stream is readable, then - close stream and abort these in-parallel steps. + close stream, Call handle response end + with fetchParams and response, and abort these in-parallel steps.
If aborted, then: @@ -4974,8 +5192,13 @@ optional boolean forceNewConnection (default false), run these steps:
If aborted is set, then:
Call handle response end with fetchParams and response. +
Set response's aborted flag. +
Set timingInfo's response end time to + the unsafe shared current time. +
If stream is readable,
error stream with an
"AbortError
" {{DOMException}}.