Skip to content

Commit 11523e1

Browse files
committed
Define preconnect and dns-prefetch with CSP
See whatwg/html#9035
1 parent 8f10983 commit 11523e1

File tree

1 file changed

+73
-1
lines changed

1 file changed

+73
-1
lines changed

fetch.bs

+73-1
Original file line numberDiff line numberDiff line change
@@ -3023,6 +3023,78 @@ details of reused connections are not exposed and time values are coarsened.
30233023
</div>
30243024

30253025

3026+
<h3 id=preemptive-connection-operations>Preemptive connection operations</h3>
3027+
3028+
<div algorithm="preemmptively-obtain-a-connection">
3029+
<p>To <dfn export>preemptively obtain a connection</dfn>, given an
3030+
<a>environment settings object</a> <var>environment</var>, a <a for=/>URL</a> <var>url</var>, and a
3031+
boolean <var>credentials</var>, run these steps:
3032+
3033+
<ol>
3034+
<li><p>Let <var>key</var> be the result of <a for=/>determining the network partition key</a> given
3035+
<var>environment</var>.
3036+
3037+
<li>
3038+
<p><a>Check CSP for preemptive operation</a> with <var>environment</var> and <var>url</var>. If
3039+
that returns <b>allowed</b>, <a>Obtain a connection</a> with <var>key</var>, <var>url</var> and
3040+
<var>credentials</var>.
3041+
3042+
<p class=note>This connection is obtained but not used directly. It will remain in the
3043+
<a>connection pool</a> for subsequent use.
3044+
3045+
<p class=note>The user agent should attempt to initiate a preconnect and perform the full
3046+
connection handshake (DNS+TCP for HTTP, and DNS+TCP+TLS for HTTPS origins) whenever possible, but
3047+
is allowed to elect to perform a partial handshake (DNS only for HTTP, and DNS or DNS+TCP for
3048+
HTTPS origins), or skip it entirely, due to resource constraints or other reasons.</p>
3049+
3050+
<p class=note>The optimal number of connections per origin is dependent on the negotiated
3051+
protocol, users current connectivity profile, available device resources, global connection
3052+
limits, and other context specific variables. As a result, the decision for how many connections
3053+
should be opened is deferred to the user agent.</p>
3054+
</ol>
3055+
</div>
3056+
3057+
<div algorithm="preemmptively-resolve-an-origin">
3058+
<p>To <dfn export>preemptively resolve an origin</dfn>, given an
3059+
<a>environment settings object</a> <var>environment</var> and a <a for=/>URL</a> <var>url</var>, run
3060+
these steps:
3061+
3062+
<ol>
3063+
<li><p>Let <var>key</var> be the result of <a for=/>determining the network partition key</a> given
3064+
<var>environment</var>.
3065+
3066+
<li><p><a>Check CSP for preemptive operation</a> with <var>environment</var> and <var>url</var>. If
3067+
that returns <b>blocked</b>, return.
3068+
3069+
<li><p>Let <var>proxies</var> be the result of finding proxies for <var>url</var> in an
3070+
<a>implementation-defined</a> manner.
3071+
3072+
<li>
3073+
<p>If there <var>proxies</var> is <a for=list>empty</a>, or if <var>proxies</var>
3074+
<a for=list>contains</a> "<code>DIRECT</code>", then <a>resolve an origin</a> given <var>key</var>
3075+
and <var>url</var>'s <a for=url>origin</a>.
3076+
3077+
<p class=note>As the results of this algorithm can be cached, future fetches could be faster.
3078+
</ol>
3079+
</div>
3080+
3081+
<div algorithm="check-preemptive-operation-csp">
3082+
<p>To <dfn>Check CSP for preemptive operation</dfn>, given an
3083+
<a>environment settings object</a> <var>environment</var>, and a <a for=/>URL</a> <var>url</var>,
3084+
run these steps:
3085+
3086+
<ol>
3087+
<li><p>Let <var>request</var> be a <a for=/>request</a> whose <a for=request>URL</a> is
3088+
<var>url</var>, <a for=request>initiator</a> is "<code>prefetch</code>", and whose
3089+
<a for=request>client</a> is <var>environment</var>.
3090+
3091+
<li><p>Return the result of running <a>should request be blocked by Content Security Policy?</a>
3092+
given <var>request</var>.
3093+
3094+
</ol>
3095+
</div>
3096+
3097+
30263098
<h3 id=network-partition-keys>Network partition keys</h3>
30273099

30283100
<p>A <dfn>network partition key</dfn> is a tuple consisting of a <a for=/>site</a> and null or
@@ -8710,7 +8782,7 @@ to discuss. [[CSP]]
87108782
<a>environment settings object</a> you're operating in. Web-exposed APIs are generally defined with
87118783
Web IDL, for which every object that implements an <a>interface</a> has a
87128784
<a>relevant settings object</a> you can use. For example, a <a for=/>request</a> associated with an
8713-
<a for=/>element</a> would set the <a for=/>request</a>'s <a for=request>client</a> to the element's
8785+
{{Element}} would set the <a for=/>request</a>'s <a for=request>client</a> to the element's
87148786
<a>node document</a>'s <a>relevant settings object</a>. All features that are directly web-exposed
87158787
by JavaScript, HTML, CSS, or other {{Document}} subresources should have a
87168788
<a for=request>client</a>.

0 commit comments

Comments
 (0)