Skip to content

Commit b2f04e2

Browse files
authored
Add proxy support to obtain a connection
This is a further incremental step toward making it possible to properly layer WebSocket connections on top of this primitive (see #1243). WebTransport PR: w3c/webtransport#351.
1 parent 4c1c5b0 commit b2f04e2

File tree

1 file changed

+64
-41
lines changed

1 file changed

+64
-41
lines changed

fetch.bs

Lines changed: 64 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2244,9 +2244,6 @@ be used as part of the cache key.
22442244
<li><p>If <var>origin</var>'s <a for=origin>host</a> is an <a for=/>IP address</a>, then return
22452245
« <var>origin</var>'s <a for=origin>host</a> ».
22462246

2247-
<li><p>If the user agent is configured to use a proxy that resolves domains on its own, then return
2248-
« <var>origin</var>'s <a for=origin>host</a> ».
2249-
22502247
<li><p>Return the result of running <a>resolve a domain</a> given <var>key</var> and
22512248
<var>origin</var>'s <a for=origin>host</a>.
22522249
</ol>
@@ -2324,23 +2321,25 @@ steps:
23242321

23252322
<hr>
23262323

2324+
<p>A <dfn>new connection setting</dfn> is "<code>no</code>", "<code>yes</code>", or
2325+
"<code>yes-and-dedicated</code>".
2326+
23272327
<p>To <dfn export id=concept-connection-obtain>obtain a connection</dfn>, given a
2328-
<a>network partition key</a> <var>key</var>, <a for=/>origin</a> <var>origin</var>, boolean
2329-
<var>credentials</var>, an optional boolean <var>forceNew</var> (default false), an optional boolean
2330-
<dfn export for="obtain a connection"><var>http3Only</var></dfn> (default false), and an optional
2331-
boolean <dfn export for="obtain a connection"><var>dedicated</var></dfn> (default false), run these
2332-
steps:
2333-
<!-- http3Only and dedicated have been added for WebTransport -->
2328+
<a>network partition key</a> <var>key</var>, <a for=/>URL</a> <var>url</var>, boolean
2329+
<var>credentials</var>, an optional <a>new connection setting</a> <var>new</var> (default
2330+
"<code>no</code>"), and an optional boolean
2331+
<dfn export for="obtain a connection"><var>http3Only</var></dfn> (default false), run these steps:
2332+
<!-- new's "yes-and-dedicated" and http3Only have been added for WebTransport -->
23342333

23352334
<ol>
23362335
<li>
2337-
<p>If <var>forceNew</var> is false or <var>dedicated</var> is false, then:
2336+
<p>If <var>new</var> is "<code>no</code>", then:
23382337

23392338
<ol>
23402339
<li><p>Let <var>connections</var> be a set of <a>connections</a> in the user agent's
23412340
<a>connection pool</a> whose <a for=connection>key</a> is <var>key</var>,
2342-
<a for=connection>origin</a> is <var>origin</var>, and <a for=connection>credentials</a> is
2343-
<var>credentials</var>.
2341+
<a for=connection>origin</a> is <var>url</var>'s <a for=url>origin</a>, and
2342+
<a for=connection>credentials</a> is <var>credentials</var>.
23442343

23452344
<li><p>If <var>connections</var> is not empty and <var>http3Only</var> is false, then return
23462345
one of <var>connections</var>.
@@ -2349,38 +2348,59 @@ steps:
23492348
<a>connection</a>.
23502349
</ol>
23512350

2351+
<li>
2352+
<p>Let <var>proxies</var> be the result of finding proxies for <var>url</var> in an
2353+
<a>implementation-defined</a> manner. If there are no proxies, let <var>proxies</var> be
2354+
« "<code>DIRECT</code>" ».
2355+
2356+
<p class=note>This is where non-standard technology such as
2357+
<a href="https://en.wikipedia.org/wiki/Web_Proxy_Auto-Discovery_Protocol">Web Proxy Auto-Discovery Protocol (WPAD)</a>
2358+
and <a href="https://en.wikipedia.org/wiki/Proxy_auto-config">proxy auto-config (PAC)</a> come
2359+
into play. The "<code>DIRECT</code>" value means to not use a proxy for this particular
2360+
<var>url</var>.
2361+
23522362
<li><p>Let <var>timingInfo</var> be a new <a for=/>connection timing info</a>.
23532363

2354-
<li><p>Set <var>timingInfo</var>'s <a for="connection timing info">domain lookup start time</a> to
2355-
the <a for=/>unsafe shared current time</a>.
2364+
<li>
2365+
<p><a for=list>For each</a> <var>proxy</var> of <var>proxies</var>:
2366+
2367+
<ol>
2368+
<li><p>Set <var>timingInfo</var>'s <a for="connection timing info">domain lookup start time</a>
2369+
to the <a for=/>unsafe shared current time</a>.
23562370

2357-
<li><p>Let <var>hosts</var> be the result of running <a>resolve an origin</a> given <var>key</var>
2358-
and <var>origin</var>.
2371+
<li><p>Let <var>hosts</var> be « <var>origin</var>'s <a for=origin>host</a> ».
23592372

2360-
<li><p>If <var>hosts</var> is failure, then return failure.
2373+
<li><p>If <var>proxy</var> is "<code>DIRECT</code>", then set <var>hosts</var> to the result of
2374+
running <a>resolve an origin</a> given <var>key</var> and <var>url</var>'s <a for=url>origin</a>.
23612375

2362-
<li><p>Set <var>timingInfo</var>'s <a for="connection timing info">domain lookup end time</a> to
2363-
the <a for=/>unsafe shared current time</a>.
2376+
<li><p>If <var>hosts</var> is failure, then <a for=iteration>continue</a>.
23642377

2365-
<li>
2366-
<p>Let <var>connection</var> be the result of running this step: run <a>create a connection</a>
2367-
given <var>key</var>, <var>origin</var>, <var>credentials</var>, an <a>implementation-defined</a>
2368-
<a for=/>host</a> from <var>hosts</var>, <var>timingInfo</var>, and <var>http3Only</var> an
2369-
<a>implementation-defined</a> number of times, <a>in parallel</a> from each other, and wait for at
2370-
least 1 to return a value. In an <a>implementation-defined</a> manner, select a value to return
2371-
from the returned values and return it. Any other returned values that are <a>connections</a> may
2372-
be closed.
2378+
<li><p>Set <var>timingInfo</var>'s <a for="connection timing info">domain lookup end time</a> to
2379+
the <a for=/>unsafe shared current time</a>.
23732380

2374-
<p class=note>Essentially this allows an implementation to pick one or more
2375-
<a for=/>IP addresses</a> from the return value of <a>resolve a domain</a> (assuming no proxy) and
2376-
race them against each other, favor <a for=/>IPv6 addresses</a>, retry in case of a timeout, etc.
2381+
<li>
2382+
<p>Let <var>connection</var> be the result of running this step: run <a>create a connection</a>
2383+
given <var>key</var>, <var>url</var>'s <a for=url>origin</a>, <var>credentials</var>,
2384+
<var>proxy</var>, an <a>implementation-defined</a> <a for=/>host</a> from <var>hosts</var>,
2385+
<var>timingInfo</var>, and <var>http3Only</var> an <a>implementation-defined</a> number of
2386+
times, <a>in parallel</a> from each other, and wait for at least 1 to return a value. In an
2387+
<a>implementation-defined</a> manner, select a value to return from the returned values and
2388+
return it. Any other returned values that are <a>connections</a> may be closed.
23772389

2378-
<li><p>If <var>connection</var> is failure, then return failure.
2390+
<p class=note>Essentially this allows an implementation to pick one or more
2391+
<a for=/>IP addresses</a> from the return value of <a>resolve a domain</a> (assuming
2392+
<var>proxy</var> is "<code>DIRECT</code>") and race them against each other, favor
2393+
<a for=/>IPv6 addresses</a>, retry in case of a timeout, etc.
23792394

2380-
<li><p>If <var>dedicated</var> is false, then <a for=set>append</a> <var>connection</var> to the
2381-
user agent's <a>connection pool</a>.
2395+
<li><p>If <var>connection</var> is failure, then <a for=iteration>continue</a>.
23822396

2383-
<li><p>Return <var>connection</var>.
2397+
<li><p>If <var>new</var> is not "<code>yes-and-dedicated</code>", then <a for=set>append</a>
2398+
<var>connection</var> to the user agent's <a>connection pool</a>.
2399+
2400+
<li><p>Return <var>connection</var>.
2401+
</ol>
2402+
2403+
<li><p>Return failure.
23842404
</ol>
23852405

23862406
<p class=note>This is intentionally a little vague as there are a lot of nuances to connection
@@ -2393,9 +2413,9 @@ reused across <a>connections</a> whose <a for=connection>credentials</a> are fal
23932413
<hr>
23942414

23952415
<p>To <dfn>create a connection</dfn>, given a <a for=/>network partition key</a> <var>key</var>,
2396-
<a for=/>origin</a> <var>origin</var>, boolean <var>credentials</var>, <a for=/>host</a>
2397-
<var>host</var>, <a for=/>connection timing info</a> <var>timingInfo</var>, and boolean
2398-
<var>http3Only</var>, run these steps:
2416+
<a for=/>origin</a> <var>origin</var>, boolean <var>credentials</var>, string <var>proxy</var>,
2417+
<a for=/>host</a> <var>host</var>, <a for=/>connection timing info</a> <var>timingInfo</var>, and
2418+
boolean <var>http3Only</var>, run these steps:
23992419

24002420
<ol>
24012421
<li><p>Set <var>timingInfo</var>'s <a for="connection timing info">connection start time</a> to the
@@ -2407,8 +2427,8 @@ reused across <a>connections</a> whose <a for=connection>credentials</a> are fal
24072427
<a for=connection>credentials</a> is <var>credentials</var>, and <a for=connection>timing info</a>
24082428
is <var>timingInfo</var>. <a for=/>Record connection timing info</a> given <var>connection</var>
24092429
and use <var>connection</var> to establish an HTTP connection to <var>host</var>, taking
2410-
<var>origin</var> into account. [[!HTTP]] [[!HTTP-SEMANTICS]] [[!HTTP-COND]] [[!HTTP-CACHING]]
2411-
[[!HTTP-AUTH]] [[!TLS]]
2430+
<var>proxy</var> and <var>origin</var> into account. [[!HTTP]] [[!HTTP-SEMANTICS]] [[!HTTP-COND]]
2431+
[[!HTTP-CACHING]] [[!HTTP-AUTH]] [[!TLS]]
24122432

24132433
<p>If <var>http3Only</var> is true, then establish an HTTP/3 connection. [[!HTTP3]]
24142434

@@ -5155,6 +5175,9 @@ optional boolean <var>forceNewConnection</var> (default false), run these steps:
51555175
<li><p>Let <var>networkPartitionKey</var> be the result of
51565176
<a for=request>determining the network partition key</a> given <var>request</var>.
51575177

5178+
<li><p>Let <var>newConnection</var> be "<code>yes</code>" if <var>forceNewConnection</var> is true;
5179+
otherwise "<code>no</code>".
5180+
51585181
<li>
51595182
<p>Switch on <var>request</var>'s <a for=request>mode</a>:
51605183

@@ -5167,8 +5190,8 @@ optional boolean <var>forceNewConnection</var> (default false), run these steps:
51675190
<dt>Otherwise
51685191
<dd><p>Let <var>connection</var> be the result of
51695192
<a lt="obtain a connection">obtaining a connection</a>, given <var>networkPartitionKey</var>,
5170-
<var>request</var>'s <a for=request>current URL</a>'s <a for=url>origin</a>,
5171-
<var>includeCredentials</var>, and <var>forceNewConnection</var>.
5193+
<var>request</var>'s <a for=request>current URL</a>, <var>includeCredentials</var>, and
5194+
<var>newConnection</var>.
51725195
</dl>
51735196

51745197
<li>

0 commit comments

Comments
 (0)