Skip to content

Integrate Client-Hints with Fetch #258

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 94 additions & 7 deletions Overview.src.html
Original file line number Diff line number Diff line change
Expand Up @@ -324,17 +324,35 @@ <h4 id=terminology-headers>Headers</h4>
<hr>

<p>A <dfn>simple header</dfn> is a <span title=concept-header>header</span> whose
<span title=concept-header-name>name</span> is `<code title>Accept</code>`,
`<code title>Accept-Language</code>`, or `<code title>Content-Language</code>`, or whose
<span title=concept-header-name>name</span> is `<code title>Content-Type</code>` and
<span title=concept-header-value>value</span>, <span title=concept-header-parse>once parsed</span>,
has a MIME type (ignoring parameters) that is
`<code title>application/x-www-form-urlencoded</code>`, `<code title>multipart/form-data</code>`, or
`<code title>text/plain</code>`.
<span title=concept-header-name>name</span> is one of

<ul class=brief>
<li>`<code title>Accept</code>`
<li>`<code title>Accept-Language</code>`
<li>`<code title>Content-Language</code>`
<li>`<code title>Content-Type</code>` and whose <span title=concept-header-value>value</span>,
<span title=concept-header-parse>once parsed</span>, has a MIME type (ignoring parameters)
that is `<code title>application/x-www-form-urlencoded</code>`,
`<code title>multipart/form-data</code>`, or `<code title>text/plain</code>`
</ul>
Copy link
Member

Choose a reason for hiding this comment

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

I think it might be better to have <p>or whose name is one of </p> <ul class=brief> ... </ul> <p>and value, once parsed, is not failure.</p> after the Content-Type entry. It seems a little weird to have a list of header names and then have a list of header names inside that list.


<!-- XXX * needs better xref
* ignoring parameters has been the standard for a long time now
* interesting test: "Content-Type: text/plain;" -->
Copy link
Member

Choose a reason for hiding this comment

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

This needs to be kept close to the Content-Type text. Below it.


<p>or whose <span title=concept-header-name>name</span> is one of

<ul class=brief>
<li>`<code title><a href=http://httpwg.org/http-extensions/client-hints.html#dpr>DPR</a></code>`
<li>`<code title><a href=http://httpwg.org/http-extensions/client-hints.html#downlink>Downlink</a></code>`
<li>`<code title><a href=http://httpwg.org/http-extensions/client-hints.html#save-data>Save-Data</a></code>`
<li>`<code title><a href=http://httpwg.org/http-extensions/client-hints.html#viewport-width>Viewport-Width</a></code>`
<li>`<code title><a href=http://httpwg.org/http-extensions/client-hints.html#width>Width</a></code>`
</ul>

<p>and whose <span title=concept-header-value>value</span>,
<span title=concept-header-parse>once parsed</span>, is not a failure.

<p>A <dfn>forbidden header name</dfn> is a <span title=concept-header>header</span>
<span title=concept-header-name>name</span> that is one of

Expand Down Expand Up @@ -804,6 +822,17 @@ <h4>Requests</h4>
an <span data-anolis-spec=html>environment settings object</span>.
<span data-anolis-ref>REFERRER</span>

<p>A <span title=concept-request>request</span> has an associated
<dfn title=concept-request-client-hints-list>client hints list</dfn>, which is a
<span title=concept-client-hints-list>client-hints list</span>. Unless stated otherwise, it is
the empty list.

<p class="note no-backref">This will be used to override a client hints list associated with
an <span data-anolis-spec=html>environment settings object</span>.
<span data-anolis-ref>CLIENT-HINTS</span>
Copy link
Member

Choose a reason for hiding this comment

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

CLIENT-HINTS doesn't define a client hints list associated with an environment settings object. What exactly is the purpose of this?

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, that part hasn't been specced yet. My intent is to mirror similar language as referrer policy.

  • We can either do that within the CH draft.
  • Or, we can integrate that language directly into the HTML spec?

Any preference on one vs other? /cc @mnot

Copy link
Member

Choose a reason for hiding this comment

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

Not really, as long as it's clearly defined. I guess it would be good to state in the note that this is not yet defined. Or say "will be used" or some such. Then we can update it later once things are defined.


<!-- XXX this needs to move to CLIENT-HINTS -->

<p>A <span title=concept-request>request</span> has an associated
<dfn>synchronous flag</dfn>. Unless stated otherwise it is unset.

Expand Down Expand Up @@ -1387,6 +1416,15 @@ <h3>Referrer policies</h3>
<span data-anolis-ref>REFERRER</span>


<h3>Client hints list</h3>

<p>A <dfn title=concept-client-hints-list>client hints list</dfn> is a list of
<a href=http://httpwg.org/http-extensions/client-hints.html#accept-ch>Client hint tokens</a>,
each of which is one of `<code title>dpr</code>`,
`<code title>save-data</code>`, `<code title>viewport-width</code>`, or
`<code title>width</code>`.
Copy link
Member

Choose a reason for hiding this comment

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

It might make sense to define this concept ("client hints list") directly in CLIENT-HINTS too, especially if it is going to be reused by multiple concepts.

Copy link
Member Author

Choose a reason for hiding this comment

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

Seems reasonable. Do you want me to drop this from here then? Or, should we remove this and add a reference once we have the other bits specc'ed in CH/HTML spec.

Copy link
Member

Choose a reason for hiding this comment

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

Either way is fine with me. If you want to go with the former approach I'd appreciate you adding <!-- XXX this needs to move to CLIENT-HINTS --> after this <p>.



<h3>Streams</h3>

<p class="note no-backref">This section might be integrated into other standards, such as IDL.
Expand Down Expand Up @@ -1888,10 +1926,59 @@ <h2>Fetching</h2>
for HTTP/2, and equivalent information used to prioritize dispatch and processing of
HTTP/1 fetches.


<li>
<p>If <var>request</var> is a <span>navigation request</span>, a user agent should, for each
<span title=concept-header>header</span> <span title=concept-header-name>name</span>
(<var>hint-name</var>) in the first column of the following table, if <var>hint-name</var>
is not in <var>request</var>'s <span title=concept-request-header-list>header list</span>,
<span title=concept-header-list-append>append</span>
<var>hint-name</var>/<var>hint-value</var> given in the same row on the second column, to
<var>request</var>'s <span title=concept-request-header-list>header list</span>.

<table>
<tr>
<th><span title=hint-name>hint-name</span>
<th><span title=hint-value>hint-value</span>
<tr>
<td>`<code title=http-dpr>dpr</a></code>`
<td>a suitable <a href=http://httpwg.org/http-extensions/client-hints.html#dpr>dpr value</a>
<tr>
<td>`<code title=http-save-data>save-data</code>`
<td>a suitable <a href=http://httpwg.org/http-extensions/client-hints.html#save-data>save-data value</a>
<tr>
<td>`<code title=http-viewport-width>viewport-width</code>`
<td>a suitable <a href=http://httpwg.org/http-extensions/client-hints.html#viewport-width>viewport-width value</a>
</table>
Copy link
Member

Choose a reason for hiding this comment

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

The <tr>s and <th>/<td>s need to be indented one more.


<li>
<p>If <var>request</var> is a <span>subresource request</span>, run these substeps:

<ol>
<li>
<p>If the <var>request</var>'s <span title=concept-client-hint-list>client hints list</span> is not empty, run these substeps for each <var>hint-name</var> in the list:

<ol>
<li>
<p>Set <var>value</var> to the first matching statement, if any, switching on
<var>hint-name</var>:

<dl class=switch>
<dt>"<code title>dpr</code>"
<dd>a suitable <a href=http://httpwg.org/http-extensions/client-hints.html#dpr>dpr value</a>
<dt>"<code title>save-data</code>"
<dd>a suitable <a href=http://httpwg.org/http-extensions/client-hints.html#save-data>save-data value</a>
<dt>"<code title>viewport-width</code>"
<dd>a suitable <a href=http://httpwg.org/http-extensions/client-hints.html#viewport-width>viewport-width value</a>
<dt>"<code title>width</code>"
<dd>a suitable <a href=http://httpwg.org/http-extensions/client-hints.html#width>width value</a></code>
</dl>

<li><p><span title=concept-header-list-append>Append</span>
<var>hint-name</var>/<var>value</var> to <var>request</var>'s
<span title=concept-request-header-list>header list</span>.
</ol>

<li><p>Let <var>record</var> be a new
<span title=concept-fetch-record>fetch record</span> consisting of
<var>request</var> and this instance of the
Expand Down