diff --git a/fetch.bs b/fetch.bs index 903bb662..8c748069 100644 --- a/fetch.bs +++ b/fetch.bs @@ -2162,6 +2162,17 @@ Unless stated otherwise, it is false.

This flag is for exclusive use by HTML's render-blocking mechanism. [[!HTML]] +

A request has an associated boolean is HTTPS upgrade. +Unless stated otherwise, it is false. + +

This is for exclusive use by HTTPS upgrading. + +

A request has an associated +HTTPS upgrade fallback URL, which is null or a URL. +Unless otherwise stated, it is null. + +

This is for exclusive use by HTTPS upgrading. +


A request has an associated @@ -3270,6 +3281,120 @@ through TLS using ALPN. The protocol cannot be spoofed through HTTP requests in +

HTTPS upgrading

+ +

User agents may optionally upgrade requests with URLs that are not +potentially trustworthy URLs to attempt to fetch them over +potentially trustworthy URLs. If an upgraded request fails with a network error, it is +retried over the original URL. + +

The HTTPS upgrading algorithm consists of upgrade an HTTP request and +HTTPS upgrade fallback algorithms. + + +

HTTPS upgrade algorithm

+ +
+

To upgrade an HTTP request given a request request: + +

    +
  1. +

    If one or more of the following conditions are met, return: +

    +
  2. + +
  3. +

    If request's HTTPS upgrade fallback URL is non-null, set + is HTTPS upgrade to false and HTTPS upgrade fallback URL to + null and return. + +

    This is a fallback request that cannot be upgraded again. + +

  4. +

    Otherwise: +

    +
  5. +
+
+ + +

Fallback algorithm

+ +
+

To run HTTPS upgrade fallback given a request request and +response response: + +

    +
  1. If request's is HTTPS upgrade is false, then return + response. + +

  2. +

    If response is a network error: + +

    This means that the upgrade failed and initiates a fallback load. + +

      +
    1. Let serializedFallbackUrl be the request's + HTTPS upgrade fallback URL, serialized and + isomorphic encoded. + +

    2. Let fallbackResponse be a new response whose + header list is « + (`Location`, serializedFallbackUrl) » and + status is 307. + +

    3. Return fallbackResponse. +

    + +
  3. +

    Return response. + +

    This means the upgrade was successful. +

+ +

User agents can implement a fast-fallback path by canceling slow fetches on upgraded +requests, in order to quickly initiate a fallback HTTP fetch. +

+ + +

Examples

+ +

a.com serves both +http://a.com and https://a.com. An eligible request to +http://a.com will be upgraded to https://a.com. + +

a.com serves +http://a.com but refuses connections on https://a.com. An eligible +request to http://a.com will be upgraded to https://a.com, but the fetch +will fail. A fallback request will be initiated to http://a.com. + +

site.test serves +http://site.test but refuses connections on https://site.test. Upon +first request and fallback to http://site.test, the user agent stores the hostname +in an allowlist with an expiration time of 7 days. In a future request, if site.test +is still in this allowlist, the user agent will not upgrade http://site.test to +https://site.test. The user agent will also set the new expiration time of the +allowlist entry for site.test to 7 days from now. + +

HTTP extensions

@@ -4457,6 +4582,14 @@ steps:
  • Upgrade request to a potentially trustworthy URL, if appropriate. +

  • +

    Optionally, run upgrade an HTTP request algorithm on request. + +

    HTTPS upgrading only applies to requests with HTTP(S) schemes, but it's done + in main fetch instead of HTTP fetch to ensure that + upgrade a mixed content request to a potentially trustworthy URL, if appropriate + step runs next and applies to the upgraded request. +

  • Upgrade a mixed content request to a potentially trustworthy URL, if appropriate.

  • If should request be blocked due to a bad port, @@ -6001,7 +6134,8 @@ optional boolean forceNewConnection (default false), run these steps: canceled:

      -
    1. If connection is failure, then return a network error. +

    2. If connection is failure, then return the result of running + HTTPS upgrade fallback given request and network error.

    3. Set timingInfo's final connection timing info to the result of calling clamp and coarsen connection timing info with @@ -8727,7 +8861,7 @@ resource — for non-CORS requests as well as CORS requests — and do not use `Vary`. -

      WebSockets

      +

      WebSockets

      As part of establishing a connection, the {{WebSocket}} object initiates a special kind of fetch (using a request whose mode is @@ -8991,6 +9125,7 @@ done only by navigations). The fetch controller is also used to redirect mode set to "manual". +

      Acknowledgments

      Thanks to