Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c18e61a

Browse files
committed
Expose resource info separately
1 parent f4a7bab commit c18e61a

1 file changed

Lines changed: 42 additions & 99 deletions

File tree

fetch.bs

Lines changed: 42 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,12 @@ lt="authentication entry">authentication entries</a> (for HTTP authentication).
210210
<dt><dfn for="fetch params">cross-origin isolated capability</dfn> (default false)
211211
<dd>A boolean.
212212

213-
<dt><dfn for="fetch params">controller</dfn> (default a new <a for=/>fetch controller</a>)
214-
<dd>A <a for=/>fetch controller</a>.
215-
216213
<dt><dfn for="fetch params">timing info</dfn>
217214
<dd>A <a for=/>fetch timing info</a>.
218215

216+
<dt><dfn for="fetch params">controller</dfn>
217+
<dd>A <a for=/>fetch controller</a>.
218+
219219
<dt><dfn export for="fetch params">preloaded response candidate</dfn> (default null)
220220
<dd>Null, "<code>pending</code>", or a <a for=/>response</a>.
221221
</dl>
@@ -229,6 +229,9 @@ lt="authentication entry">authentication entries</a> (for HTTP authentication).
229229
<dd>"<code>requesting</code>", "<code>responding</code>", "<code>concluded</code>",
230230
"<code>terminated</code>", or "<code>aborted</code>"
231231

232+
<dt><dfn for="fetch controller">timing info</dfn>
233+
<dd>A <a for=/>fetch timing info</a>
234+
232235
<dt><dfn for="fetch controller">conclude steps</dfn> (default null)
233236
<dd>Null or an algorithm responsible for finalizing the fetch and reporting timing information
234237
</dl>
@@ -242,10 +245,11 @@ lt="authentication entry">authentication entries</a> (for HTTP authentication).
242245
"<code>terminated</code>".
243246

244247
<p>To <dfn export for="fetch controller" id="finalize-and-report-timing">conclude</dfn> a
245-
<a for=/>fetch controller</a> <var>controller</var>, perform the following steps given a string
246-
<var>initiatorType</var>, an optional "<code>client</code>" or <a for=/>global object</a>
247-
<var>global</var> (default "<code>client</code>"), and an optional "<code>original</code>" or
248-
<a for=/>response</a> <var>finalResponse</var> (default "<code>original</code>"):</p>
248+
<a for=/>fetch controller</a> <var>controller</var>, perform the following steps given an optional
249+
string <var>initiatorType</var> (default "<code>other</code>"), an optional "<code>client</code>" or
250+
<a for=/>global object</a> <var>global</var> (default "<code>client</code>"), and an optional
251+
"<code>original</code>" or <a for=/>response</a> <var>finalResponse</var> (default
252+
"<code>original</code>"):</p>
249253

250254
<ol>
251255
<li><p>If <a>this</a>'s <a for="fetch controller">state</a> is "<code>aborted</code>", then return.
@@ -284,37 +288,27 @@ following <a for=struct>items</a>: [[RESOURCE-TIMING]] [[NAVIGATION-TIMING]]
284288
<dt><dfn export for="fetch timing info">end time</dfn> (default 0)
285289
<dd>A {{DOMHighResTimeStamp}}.
286290

287-
<dt><dfn export for="fetch timing info">encoded body size</dfn> (default 0)
288-
<dt><dfn export for="fetch timing info">decoded body size</dfn> (default 0)
289-
<dd>A number.
290-
291291
<dt><dfn export for="fetch timing info">final connection timing info</dfn> (default null)
292292
<dd>Null or a <a for=/>connection timing info</a>.
293293
</dl>
294294

295+
<p>A <dfn export>fetch resource info</dfn> is a <a for=/>struct</a> used to maintain
296+
information needed by <cite>Resource Timing</cite> and <cite>Navigation Timing</cite>. It has the
297+
following <a for=struct>items</a>: [[RESOURCE-TIMING]] [[NAVIGATION-TIMING]]
298+
299+
<dl>
300+
<dt><dfn export for="fetch resource info">encoded body size</dfn> (default 0)
301+
<dt><dfn export for="fetch resource info">decoded body size</dfn> (default 0)
302+
<dd>A number.
303+
</dl>
304+
295305
<p>To
296306
<dfn export lt="create an opaque timing info|creating an opaque timing info">create an opaque timing info</dfn>,
297307
given a <a for=/>fetch timing info</a> <var>timingInfo</var>, return a new
298308
<a for=/>fetch timing info</a> whose <a for="fetch timing info">start time</a> and
299309
<a for="fetch timing info">post-redirect start time</a> are <var>timingInfo</var>'s
300310
<a for="fetch timing info">start time</a>.
301311

302-
<p>To <dfn>update timing info from stored response</dfn>, given a
303-
<a for=/>connection timing info</a> <var>timingInfo</var> and a <a for=/>response</a>
304-
<var>response</var>, perform the following steps:
305-
306-
<ol>
307-
<li><p>Let <var>storedTimingInfo</var> be <var>response</var>'s <a for=response>timing info</a>.
308-
309-
<li><p>If <var>storedTimingInfo</var> is null, then return.
310-
311-
<li><p>Set <var>timingInfo</var>'s <a for="fetch timing info">encoded body size</a> to
312-
<var>storedTimingInfo</var>'s <a for="fetch timing info">encoded body size</a>.
313-
314-
<li><p>Set <var>timingInfo</var>'s <a for="fetch timing info">decoded body size</a> to
315-
<var>storedTimingInfo</var>'s <a for="fetch timing info">decoded body size</a>.
316-
</ol>
317-
318312
<p>To <dfn>queue a fetch task</dfn>, given an algorithm <var>algorithm</var>, a
319313
<a for=/>global object</a> or a <a for=/>parallel queue</a> <var>taskDestination</var>, run these
320314
steps:
@@ -2100,6 +2094,11 @@ message as HTTP/2 does not support them.
21002094
"<code>local</code>", or "<code>validated</code>"). Unlesss stated otherwise, it is the empty
21012095
string.
21022096

2097+
<p>A <a for=/>response</a> has an associated
2098+
<dfn export for=response id=concept-response-resource-info>resource info</dfn>
2099+
(a <a for=/>fetch resource info</a>). Unlesss stated otherwise, it is a new
2100+
<a for=/>fetch resource info</a>.
2101+
21032102
<p class=note>This is intended for usage by <cite>Service Workers</cite> and
21042103
<cite>Resource Timing</cite>. [[SW]] [[RESOURCE-TIMING]]
21052104
<!-- If we ever expand the utility of this we need to carefully consider whether filtered responses
@@ -2135,10 +2134,6 @@ allowed on the resource fetched by looking at the flag of the response returned.
21352134
the response of a redirect has to be set if it was set for previous responses in the redirect chain,
21362135
this is also tracked internally using the request's <a for=request>timing allow failed flag</a>.
21372136

2138-
<p>A <a for=/>response</a> has an associated
2139-
<dfn for=response id=concept-response-timing-info>timing info</dfn> (null or a
2140-
<a for=/>fetch timing info</a>), which is initially null.
2141-
21422137
<p>A <a for=/>response</a> has an associated
21432138
<dfn export for=response>service worker timing info</dfn> (null or a
21442139
<a for=/>service worker timing info</a>), which is initially null.
@@ -3866,9 +3861,13 @@ the request.
38663861
<a for="fetch timing info">post-redirect start time</a> are the
38673862
<a for=/>coarsened shared current time</a> given <var>crossOriginIsolatedCapability</var>.
38683863

3864+
<li><p>Let <var>controller</var> be a new <a for=/>fetch controller</a> whose
3865+
<a for="fetch controller">timing info</a> is <var>timingInfo</var>.
3866+
38693867
<li><p>Let <var>fetchParams</var> be a new <a for=/>fetch params</a> whose
38703868
<a for="fetch params">request</a> is <var>request</var>,
38713869
<a for="fetch params">timing info</a> is <var>timingInfo</var>,
3870+
<a for="fetch params">controller</a> is <var>controller</var>,
38723871
<a for="fetch params">process request body chunk length</a> is
38733872
<var>processRequestBodyChunkLength</var>,
38743873
<a for="fetch params">process request end-of-body</a> is <var>processRequestEndOfBody</var>,
@@ -4319,8 +4318,6 @@ steps:
43194318
<li><p>Let <var>timingInfo</var> be <var>fetchParams</var>'s
43204319
<a for="fetch params">timing info</a>.</p></li>
43214320

4322-
<li><p>Set <var>response</var>'s <a for=response>timing info</a> to <var>timingInfo</var>.</p></li>
4323-
43244321
<li><p>Set <var>fetchParams</var>'s <a for="fetch params">controller</a>'s
43254322
<a for="fetch controller">state</a> to "<code>responding</code>".
43264323

@@ -4349,10 +4346,13 @@ steps:
43494346

43504347
<li><p>Let <var>cacheState</var> be <var>response</var>'s <a for=response>cache state</a>.
43514348

4349+
<li><p>Let <var>resourceInfo</var> be <var>response</var>'s <a for=response>resource info</a>.
4350+
43524351
<li>
43534352
<p>If <var>finalResponse</var>'s <a for=response>timing allow passed flag</a> is not set,
43544353
then set <var>timingInfo</var> to a the result of <a>creating an opaque timing info</a> for
4355-
<var>timingInfo</var> and set <var>cacheState</var> to the empty string.
4354+
<var>timingInfo</var>, set <var>resourceInfo</var> to a new <a for=/>fetch resource info</a> and
4355+
set <var>cacheState</var> to the empty string.
43564356

43574357
<p class=note>This covers the case of <var>finalResponse</var> being a <a>network error</a>.
43584358
</li>
@@ -4363,7 +4363,8 @@ steps:
43634363
<a for="environment settings object">cross-origin isolated capability</a>.
43644364

43654365
<li><p><a for=/>Mark resource timing</a> for <var>timingInfo</var>, <var>request</var>'s
4366-
<a for=request>URL</a> <var>initiatorType</var>, <var>global</var>, and <var>cacheState</var>.
4366+
<a for=request>URL</a> <var>initiatorType</var>, <var>global</var>, <var>cacheState</var>,
4367+
and <var>resourceInfo</var>.
43674368
</ol>
43684369
</li>
43694370

@@ -4434,49 +4435,6 @@ steps:
44344435
</ol>
44354436
</ol>
44364437

4437-
<p>To <dfn export>finalize and report timing</dfn> given a <a for=/>response</a>
4438-
<var>response</var>, a <a for=/>global object</a> <var>global</var>, and a <a for=/>string</a>
4439-
<var>initiatorType</var> (default "<code>other</code>"), run these steps:
4440-
4441-
<ol>
4442-
<li><p>If <var>response</var> is an <a>aborted network error</a>, then return.
4443-
4444-
<li><p>If <var>response</var>'s <a for=response>URL list</a> is null or
4445-
<a for=list lt="is empty">empty</a>, then return.
4446-
4447-
<li><p>Let <var>originalURL</var> be <var>response</var>'s <a for=response>URL list</a>[0].
4448-
4449-
<li><p>Let <var>timingInfo</var> be <var>response</var>'s <a for=response>timing info</a>.
4450-
4451-
<li><p>Let <var>cacheState</var> be <var>response</var>'s <a for=response>cache state</a>.
4452-
4453-
<li><p>If <var>originalURL</var>'s <a for=url>scheme</a> is not an <a>HTTP(S) scheme</a>, then
4454-
return.
4455-
4456-
<li><p>If <var>timingInfo</var> is null, then return.
4457-
4458-
<li>
4459-
<p>If <var>response</var>'s <a for=response>timing allow passed flag</a> is not set, then:
4460-
4461-
<ol>
4462-
<li><p>Set <var>timingInfo</var> to a the result of <a>creating an opaque timing info</a> for
4463-
<var>timingInfo</var>.
4464-
4465-
<li><p>Set <var>cacheState</var> to the empty string.
4466-
</ol>
4467-
4468-
<li><p>Set <var>timingInfo</var>'s <a for="fetch timing info">end time</a> to the
4469-
<a for=/>coarsened shared current time</a> given <var>global</var>'s
4470-
<a>relevant settings object</a>'s
4471-
<a for="environment settings object">cross-origin isolated capability</a>.
4472-
4473-
<li><p>Set <var>response</var>'s <a for="response">timing info</a> to <var>timingInfo</var>.
4474-
4475-
<li><p><a for=/>Mark resource timing</a> for <var>timingInfo</var>, <var>originalURL</var>,
4476-
<var>initiatorType</var>, <var>global</var>, and <var>cacheState</var>.
4477-
</ol>
4478-
4479-
44804438
<h3 id=scheme-fetch oldids=basic-fetch>Scheme fetch</h3>
44814439

44824440
<p>To <dfn id=concept-scheme-fetch oldids=concept-basic-fetch>scheme fetch</dfn>, given a
@@ -4644,9 +4602,6 @@ these steps:
46444602
<a for="fetch timing info">final service worker start time</a> to
46454603
<var>serviceWorkerStartTime</var>.
46464604

4647-
<li><p><a for=/>Update timing info from stored response</a> given <var>fetchParams</var>'s
4648-
<a for="fetch params">timing info</a> and <var>response</var>.
4649-
46504605
<li>If <var>request</var>'s <a for=request>body</a> is non-null, then
46514606
<a for=ReadableStream>cancel</a> <var>request</var>'s <a for=request>body</a> with undefined.
46524607

@@ -4778,15 +4733,7 @@ these steps:
47784733
</dl>
47794734
<!-- not resetting actualResponse since it's no longer used anyway -->
47804735
</ol>
4781-
4782-
<li>
4783-
<p>Set <var>response</var>'s <a for=response>timing info</a> to <var>timingInfo</var>.
4784-
4785-
<p class=note>Attaching the timing info to a response is what makes it exposed to the web as a
4786-
Resource Timing entry later. This step is done here, as resource-timing entries are available only
4787-
for HTTP fetches, including ones that are handled by service-workers or HTTP cache, and not for,
4788-
e.g., <code>data:</code>, <code>blob:</code> URL fetches, and are only available after all the
4789-
relevant security checks have succeeded.
4736+
</li>
47904737

47914738
<li><p>Return <var>response</var>. <span class="note no-backref">Typically
47924739
<var>actualResponse</var>'s <a for=response>body</a>'s
@@ -5312,9 +5259,6 @@ steps. They return a <a for=/>response</a>.
53125259
<li><p>Set <var>response</var> to <var>storedResponse</var>.
53135260

53145261
<li><p>Set <var>response</var>'s <a for=response>cache state</a> to "<code>validated</code>".
5315-
5316-
<li><p><a for=/>Update timing info from stored response</a> given <var>fetchParams</var>'s
5317-
<a for="fetch params">timing info</a> and <var>response</var>.
53185262
</ol>
53195263

53205264
<li>
@@ -5330,9 +5274,6 @@ steps. They return a <a for=/>response</a>.
53305274

53315275
<p class=note>If <var>forwardResponse</var> is a <a>network error</a>, this effectively caches
53325276
the network error, which is sometimes known as "negative caching".
5333-
5334-
<p class=note>The associated <a for=response>timing info</a> is stored in the cache
5335-
alongside the response.
53365277
</ol>
53375278
</ol>
53385279

@@ -5726,8 +5667,9 @@ optional boolean <var>forceNewConnection</var> (default false), run these steps:
57265667
<li><p>Let <var>codings</var> be the result of <a>extracting header list values</a> given
57275668
`<code>Content-Encoding</code>` and <var>response</var>'s <a for=response>header list</a>.
57285669

5729-
<li><p>Increase <var>timingInfo</var>'s <a for="fetch timing info">encoded body size</a>
5730-
by <var>bytes</var>'s <a for="byte sequence">length</a>.
5670+
<li><p>Increase <var>response</var>'s <a for=response>resource info</a>'s
5671+
<a for="fetch resource info">encoded body size</a> by <var>bytes</var>'s
5672+
<a for="byte sequence">length</a>.
57315673

57325674
<li>
57335675
<p>Set <var>bytes</var> to the result of <a lt="handle content codings">handling content
@@ -5736,7 +5678,8 @@ optional boolean <var>forceNewConnection</var> (default false), run these steps:
57365678
<p class="note no-backref">This makes the `<code>Content-Length</code>` <a for=/>header</a>
57375679
unreliable to the extent that it was reliable to begin with.
57385680

5739-
<li><p>Increase <var>timingInfo</var>'s <a for="fetch timing info">decoded body size</a> by
5681+
<li><p>Increase <var>response</var>'s <a for=response>resource info</a>'s
5682+
<a for="fetch resource info">decoded body size</a> by
57405683
<var>bytes</var>'s <a for="byte sequence">length</a>.
57415684

57425685
<li><p>If <var>bytes</var> is failure, then <a for="fetch controller">terminate</a>

0 commit comments

Comments
 (0)