diff --git a/index.bs b/index.bs index 8415770..7da2764 100644 --- a/index.bs +++ b/index.bs @@ -75,6 +75,7 @@ spec:infra; type:dfn; for:/; text:set spec:streams; type:interface; text:ReadableStream spec:fetch; type:dfn; for:/; text:fetch spec:fetch; type:dfn; for:/; text:credentials +spec:fetch; type:dfn; for:fetch record; text:request spec:url; type:dfn; text:scheme spec:url; type:dfn; text:fragment spec:infra; type:dfn; for:/; text:ASCII case-insensitive @@ -853,6 +854,18 @@ A {{WebTransport}} object has the following internal slots. `[[Session]]` A [=WebTransport session=] for this {{WebTransport}} object, or null. + + `[[NewConnection]]` + Either `"no"` or `"yes-and-dedicated"`. + + + `[[RequireUnreliable]]` + A boolean indicating whether UDP is required. + + + `[[ServerCertificateHashes]]` + A [=list=] of zero or more {{WebTransportHash}} objects. + ## Constructor ## {#webtransport-constructor} @@ -861,11 +874,11 @@ A {{WebTransport}} object has the following internal slots. When the {{WebTransport/constructor()}} constructor is invoked, the user agent MUST run the following steps: 1. Let |baseURL| be [=this=]'s [=relevant settings object=]'s [=API base URL=]. -1. Let |parsedURL| be the [=URL record=] resulting from [=URL parser|parsing=] +1. Let |url| be the [=URL record=] resulting from [=URL parser|parsing=] {{WebTransport/constructor(url, options)/url}} with |baseURL|. -1. If |parsedURL| is a failure, [=throw=] a {{SyntaxError}} exception. -1. If |parsedURL| [=scheme=] is not `https`, [=throw=] a {{SyntaxError}} exception. -1. If |parsedURL| [=fragment=] is not null, [=throw=] a {{SyntaxError}} exception. +1. If |url| is a failure, [=throw=] a {{SyntaxError}} exception. +1. If |url| [=scheme=] is not `https`, [=throw=] a {{SyntaxError}} exception. +1. If |url| [=fragment=] is not null, [=throw=] a {{SyntaxError}} exception. 1. Let |allowPooling| be {{WebTransport/constructor(url, options)/options}}'s {{WebTransportOptions/allowPooling}}. 1. Let |dedicated| be the negation of |allowPooling|. @@ -873,6 +886,7 @@ agent MUST run the following steps: {{WebTransportOptions/serverCertificateHashes}} if it exists, and null otherwise. 1. If |dedicated| is false and |serverCertificateHashes| is non-null, then [=throw=] a {{NotSupportedError}} exception. +1. Let |newConnection| be `"no"` if |dedicated| is false; otherwise `"yes-and-dedicated"`. 1. Let |requireUnreliable| be {{WebTransport/constructor(url, options)/options}}'s {{WebTransportOptions/requireUnreliable}}. 1. Let |congestionControl| be {{WebTransport/constructor(url, options)/options}}'s @@ -930,12 +944,18 @@ agent MUST run the following steps: :: |datagrams| : {{[[Session]]}} :: null + : {{[[NewConnection]]}} + :: |newConnection| + : {{[[RequireUnreliable]]}} + :: |requireUnreliable| + : {{[[ServerCertificateHashes]]}} + :: |serverCertificateHashes| 1. Let |pullDatagramsAlgorithm| be an action that runs [=pullDatagrams=] with |transport|. -Note: Using 64kB buffers with datagrams is recommended because the effective -maximum WebTransport datagram frame size has an upper bound of the QUIC maximum datagram frame size -which is recommended to be 64kB (See [[!QUIC-DATAGRAM]] [Section 3](https://datatracker.ietf.org/doc/html/rfc9221#section-3)). -This will ensure the stream is not errored due to a datagram being larger than the buffer. + Note: Using 64kB buffers with datagrams is recommended because the effective + maximum WebTransport datagram frame size has an upper bound of the QUIC maximum datagram frame size + which is recommended to be 64kB (See [[!QUIC-DATAGRAM]] [Section 3](https://datatracker.ietf.org/doc/html/rfc9221#section-3)). + This will ensure the stream is not errored due to a datagram being larger than the buffer. 1. If |datagramsReadableMode| is `"bytes"`, [=ReadableStream/set up with byte reading support=] |incomingDatagrams| with [=ReadableStream/set up with byte reading support/pullAlgorithm=] set @@ -953,48 +973,46 @@ This will ensure the stream is not errored due to a datagram being larger than t 1. [=ReadableStream/Set up=] |transport|.{{[[IncomingUnidirectionalStreams]]}} with [=ReadableStream/set up/pullAlgorithm=] set to |pullUnidirectionalStreamAlgorithm|, and [=ReadableStream/set up/highWaterMark=] set to 0. -1. [=Initialize WebTransport over HTTP=] with |transport|, |parsedURL|, |dedicated|, - |requireUnreliable|, |congestionControl|, |protocols|, and |serverCertificateHashes|. +1. Let |client| be |transport|'s [=relevant settings object=]. +1. Let |origin| be |client|'s [=environment settings object/origin=]. +1. Let |request| be a new [=/request=] whose [=request/URL=] is |url|, [=request/client=] is + |client|, [=service-workers mode=] is "`none`", + [=request/referrer=] is "`no-referrer`", [=request/mode=] is "`webtransport`", + [=request/credentials mode=] is "`omit`", [=request/cache mode=] is "`no-store`", + [=request/policy container=] is |client|'s + [=environment settings object/policy container=], [=request/destination=] is "", + [=request/origin=] is |origin| and [=request/redirect mode=] is "error". +1. [=Fetch=] |request|, with [=useParallelQueue=] set to true, and [=processResponse=] + set to the following steps given a |response|: + 1. [=Process a WebTransport fetch response=] with |response|, |origin|, |protocols|, and |congestionControl|. 1. Return |transport|. -
-To initialize WebTransport over HTTP, given a {{WebTransport}} object -transport, a [=URL record=] |url|, a boolean |dedicated|, a boolean -|requireUnreliable|, a {{WebTransportCongestionControl}} |congestionControl|, -a |protocols| array, and a -sequence<{{WebTransportHash}}> |serverCertificateHashes|, run these steps. +Note: The plan is for [=fetch=] to call into the below algorithm based off a +new "`webtransport`" [=request/mode=]. [#1808](https://github.com/whatwg/fetch/issues/1808). -1. Let |client| be |transport|'s [=relevant settings object=]. -1. Let |origin| be |client|'s [=environment settings object/origin=]. -1. Let |request| be a new [=/request=] whose [=request/URL=] is |url|, [=request/client=] is - |client|, [=request/policy container=] is |client|'s - [=environment settings object/policy container=], [=request/destination=] is an empty string, - [=request/origin=] is |origin| and [=request/redirect mode=] is "error". -1. Run report Content Security Policy violations for |request|. -1. If [=should request be blocked by Content Security Policy?=] with |request| returns - "Blocked", or if |request| [=block bad port|should be blocked due to a bad port=] - returns blocked, then abort the remaining steps and [=queue a network task=] with |transport| - to run these steps: - 1. If |transport|.{{[[State]]}} is `"closed"` or `"failed"`, then abort these steps. - 1. Let |error| be a newly [=DOMException/created=] {{WebTransportError}} whose - {{WebTransportErrorOptions/source}} is `"session"`. - 1. [=Cleanup=] |transport| with |error|. -1. Let |networkPartitionKey| be the result of [=determining the network partition key=] with - |transport|'s [=relevant settings object=]. -1. Run the following steps [=in parallel=], but [=abort when=] |transport|.{{[[State]]}} becomes `"closed"` or `"failed"`: - 1. Let |newConnection| be "`no`" if |dedicated| is false; otherwise "`yes-and-dedicated`". - 1. Let |connection| be the result of [=obtain a connection|obtaining a connection=] with - |networkPartitionKey|, |url|, false, |newConnection|, and |requireUnreliable|. If the user agent - supports more than one congestion control algorithm, choose one appropriate for - |congestionControl| for sending of data on this |connection|. When obtaining a connection, if +
+To obtain a WebTransport connection, given a [=network partition key=] +|networkPartitionKey|, and a [=request=] |request|, run these steps: + 1. Let |transport| be the {{WebTransport}} object associated with |request|. + 1. Let |url| be |request|'s [=request/current URL=]. + 1. Let |newConnection| be |transport|.{{[[NewConnection]]}}. + 1. Let |requireUnreliable| be |transport|.{{[[RequireUnreliable]]}}. + 1. Let |serverCertificateHashes| be the values in |transport|.{{[[ServerCertificateHashes]]}}. + 1. Return the result of [=obtain a connection|obtaining a connection=] with + |networkPartitionKey|, |url|, false, |newConnection|, and |requireUnreliable|. + When obtaining a connection, if |serverCertificateHashes| is specified, instead of using the default certificate verification algorithm, consider the certificate valid if it meets the [=custom certificate requirements=] and if [=verify a certificate hash|verifying the certificate hash=] against - |serverCertificateHashes| returns true. If either condition is not met, let |connection| be - failure. - 1. If |connection| is failure, then abort the remaining steps and [=queue a network task=] with + |serverCertificateHashes| returns true. If either condition is not met, fail with a + [=network error=]. +
+ +
+To process a WebTransport fetch response, given a |response|, |origin|, |protocols|, and |congestionControl|, run these steps: + 1. If |response| is [=network error=], then abort the remaining steps and [=queue a network task=] with |transport| to run these steps: 1. If |transport|.{{[[State]]}} is `"closed"` or `"failed"`, then abort these steps. 1. Let |error| be a newly [=DOMException/created=] {{WebTransportError}} whose @@ -1006,6 +1024,7 @@ sequence<{{WebTransportHash}}> |serverCertificateHashes|, run these steps. information that would normally be blocked by CORS. In same-origin contexts, it might encourage applications to abuse the handshake as a vector for passing information. + 1. Let |connection| be the underlying connection associated with |response|. 1. Wait for |connection| to receive the first SETTINGS frame, and let |settings| be a dictionary that represents the SETTINGS frame. 1. If |settings| doesn't contain SETTINGS_ENABLE_WEBTRANPORT with a value of 1, or it doesn't @@ -1026,6 +1045,8 @@ sequence<{{WebTransportHash}}> |serverCertificateHashes|, run these steps. {{WebTransportErrorOptions/source}} is `"session"`. 1. [=Cleanup=] |transport| with |error|. 1. Let |session| be the established [=WebTransport session=]. + 1. If the user agent supports more than one congestion control algorithm, choose one + appropriate for |congestionControl| for sending of data on this |connection|. 1. [=Queue a network task=] with |transport| to run these steps: 1. Assert: [=this=]'s {{[[Datagrams]]}}'s {{[[OutgoingMaxDatagramSize]]}} is an integer. 1. If |transport|.{{[[State]]}} is not `"connecting"`: @@ -1433,7 +1454,7 @@ run these steps: ## Context cleanup steps ## {#web-transport-context-cleanup-steps} -This specification defines context cleanup steps as the following steps, given +This specification defines context cleanup steps as the following steps, given {{WebTransport}} |transport|: 1. If |transport|.{{[[State]]}} is `"connected"`, then: