Skip to content

Commit 9829bab

Browse files
committed
Link to https upgrading from main fetch
1 parent 4693f1a commit 9829bab

File tree

1 file changed

+107
-116
lines changed

1 file changed

+107
-116
lines changed

fetch.bs

Lines changed: 107 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -3089,113 +3089,6 @@ an <a>implementation-defined</a> value.
30893089
</ol>
30903090
</div>
30913091

3092-
<h3 id=https-upgrades>HTTPS upgrades</h3>
3093-
3094-
<div algorithm>
3095-
3096-
<p>User agents may optionally upgrade requests with <a>potentially untrustworthy URL</a>s
3097-
to attempt to fetch them over <a>potentially trustworthy URL</a>s. If an upgraded request
3098-
fails with a network error, it is retried over the original URL.
3099-
3100-
<p>The HTTPS Upgrades algorithm consists of Upgrade and Fallback algorithms, with the following
3101-
steps:
3102-
3103-
<h4>Upgrade algorithm</h4>
3104-
3105-
<p>Given a request <var>request</var>, this algorithm will rewrite its URL if the request should be
3106-
modified and loaded over <code>"https"</code>, via the following algorithm:
3107-
3108-
<ol>
3109-
<li>
3110-
<p>If one or more of the following conditions are met, return without modifying request:
3111-
<ul>
3112-
<li><p><var>request</var> is not a navigation request whose destination is document</li>
3113-
3114-
<li><p><var>request</var>'s method is not `<code>GET</code>`</li>
3115-
3116-
<li><p><var>request</var>'s URL's scheme is not <code>"http"</code></li>
3117-
3118-
<li><p><var>request</var>'s URL's host is non-unique (i.e., contains a non-registrable or
3119-
non-assignable domain name such as .local or an IP address that falls in a range reserved for
3120-
non-publicly routable networks)</li>
3121-
3122-
<li><p>Optionally, <var>request</var>'s URL's host is exempted from upgrades by the user agent
3123-
</li>
3124-
</ul>
3125-
</li>
3126-
3127-
<li><p>If <var>request</var>'s <code>https-upgrade-fallback-url</code> is non-null, this is a
3128-
fallback request that shouldn't be upgraded again. Clear the <code>https-upgrade</code> and
3129-
<code>https-upgrade-fallback-url</code> flags and return <var>request</var>.</li>
3130-
3131-
<li><p>Otherwise, upgrade the request by setting the following fields:
3132-
<ul>
3133-
<li>Set <code>https-upgrade-fallback-url</code> to request's URL</li>
3134-
<li>Set <var>request</var>'s URL's scheme to <code>"https"</code></li>
3135-
<li>Set <code>https-upgrade</code> flag to true</li>
3136-
</ul>
3137-
</li>
3138-
</ol>
3139-
3140-
<h4>Fallback algorithm</h4>
3141-
3142-
<p>Runs after the Upgrade algorithm. This algorithm determines whether the upgraded
3143-
request completed without a network error. If not, it retries the request over <code>"http"</code>.
3144-
3145-
<ol>
3146-
<li><p>If the <code>https-upgrade</code> flag is not set, return without modifying request.</li>
3147-
3148-
<li><p>Otherwise, this is an upgraded request. Let <var>upgradedResponse</var> be the result of
3149-
fetching the upgraded request.</li>
3150-
3151-
<li>
3152-
<p>If <var>upgradedResponse</var> is a network error, initiate a fallback http load by doing the
3153-
following:
3154-
3155-
<ul>
3156-
<li><p>Set <var>request</var>'s URL to the value of <var>request</var>'s
3157-
<code>https-upgrade-fallback-url</code> flag</li>
3158-
3159-
<li><p>Set response to the result of running <a>HTTP-redirect fetch</a> given fetchParams and
3160-
<var>upgradedResponse</var>.</li>
3161-
</ul>
3162-
</li>
3163-
3164-
<li><p>Otherwise, the upgrade was successful. Return <var>upgradedResponse</var>.</li>
3165-
</ol>
3166-
3167-
<p>
3168-
Optionally, user agents may implement a fast-fallback option by canceling slow fetches on upgraded
3169-
requests and quickly initiate a fallback http load.
3170-
3171-
</div>
3172-
3173-
<h4>Examples</h4>
3174-
3175-
<div id=example-https-upgrade-good-https class=example>
3176-
<p>
3177-
<code>a.com</code> serves both <code>http://a.com</code> and <code>https://a.com</code>.
3178-
An eligible request to <code>http://a.com</code> will be upgraded to <code>https://a.com</code>.
3179-
</div>
3180-
3181-
<div id=example-https-upgrade-bad-https class=example>
3182-
<p>
3183-
<code>a.com</code> serves <code>http://a.com</code> but refuses connections on
3184-
<code>https://a.com</code>.
3185-
An eligible request to <code>http://a.com</code> will be upgraded to <code>https://a.com</code>,
3186-
but the fetch will fail.
3187-
A fallback request will be initiated to <code>http://a.com</code>.
3188-
</div>
3189-
3190-
<div id=example-https-upgrade-slow-https class=example>
3191-
<p>
3192-
Optional fast-fallback example: <code>a.com</code> serves <code>http://a.com</code> and loads very
3193-
slowly over <code>https://a.com</code>.
3194-
An eligible request to <code>http://a.com</code> will be upgraded to <code>https://a.com</code>.
3195-
If the upgraded request doesn't return a response for N seconds, the fetch will be canceled.
3196-
A fallback request will be initiated to <code>http://a.com</code>.
3197-
</div>
3198-
31993092
<h3 id=port-blocking>Port blocking</h3>
32003093

32013094
<p class=note>New protocols can avoid the need for blocking ports by negotiating the protocol
@@ -3334,7 +3227,112 @@ through TLS using ALPN. The protocol cannot be spoofed through HTTP requests in
33343227
</ol>
33353228
</div>
33363229

3230+
<h3 id=https-upgrades>HTTPS upgrading</h3>
3231+
3232+
<div algorithm>
3233+
3234+
<p>User agents may optionally upgrade requests with <a>potentially untrustworthy URL</a>s
3235+
to attempt to fetch them over <a>potentially trustworthy URL</a>s. If an upgraded request
3236+
fails with a network error, it is retried over the original URL.
3237+
3238+
<p>The HTTPS upgrading algorithm consists of Upgrade and Fallback algorithms, with the following
3239+
steps:
3240+
3241+
<h4 id=https-upgrades-upgrade>Upgrade algorithm</h4>
3242+
3243+
<p>Given a request <var>request</var>, this algorithm will rewrite its URL if the request should be
3244+
modified and loaded over <code>"https"</code>, via the following algorithm:
3245+
3246+
<ol>
3247+
<li>
3248+
<p>If one or more of the following conditions are met, return without modifying request:
3249+
<ul>
3250+
<li><p><var>request</var> is not a navigation request whose destination is document</li>
3251+
3252+
<li><p><var>request</var>'s method is not `<code>GET</code>`</li>
3253+
3254+
<li><p><var>request</var>'s URL's scheme is not <code>"http"</code></li>
3255+
3256+
<li><p><var>request</var>'s URL's host is non-unique (i.e., contains a non-registrable or
3257+
non-assignable domain name such as .local or an IP address that falls in a range reserved for
3258+
non-publicly routable networks)</li>
3259+
3260+
<li><p>Optionally, <var>request</var>'s URL's host is exempted from upgrades by the user agent
3261+
</li>
3262+
</ul>
3263+
</li>
3264+
3265+
<li><p>If <var>request</var>'s <code>https-upgrade-fallback-url</code> is non-null, this is a
3266+
fallback request that shouldn't be upgraded again. Clear the <code>https-upgrade</code> and
3267+
<code>https-upgrade-fallback-url</code> flags and return <var>request</var>.</li>
3268+
3269+
<li><p>Otherwise, upgrade the request by setting the following fields:
3270+
<ul>
3271+
<li>Set <code>https-upgrade-fallback-url</code> to request's URL</li>
3272+
<li>Set <var>request</var>'s URL's scheme to <code>"https"</code></li>
3273+
<li>Set <code>https-upgrade</code> flag to true</li>
3274+
</ul>
3275+
</li>
3276+
</ol>
3277+
3278+
<h4 id=https-upgrades-fallback>Fallback algorithm</h4>
3279+
3280+
<p>Runs after the Upgrade algorithm. This algorithm determines whether the upgraded
3281+
request completed without a network error. If not, it retries the request over <code>"http"</code>.
3282+
3283+
<ol>
3284+
<li><p>If the <code>https-upgrade</code> flag is not set, return without modifying request.</li>
3285+
3286+
<li><p>Otherwise, this is an upgraded request. Let <var>upgradedResponse</var> be the result of
3287+
fetching the upgraded request.</li>
3288+
3289+
<li>
3290+
<p>If <var>upgradedResponse</var> is a network error, initiate a fallback http load by doing the
3291+
following:
3292+
3293+
<ul>
3294+
<li><p>Set <var>request</var>'s URL to the value of <var>request</var>'s
3295+
<code>https-upgrade-fallback-url</code> flag</li>
3296+
3297+
<li><p>Set response to the result of running <a>HTTP-redirect fetch</a> given fetchParams and
3298+
<var>upgradedResponse</var>.</li>
3299+
</ul>
3300+
</li>
3301+
3302+
<li><p>Otherwise, the upgrade was successful. Return <var>upgradedResponse</var>.</li>
3303+
</ol>
3304+
3305+
<p>
3306+
Optionally, user agents may implement a fast-fallback option by canceling slow fetches on upgraded
3307+
requests and quickly initiate a fallback http load.
3308+
3309+
</div>
3310+
3311+
<h4>Examples</h4>
33373312

3313+
<div id=example-https-upgrade-good-https class=example>
3314+
<p>
3315+
<code>a.com</code> serves both <code>http://a.com</code> and <code>https://a.com</code>.
3316+
An eligible request to <code>http://a.com</code> will be upgraded to <code>https://a.com</code>.
3317+
</div>
3318+
3319+
<div id=example-https-upgrade-bad-https class=example>
3320+
<p>
3321+
<code>a.com</code> serves <code>http://a.com</code> but refuses connections on
3322+
<code>https://a.com</code>.
3323+
An eligible request to <code>http://a.com</code> will be upgraded to <code>https://a.com</code>,
3324+
but the fetch will fail.
3325+
A fallback request will be initiated to <code>http://a.com</code>.
3326+
</div>
3327+
3328+
<div id=example-https-upgrade-slow-https class=example>
3329+
<p>
3330+
Optional fast-fallback example: <code>a.com</code> serves <code>http://a.com</code> and loads very
3331+
slowly over <code>https://a.com</code>.
3332+
An eligible request to <code>http://a.com</code> will be upgraded to <code>https://a.com</code>.
3333+
If the upgraded request doesn't return a response for N seconds, the fetch will be canceled.
3334+
A fallback request will be initiated to <code>http://a.com</code>.
3335+
</div>
33383336

33393337
<h2 id=http-extensions>HTTP extensions</h2>
33403338

@@ -4514,11 +4512,7 @@ steps:
45144512

45154513
<li><p><a>Upgrade <var>request</var> to a potentially trustworthy URL, if appropriate</a>.
45164514

4517-
<li><p>If <var>request</var> is a <a>navigation request</a> whose <a for=request>destination</a>
4518-
is <code>document</code>, <var>request</var>'s <a for=request>method</a> is <code>GET</code>,
4519-
and <var>request</var>'s <a for=request>URL</a> is not a <a>potentially trustworthy URL</a>,
4520-
optionally upgrade it to a <a>potentially trustworthy URL<a>. If <var>request</var> is upgraded,
4521-
set <var>request</var>'s <a for=request>https-upgrade</a> flag to true.
4515+
<li><p><a href="#https-upgrades-upgrade">Optionally, run HTTPS upgrading algorithm on <var>request</var>, if appropriate</a>.
45224516

45234517
<li><p><a>Upgrade a mixed content <var>request</var> to a potentially trustworthy URL, if appropriate</a>.
45244518

@@ -5339,10 +5333,7 @@ these steps:
53395333
<!-- not resetting actualResponse since it's no longer used anyway -->
53405334
</ol>
53415335

5342-
<li><p>If <var>response</var> is a <a>network error</a> and <var>request</var> has the
5343-
<a>https-upgrade</a> flag set, set <var>request</var>'s <a for=/>URL</a> <a for=url>scheme</a>
5344-
to <code>http</code> and set <var>response</var> to the result of running <a>HTTP-redirect fetch</a>
5345-
given <var>fetchParams</var> and <var>response</var>.
5336+
<li><p><a href="#https-upgrades-fallback">Optionally, run HTTPS upgrading fallback algorithm, if appropriate.</a>
53465337

53475338
<li><p>Return <var>response</var>. <span class=note>Typically <var>actualResponse</var>'s
53485339
<a for=response>body</a>'s <a for=body>stream</a> is still being enqueued to after

0 commit comments

Comments
 (0)