Skip to content
149 changes: 135 additions & 14 deletions fetch.bs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ url:https://tools.ietf.org/html/rfc7234#section-1.2.1;text:delta-seconds;type:df
},
"OCSP": {
"aliasOf": "RFC2560"
},
"FEATURE-POLICY": {
"authors": [
"Ian Clelland"
],
"href": "https://wicg.github.io/feature-policy/",
"publisher": "WICG",
"title": "Feature Policy"
}
}
</pre>
Expand Down Expand Up @@ -637,6 +645,9 @@ production as
<ol>
<li><p>Let <var>value</var> be <var>header</var>'s <a for=header>value</a>.

<li><p>If <var>header</var>'s <a for=header>name</a> starts with a <a>byte-case-insensitive</a>
match to `Sec-`, return true.

<li>
<p><a>Byte-lowercase</a> <var>header</var>'s <a for=header>name</a> and switch on the result:

Expand Down Expand Up @@ -1295,6 +1306,15 @@ to not have to set <a for=/>request</a>'s <a for=request>referrer</a>.
<p class="note no-backref">This can be used to override a referrer policy associated with an
<a>environment settings object</a>.

<p>A <a for=/>request</a> has an associated
<dfn export for=request id=concept-request-client-hints-set>client-hints set</dfn>,
which is a <a lt="client-hints set">client-hints set</a>. Unless stated
otherwise, it is the empty set.

<p class="note no-backref">This will be used to override a client-hints set associated with
an <a>environment settings object</a>.
[[!CLIENT-HINTS]]

<p>A <a for=/>request</a> has an associated
<dfn id=synchronous-flag export for=request>synchronous flag</dfn>. Unless stated otherwise it is
unset.
Expand Down Expand Up @@ -1750,6 +1770,10 @@ initially unset.
being provided to an API that didn't make a range request. See the flag's usage for a detailed
description of the attack.

<p>A <a for=/>response</a> has an associated
<dfn for=response id=concept-response-image-density>image density</dfn>, which is initially set to
zero.

<p>A <a for=/>response</a> can have an associated
<dfn export for=response id=concept-response-location-url>location URL</dfn> (null, failure, or a
<a for=/>URL</a>). Unless specified otherwise, <a for=/>response</a> has no
Expand Down Expand Up @@ -2115,6 +2139,18 @@ run these steps:
</ol>


<h3 id=client-hints-set>Client-hints set</h3>

<p>A <dfn export id=concept-client-hints-set>client-hints set</dfn> is a
<a for=/>set</a> of
<a href=http://httpwg.org/http-extensions/client-hints.html#accept-ch>Client hint tokens</a>, each
of which is one of `<code>DPR</code>`, `<code>Save-Data</code>`, `<code>Viewport-Width</code>`,
`<code>Width</code>`, `<code>Device-Memory</code>`, `<code>RTT</code>`, `<code>Downlink</code>`, or
`<code>ECT</code>`.


`<code>Width</code>`.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the other new hints here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup


<h3 id=streams>Streams</h3>

<p class="note no-backref">This section might be integrated into other standards, such as IDL.
Expand Down Expand Up @@ -3062,6 +3098,10 @@ the request.
<a for=request>origin</a> to <var>request</var>'s
<a for=request>client</a>'s <a for="environment settings object">origin</a>.

<li><p>Set <var>request</var>'s <a for=request>client-hints set</a> to be a <a for=list>clone</a>
of the <a for="environment settings object">client-hints set</a> of the <var>request</var>'s
<a for=request>client</a>'s <a for="environment settings object">global object</a>.

<li>
<p>If <var>request</var>'s <a for=request>header list</a>
<a for="header list">does not contain</a> `<code>Accept</code>`, then:
Expand Down Expand Up @@ -3107,20 +3147,81 @@ the request.
HTTP/1 fetches.

<li>
<p>If <var>request</var> is a <a>subresource request</a>, then:

<ol>
<li><p>Let <var>record</var> be a new
<a for="fetch group">fetch record</a> consisting of
<var>request</var> and this instance of the
<a for=/>fetch</a> algorithm.

<li><p>Append <var>record</var> to <var>request</var>'s
<a for=request>client</a>'s
<a for=fetch>fetch group</a> list of
<a for="fetch group">fetch records</a>.
</ol>
</ol>
<p>If <var>request</var> is a <a>navigation request</a>, a user agent should, for each
<a for=/>header</a> <a for=header>name</a> (<var>hintName</var>) in the first column of the
following table, if <var>request</var>'s <a for=request>header list</a>
<a for="header list">does not contain</a> <var>hintName</var>, then
<a for="header list">append</a>
<var>hintName</var>/the value given in the same row on the second column, to
<var>request</var>'s <a for=request>header list</a>.

<table>
<tbody><tr>
<th><a for=header>Name</a>
<th><a for=header>Value</a>
<tr>
<td>`<code>Save-Data</code>`
<td>a suitable <a href=http://httpwg.org/http-extensions/client-hints.html#save-data>save-data value</a>
</table>

<li>

<p><a for=list>For each</a> <var>hintName</var> of <var>request</var>'s
<a for=request>client-hints set</a>:

<ol>
<li>
<p>Let <var>value</var> be the first matching statement, switching on <var>hintName</var>:

<dl class=switch>
<dt>`<code>DPR</code>`
<dd>a suitable <a href=http://httpwg.org/http-extensions/client-hints.html#dpr>dpr value</a>
<dt>`<code>Save-Data</code>`
<dd>a suitable <a href=http://httpwg.org/http-extensions/client-hints.html#save-data>save-data value</a>
<dt>`<code>Viewport-Width</code>`
<dd>a suitable <a href=http://httpwg.org/http-extensions/client-hints.html#viewport-width>viewport-width value</a>
<dt>`<code>Width</code>`
<dd>a suitable <a href=http://httpwg.org/http-extensions/client-hints.html#width>width value</a>
<dt>`<code>Device-Memory</code>`
<dd>a suitable <a href=https://w3c.github.io/device-memory/#sec-device-memory-client-hint-header>Device-Memory value</a>
<dt>`<code>RTT</code>`
<dd>a suitable <a href=https://wicg.github.io/netinfo/#rtt-request-header-field>RTT value</a>
<dt>`<code>Downlink</code>`
<dd>a suitable <a href=https://wicg.github.io/netinfo/#downlink-request-header-field>Downlink value</a>
<dt>`<code>ECT</code>`
<dd>a suitable <a href=https://wicg.github.io/netinfo/#ect-request-header-field>ECT value</a>
</dl>

<li><p>If <var>request</var> is a <a>subresource request</a> and the result of running <a
href="https://wicg.github.io/feature-policy/#should-request-be-allowed-to-use-feature">Should
request be allowed to use feature?</a>, given <var>request</var> and <var>hintName</var>’s
<a href="http://httpwg.org/http-extensions/client-hints.html#opt-in-via-feature-policy">associated
policy-controlled feature</a>, returns <code>false</code>, then skip the next steps and
continue to the next <var>hintName</var>.
[[!FEATURE-POLICY]] [[!CLIENT-HINTS]]

<!-- TODO(yoav): Fix the above Feature policy link -->
<!-- TODO(yoav): Fix the Client hints reference to the HTML one, once it lands -->
<li><p>Set <var>hintName</var> to "Sec-" concatenated with <var>hintName</var>.

<li><p>If <var>request</var>'s <a for=request>header list</a> <a for="header list">does not
contain</a> <var>hintName</var>, a user agent should <a for="header list">append</a>
<var>hintName</var>/<var>value</var> to <var>request</var>'s <a for=request>header list</a>.
</ol>

<li><p>If <var>request</var> is a <a>subresource request</a>, then:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indentation is off here as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack

<ol>
<li><p>Let <var>record</var> be a new
<a for="fetch group">fetch record</a> consisting of
<var>request</var> and this instance of the
<a for=/>fetch</a> algorithm.

<li><p>Append <var>record</var> to <var>request</var>'s
<a for=request>client</a>'s
<a for=fetch>fetch group</a> list of
<a for="fetch group">fetch records</a>.
</ol>
</ol>

<li>
<p><a>If aborted</a>, then:
Expand Down Expand Up @@ -3494,6 +3595,12 @@ with a <i>CORS flag</i> and <i>recursive flag</i>, run these steps:
<a>queue a fetch-request-done task</a> for <var>request</var>.
</ol>

<li><p>If <var>request</var>'s destination is "image" and <var>response</var>'s
<a for=response>header list</a> <a for="header list">contains</a>
`<code>Content-DPR</code>`, set <var>response</var>'s <a for=response>image density</a> value to the
result of parsing the header value as float.
<!-- TODO: propoerly link parse as float -->

<li><p><a>Queue a fetch task</a> on <var>request</var> to
<a>process response</a> for <var>response</var>.

Expand Down Expand Up @@ -3857,6 +3964,20 @@ optional <i>CORS flag</i> and <i>CORS-preflight flag</i>, run these steps:
not <a>same origin</a> with <var>actualResponse</var>'s <a for=response>location URL</a>'s
<a for=url>origin</a>, then return a <a>network error</a>.

<li><p><a for=list>For each</a> <var>hintName</var> of <var>request</var>'s
<a for=request>client-hints set</a>:
<ol>
<li><p>Set <var>hintName</var> to "Sec-" concatenated with <var>hintName</var>.
<li><p>If <var>request</var>'s <a for=request>header list</a> <a for="header list"> contains</a>
<var>hintName</var> and if the result of running <a
href="https://wicg.github.io/feature-policy/#should-request-be-allowed-to-use-feature">Should
request be allowed to use feature?</a>, given <var>request</var> and <var>hintName</var>’s
<a href="http://httpwg.org/http-extensions/client-hints.html#opt-in-via-feature-policy">associated
policy-controlled feature</a>, returns <code>false</code>, then remove <var>hintName</var> from
<a for=request>header list</a>.
[[!FEATURE-POLICY]] [[!CLIENT-HINTS]]
</ol>

<li>
<p>If <i>CORS flag</i> is set and <var>actualResponse</var>'s
<a for=response>location URL</a>
Expand Down