Skip to content

Commit 53dcb01

Browse files
bashiannevk
andauthored
Infrastructure for 103 Early Hints responses
Allow specifications to pass an algorithm to fetch to process 103 Early Hints responses. See whatwg/html#7598 for the overall approach. Corresponding HTML PR: whatwg/html#7675. Co-authored-by: Anne van Kesteren <[email protected]>
1 parent 3a65729 commit 53dcb01

File tree

1 file changed

+52
-18
lines changed

1 file changed

+52
-18
lines changed

fetch.bs

Lines changed: 52 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ lt="authentication entry">authentication entries</a> (for HTTP authentication).
199199
<dt><dfn for="fetch params" id=fetch-params-process-request-body>process request body chunk length</dfn>
200200
(default null)
201201
<dt><dfn for="fetch params">process request end-of-body</dfn> (default null)
202+
<dt><dfn for="fetch params">process early hints response</dfn> (default null)
202203
<dt><dfn for="fetch params">process response</dfn> (default null)
203204
<dt><dfn for="fetch params">process response end-of-body</dfn> (default null)
204205
<dt><dfn for="fetch params">process response consume body</dfn> (default null)
@@ -1130,7 +1131,7 @@ format of range header value can be set using <a>add a range header</a>.
11301131
<p class=XXX>Various edge cases in mapping HTTP/1's <code>status-code</code> to this concept are
11311132
worked on in <a href=https://github.com/whatwg/fetch/issues/1156>issue #1156</a>.
11321133

1133-
<p>A <dfn export>null body status</dfn> is a <a for=/>status</a> that is 101, 204, 205, or 304.
1134+
<p>A <dfn export>null body status</dfn> is a <a for=/>status</a> that is 101, 103, 204, 205, or 304.
11341135

11351136
<p>An <dfn export>ok status</dfn> is a <a for=/>status</a> in the range 200 to 299, inclusive.
11361137

@@ -3787,15 +3788,16 @@ optional algorithm
37873788
<dfn export for=fetch id=process-request-body><var>processRequestBodyChunkLength</var></dfn>, an
37883789
optional algorithm
37893790
<dfn export for=fetch id=process-request-end-of-body oldids=process-request-end-of-file><var>processRequestEndOfBody</var></dfn>,
3790-
an optional algorithm <dfn export for=fetch id=process-response><var>processResponse</var></dfn>, an
3791-
optional algorithm <dfn export for=fetch><var>processResponseEndOfBody</var></dfn>, an optional
3792-
algorithm
3791+
an optional algorithm <dfn export for=fetch><var>processEarlyHintsResponse</var></dfn>, an optional
3792+
algorithm <dfn export for=fetch id=process-response><var>processResponse</var></dfn>, an optional
3793+
algorithm <dfn export for=fetch><var>processResponseEndOfBody</var></dfn>, an optional algorithm
37933794
<dfn export for=fetch id=process-response-end-of-body oldids=process-response-end-of-file><var>processResponseConsumeBody</var></dfn>,
37943795
and an optional boolean <dfn export for=fetch><var>useParallelQueue</var></dfn> (default false), run
37953796
the steps below. If given, <var>processRequestBodyChunkLength</var> must be an algorithm accepting
37963797
an integer representing the number of bytes transmitted. If given,
37973798
<var>processRequestEndOfBody</var> must be an algorithm accepting no arguments. If given,
3798-
<var>processResponse</var> must be an algorithm accepting a <a for=/>response</a>. If given,
3799+
<var>processEarlyHintsResponse</var> must be an algorithm accepting a <a for=/>response</a>. If
3800+
given, <var>processResponse</var> must be an algorithm accepting a <a for=/>response</a>. If given,
37993801
<var>processResponseEndOfBody</var> must be an algorithm accepting a <a for=/>response</a>. If
38003802
given, <var>processResponseConsumeBody</var> must be an algorithm accepting a <a for=/>response</a>
38013803
and null, failure, or a <a for=/>byte sequence</a>.
@@ -3813,6 +3815,13 @@ the request.
38133815
[[!HTTP-CACHING]]
38143816

38153817
<ol>
3818+
<li>
3819+
<p><a for=/>Assert</a>: <var>request</var>'s <a for=request>mode</a> is "<code>navigate</code>" or
3820+
<var>processEarlyHintsResponse</var> is null.
3821+
3822+
<p class=note>Processing of early hints (<a for=/>responses</a> whose <a for=response>status</a>
3823+
is 103) is only vetted for navigations.
3824+
38163825
<li><p>Let <var>taskDestination</var> be null.
38173826

38183827
<li><p>Let <var>crossOriginIsolatedCapability</var> be false.
@@ -3848,6 +3857,7 @@ the request.
38483857
<a for="fetch params">process request body chunk length</a> is
38493858
<var>processRequestBodyChunkLength</var>,
38503859
<a for="fetch params">process request end-of-body</a> is <var>processRequestEndOfBody</var>,
3860+
<a for="fetch params">process early hints response</a> is <var>processEarlyHintsResponse</var>,
38513861
<a for="fetch params">process response</a> is <var>processResponse</var>,
38523862
<a for="fetch params">process response consume body</a> is <var>processResponseConsumeBody</var>,
38533863
<a for="fetch params">process response end-of-body</a> is <var>processResponseEndOfBody</var>,
@@ -5482,22 +5492,41 @@ optional boolean <var>forceNewConnection</var> (default false), run these steps:
54825492
<a for=request>body</a> cannot be recreated and that is why the buffer is needed.
54835493
</div>
54845494

5485-
<li><p>Set <var>timingInfo</var>'s
5486-
<a for="fetch timing info">final network-response start time</a> to the
5487-
<a for=/>coarsened shared current time</a> given <var>fetchParams</var>'s
5488-
<a for="fetch params">cross-origin isolated capability</a>, immediately after the user agent's
5489-
HTTP parser receives the first byte of the response (e.g., frame header bytes for HTTP/2 or
5490-
response status line for HTTP/1.x).
5495+
<li>
5496+
<p>While true:
54915497

5492-
<li><p>Wait until all the <a for=/>headers</a> are transmitted.
5498+
<ol>
5499+
<li><p>If <var>timingInfo</var>'s
5500+
<a for="fetch timing info">final network-response start time</a> is 0, then set
5501+
<var>timingInfo</var>'s <a for="fetch timing info">final network-response start time</a> to
5502+
<a for=/>coarsened shared current time</a> given <var>fetchParams</var>'s
5503+
<a for="fetch params">cross-origin isolated capability</a>, immediately after the user
5504+
agent's HTTP parser receives the first byte of the response (e.g., frame header bytes for
5505+
HTTP/2 or response status line for HTTP/1.x).
54935506

5494-
<li>
5495-
<p>Any <a for=/>responses</a> whose <a for=response>status</a> is in the range 100 to 199,
5496-
inclusive, and is not 101, are to be ignored, except for the purposes of setting
5497-
<var>timingInfo</var>'s <a for="fetch timing info">final network-response start time</a> above.
5507+
<li><p>Wait until all the HTTP response headers are transmitted.
5508+
5509+
<li><p>Let <var>status</var> be the HTTP response's status code.
5510+
5511+
<li>
5512+
<p>If <var>status</var> is in the range 100 to 199, inclusive:
5513+
5514+
<ol>
5515+
<li><p>If <var>status</var> is 101, <a for=iteration>break</a>.
54985516

5499-
<p class="note no-backref">These kind of <a for=/>responses</a> are eventually followed by a
5500-
"final" <a for=/>response</a>.
5517+
<li><p>If <var>status</var> is 103 and <var>fetchParams</var>'s
5518+
<a for="fetch params">process early hints response</a> is non-null, then
5519+
<a>queue a fetch task</a> to run <var>fetchParams</var>'s
5520+
<a for="fetch params">process early hints response</a>, with <a for=/>response</a>.
5521+
5522+
<li><p><a for=iteration>Continue</a>.
5523+
</ol>
5524+
5525+
<p class=note>These kind of HTTP responses are eventually followed by a "final" HTTP
5526+
response.
5527+
5528+
<li><p><a for=iteration>Break</a>.
5529+
</ol>
55015530
</ul>
55025531

55035532
<p class=note>The exact layering between Fetch and HTTP still needs to be sorted through and
@@ -8101,6 +8130,11 @@ in a <a for=/>parallel queue</a> if <a for=fetch><i>useParallelQueue</i></a> is
81018130
<dd><p>Takes an algorithm that will be passed nothing. Indicates <a for=/>request</a>'s
81028131
<a for=request>body</a> has been transmitted. Most standards will not need this.
81038132

8133+
<dt><a for=fetch><i>processEarlyHintsResponse</i></a>
8134+
<dd><p>Takes an algorithm that will be passed a <a for=/>response</a> (whose
8135+
<a for=response>status</a> is 103). Can only be used for navigations as defined by
8136+
<cite>HTML</cite>. [[HTML]]
8137+
81048138
<dt><a for=fetch><i>processResponse</i></a>
81058139
<dd><p>Takes an algorithm that will be passed a <a for=/>response</a>. Indicates
81068140
<a for=/>response</a>'s <a for=response>header list</a> has been received and initialized. This

0 commit comments

Comments
 (0)