Skip to content

Commit

Permalink
Add more timing iformation about (interim) responses
Browse files Browse the repository at this point in the history
See w3c/resource-timing#345

Since early hints have landed, there are additional useful timestamps
that are currently not exposed:

- First interim response start (e.g. when we received a 103)
  as a different timestamp from the final response start
  (e.g. when we received the 200)

- Final headers received (when the last header has been received and
  we're ready for the body)

- First bytes of the body received

The naming in whatwg#345 is not finalized yet, but it's clear that these
are the 3 interesting timestamps. This PR exposes those for later
use by resource timing.
  • Loading branch information
noamr committed May 4, 2023
1 parent 4502481 commit a18e4e3
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions fetch.bs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,10 @@ following <a for=struct>items</a>: [[RESOURCE-TIMING]] [[NAVIGATION-TIMING]]
<dt><dfn export for="fetch timing info">post-redirect start time</dfn> (default 0)
<dt><dfn export for="fetch timing info">final service worker start time</dfn> (default 0)
<dt><dfn export for="fetch timing info">final network-request start time</dfn> (default 0)
<dt><dfn export for="fetch timing info">first interim network-response start time</dfn> (default 0)
<dt><dfn export for="fetch timing info">final network-response start time</dfn> (default 0)
<dt><dfn export for="fetch timing info">final network-response headers end time</dfn> (default 0)
<dt><dfn export for="fetch timing info">response body start time</dfn> (default 0)
<dt><dfn export for="fetch timing info">end time</dfn> (default 0)
<dd>A {{DOMHighResTimeStamp}}.

Expand Down Expand Up @@ -5994,16 +5997,20 @@ optional boolean <var>forceNewConnection</var> (default false), run these steps:
<p>While true:

<ol>
<li><p>If <var>timingInfo</var>'s
<a for="fetch timing info">final network-response start time</a> is 0, then set
<var>timingInfo</var>'s <a for="fetch timing info">final network-response start time</a> to
<li><p>Set <var>timingInfo</var>'s
<a for="fetch timing info">final network-response start time</a> to the
<a for=/>coarsened shared current time</a> given <var>fetchParams</var>'s
<a for="fetch params">cross-origin isolated capability</a>, immediately after the user
agent's HTTP parser receives the first byte of the response (e.g., frame header bytes for
HTTP/2 or response status line for HTTP/1.x).

<li><p>Wait until all the HTTP response headers are transmitted.

<li><p>Set <var>timingInfo</var>'s
<a for="fetch timing info">final network-response headers end time</a> to
<a for=/>coarsened shared current time</a> given <var>fetchParams</var>'s
<a for="fetch params">cross-origin isolated capability</a>.

<li><p>Let <var>status</var> be the HTTP response's status code.

<li>
Expand All @@ -6017,6 +6024,14 @@ optional boolean <var>forceNewConnection</var> (default false), run these steps:
<li><p>If <var>request</var>'s <a for=request>mode</a> is "<code>websocket</code>" and
<var>status</var> is 101, then <a for=iteration>break</a>.

<li><p>If <var>timingInfo</var>'s
<a for="fetch timing info">first interim network-response start time</a> is 0, then set
<var>timingInfo</var>'s
<a for="fetch timing info">first interim network-response start time</a> to
<var>timingInfo</var>'s <a for="fetch timing info">final network-response start time</a>.

<li><p>If <var>status</var> is 101, <a for=iteration>break</a>.

<li><p>If <var>status</var> is 103 and <var>fetchParams</var>'s
<a for="fetch params">process early hints response</a> is non-null, then
<a>queue a fetch task</a> to run <var>fetchParams</var>'s
Expand Down Expand Up @@ -6197,6 +6212,13 @@ optional boolean <var>forceNewConnection</var> (default false), run these steps:
<p>If one or more bytes have been transmitted from <var>response</var>'s message body, then:

<ol>
<li><p>If <var>fetchParams</var>'s <a for="fetch params">timing info</a>'s
<a for="fetch timing info">response body start time</a> is 0, then set
<var>fetchParams</var>'s <a for="fetch params">timing info</a>'s
<a for="fetch timing info">response body start time</a> to the
<a for=/>coarsened shared current time</a> given <var>fetchParams</var>'s
<a for="fetch params">cross-origin isolated capability</a>.

<li><p>Let <var>bytes</var> be the transmitted bytes.

<li><p>Let <var>codings</var> be the result of <a>extracting header list values</a> given
Expand Down

0 comments on commit a18e4e3

Please sign in to comment.