Skip to content

Process Preload link headers #7622

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

Merged
merged 12 commits into from
Mar 8, 2022
Merged
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
118 changes: 106 additions & 12 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -2429,6 +2429,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute

<ul class="brief">
<li>`<dfn data-x="http-link" data-x-href="https://tools.ietf.org/html/rfc8288#section-3"><code>Link</code></dfn>` header</li>
<li><dfn data-x="parsing a link header value" data-x-href="https://tools.ietf.org/html/rfc8288#appendix-B.2">Parsing a `<code>Link</code>` header value</dfn></li>
</ul>

<p>The following terms are defined in <cite>Structured Field Values for HTTP</cite>: <ref
Expand Down Expand Up @@ -14241,20 +14242,83 @@ interface <dfn interface>HTMLLinkElement</dfn> : <span>HTMLElement</span> {

<h5>Processing `<code data-x="http-link">Link</code>` headers</h5>

<p>HTTP `<code data-x="http-link">Link</code>` headers, if supported, must be assumed to come
before any links in the document, in the order that they were given in the HTTP message. These
headers are to be processed according to the rules given in the relevant specifications. <ref
spec=HTTP> <ref spec=WEBLINK></p> <!-- WEBLINK is ref for Link: header -->
<p>To <dfn>process link headers</dfn> given a <code>Document</code> <var>doc</var>, a <span
data-x="concept-response">response</span> <var>response</var>, and a "<code
data-x="">pre-media</code>" or "<code data-x="">media</code>" <var>phase</var>:</p>

<p class="note">Registration of relation types in HTTP `<code data-x="http-link">Link</code>`
headers is distinct from <a href="#linkTypes">HTML link types</a>, and thus their semantics can be
different from same-named HTML types.</p>
<ol>
<li><p>Let <var>rawLinkHeaders</var> be the result of <span
data-x="concept-header-list-get-decode-split">getting, decoding, and splitting</span>
`<code>Link</code>` from <var>response</var>'s <span
data-x="concept-response-header-list">header list</span>.</p></li>

<li>
<p><span data-x="list iterate">For each</span> <var>linkHeader</var> of
<var>rawLinkHeaders</var>:</p>

<ol>
<li><p>Let <var>linkObject</var> be the result of <span data-x="parsing a link header
value">parsing</span> <var>linkHeader</var>. <ref spec=WEBLINK></p></li>

<li>
<p>If <var>linkObject</var>["<code data-x="">relation_type</code>"] is not "<code
data-x="rel-preload">preload</code>", then <span>continue</span>.</p>

<p class="note">Support for additional link types can be added here in the future.</p>
</li>

<li><p>Let <var>attribs</var> be <var>linkObject</var>["<code
data-x="">target_attributes</code>"].</p></li>

<p class="XXX">The processing of `<code data-x="http-link">Link</code>` headers, in particular
their influence on a <code>Document</code>'s <span>script-blocking style sheet counter</span>, is
not defined. See <a href="https://github.com/whatwg/html/issues/4224">issue #4224</a> for
discussion on integrating this into the spec.</p>
<li><p>Let <var>expectedPhase</var> be "<code data-x="">media</code>" if either "<code
data-x="attr-img-srcset">srcset</code>", "<code
data-x="attr-link-imagesrcset">imagesrcset</code>", or "<code
data-x="attr-link-media">media</code>" <span data-x="map exists">exist</span> in
<var>attribs</var>; otherwise false.</p></li>

<li><p>If <var>expectedPhase</var> is not <var>phase</var>, then
<span>continue</span>.</p></li>

<li><p>If <var>params</var> includes "<code data-x="attr-link-media">media</code>" and
<var>params</var>["<code data-x="attr-link-media">media</code>"] does not <span
data-x="matches the environment">match the environment</span>, then
<span>continue</span>.</p></li>

<li><p>Let <var>element</var> be the result of <span data-x="create an element">creating an
element</span> given <var>doc</var>, <code>link</code>, and the <span>HTML
namespace</span>.</p></li>

<li><p><span data-x="concept-element-attributes-set-value">Set an attribute value</span> for
<var>element</var> using "<code data-x="attr-link-href">href</code>" and
<var>linkObject</var>["<code data-x="">target_uri</code>"].</p></li>

<li><p><span data-x="concept-element-attributes-set-value">Set an attribute value</span> for
<var>element</var> using "<code data-x="attr-link-href">rel</code>" and
<var>linkObject</var>["<code data-x="">relation_type</code>"].</p></li>

<li><p><span data-x="map iterate">For each</span> <var>entry</var> in <var>attribs</var>: if
<var>entry</var>[0] is "<code data-x="attr-link-as">as</code>", "<code
data-x="attr-link-type">type</code>", "<code
data-x="attr-link-crossorigin">crossorigin</code>", "<code
data-x="attr-link-imagesizes">imagesizes</code>", "<code
data-x="attr-link-blocking">blocking</code>", "<code
data-x="attr-link-integrity">integrity</code>", "<code
data-x="attr-link-imagesrcset">imagesrcset</code>", or "<code
data-x="attr-link-media">media</code>", then <span
data-x="concept-element-attributes-set-value">set an attribute value</span> for
<var>element</var> using <var>entry</var>[0] and <var>entry</var>[1].</p></li>

<li><p><span data-x="fetch and process the linked resource">Fetch and process</span>
<var>el</var>.</p></li>
</ol>
</li>
</ol>

<p class="XXX">The processing of `<code data-x="http-link">Link</code>` headers apart from <code
data-x="rel-preload">preload</code>, in particular their influence on a <code>Document</code>'s
<span>script-blocking style sheet counter</span>, is not defined. See <a
href="https://github.com/whatwg/html/issues/4224">issue #4224</a> for discussion on integrating
this into the spec.</p>

</div>

Expand Down Expand Up @@ -88852,6 +88916,10 @@ interface <dfn interface>Location</dfn> { // but see also <a href="#the-location
href="https://github.com/whatwg/html/issues/2900">issue #2900</a>.</p>
</li>

<li><p><span>Process link headers</span> given <var>document</var>,
<var>navigationParams</var>'s <span data-x="navigation-params-response">response</span>, and
"<code data-x="">pre-media</code>".</p></li>

<li><p>Return <var>document</var>.</p></li>
</ol>

Expand Down Expand Up @@ -89065,12 +89133,18 @@ new PaymentRequest(&hellip;); // Allowed to use
<var>navigationParams</var>.</p></li>

<li>
<p>Create an <span>HTML parser</span> and associate it with the <var>document</var>. Each
<p>Create an <span>HTML parser</span> and associate it with the <var>document</var>. Each
<span data-x="concept-task">task</span> that the <span>networking task source</span> places on
the <span>task queue</span> while fetching runs must then fill the parser's <span>input byte
stream</span> with the fetched bytes and cause the <span>HTML parser</span> to perform the
appropriate processing of the input stream.</p>

<p>The first <span data-x="concept-task">task</span> that the <span>networking task
source</span> places on the <span>task queue</span> while fetching runs must <span>process link
headers</span> given <var>document</var>, <var>navigationParams</var>'s <span
data-x="navigation-params-response">response</span>, and "<code data-x="">media</code>", after
the task has been procesed by the <span>HTML parser</span>.</p>

<p class="note">The <span>input byte stream</span> converts bytes into characters for use in the
<span data-x="tokenization">tokenizer</span>. This process relies, in part, on character encoding
information found in the real <span data-x="Content-Type">Content-Type metadata</span> of the
Expand Down Expand Up @@ -89103,6 +89177,12 @@ new PaymentRequest(&hellip;); // Allowed to use
<var>navigationParams</var>. They must also create a corresponding <span>XML parser</span>.
<ref spec=XML> <ref spec=XMLNS> <ref spec=RFC7303> <ref spec=DOM></p>

<p>The first <span data-x="concept-task">task</span> that the <span>networking task source</span>
places on the <span>task queue</span> while fetching runs must <span>process link headers</span>
given <var>document</var>, <var>navigationParams</var>'s <span
data-x="navigation-params-response">response</span>, and "<code data-x="">media</code>", after
the task has been procesed by the <span>XML parser</span>.</p>

<p class="note">At the time of writing, the XML specification community had not actually yet
specified how XML and the DOM interact.</p> <!--XMLPARSE-->

Expand Down Expand Up @@ -89166,6 +89246,12 @@ new PaymentRequest(&hellip;); // Allowed to use
"navigate-ua-inline" section, and the next three are similar to the navigate-media and
navigate-plugin sections; keep them all in sync -->

<p>The first <span data-x="concept-task">task</span> that the <span>networking task source</span>
places on the <span>task queue</span> while fetching runs must <span>process link headers</span>
given <var>document</var>, <var>navigationParams</var>'s <span
data-x="navigation-params-response">response</span>, and "<code data-x="">media</code>", after
the task has been procesed by the <span>HTML parser</span>.</p>

<p>When no more bytes are available, the user agent must <span>queue a global task</span> on the
<span>networking task source</span> given the newly-created <code>Document</code>'s <span>relevant
global object</span> for the parser to process the implied EOF character, which eventually causes
Expand Down Expand Up @@ -89234,6 +89320,10 @@ new PaymentRequest(&hellip;); // Allowed to use

<li><p>Set the appropriate attribute of the element <var>host element</var>, as described below,
to the address of the image, video, or audio resource.</p></li>

<li><p><span>Process link headers</span> given <var>document</var>,
<var>navigationParams</var>'s <span data-x="navigation-params-response">response</span>, and
"<code data-x="">media</code>".</p></li>
</ol>

<p>The element <var>host element</var> to create for the media is the element given in
Expand Down Expand Up @@ -89299,6 +89389,10 @@ new PaymentRequest(&hellip;); // Allowed to use

<li><p>Set the <code data-x="attr-embed-src">src</code> attribute of the <code>embed</code>
element to the address of the resource.</p></li>

<li><p><span>Process link headers</span> given <var>document</var>,
<var>navigationParams</var>'s <span data-x="navigation-params-response">response</span>, and
"<code data-x="">media</code>".</p></li>
</ol>

<p class="note">The term <span>plugin document</span> is used by
Expand Down