diff --git a/fetch.bs b/fetch.bs index 58579420d..f4b4996e2 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,139 @@ 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 any of the following are true: + +

    + +

    then return. +

  2. + +
  3. +

    If request's HTTPS upgrade fallback URL is non-null, then 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: + +

      +
    1. Set HTTPS upgrade fallback URL to request's + URL. + +

    2. Set request's URL's scheme to + "https". + +

    3. Set is HTTPS upgrade to true. +

    +
  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. + +

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

a.com serves +http://a.com:8080. When a site is served from a non-default HTTP port, it's unlikely +that the corresponding HTTPS URL is served from the default port either. Therefore, the user agent +doesn't upgrade requests to http://a.com:8080. + +

a.com serves +http://a.com and https://a.com. The latter redirects to the former. +An eligible request to http://a.com will be upgraded to +https://a.com and will be redirected back to http://a.com. +The user agent will detect this as a redirect loop, treat it as a failed upgrade and initiate a +fallback navigation to http://a.com. + +

HTTP extensions

@@ -4504,6 +4648,8 @@ steps: in the fetch algorithm and potentially unwind logic on discovering the need to change request's current URL's scheme. +
  • Optionally, run upgrade an HTTP request algorithm on request. +

  • If recursive is false, then run the remaining steps in parallel.

  • @@ -6001,7 +6147,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 a network error.

    3. Set timingInfo's final connection timing info to the result of calling clamp and coarsen connection timing info with @@ -8727,7 +8874,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 +9138,7 @@ done only by navigations). The fetch controller is also used to redirect mode set to "manual". +

      Acknowledgments

      Thanks to