-
Notifications
You must be signed in to change notification settings - Fork 6
/
webtransport.html
2095 lines (2065 loc) · 94.1 KB
/
webtransport.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<link href="includes/style.css" rel="stylesheet">
<title>WebTransport</title>
<script src="includes/respec-w3c-common.js" class="remove" type="text/javascript"></script>
<script src="includes/respec-config-webtransport.js" class="remove" type="text/javascript"></script>
</head>
<body>
<section id="abstract">
<p>This document defines a set of ECMAScript APIs in WebIDL to allow data to be sent
and received between a browser and server, implementing pluggable
protocols underneath with common APIs on top. APIs specific to QUIC are also provided.
This specification is being developed in conjunction with a protocol
specification developed by the IETF QUIC Working Group.</p>
</section>
<section id="sotd">
</section>
<section class="informative" id="intro">
<h2>Introduction</h2>
<p>This specification uses pluggable protocols, with
QUIC [[!QUIC-TRANSPORT]] as one such protocol, to send data
to and receive data from servers. It can be used like WebSockets
but with support for multiple streams, unidirectional streams,
out-of-order delivery, and reliable as well as unreliable transport.</p>
<p class="note">The API presented in this specification
represents a preliminary proposal based on work-in-progress
within the IETF QUIC WG. Since the QUIC transport specification is
a work-in-progress, both the protocol and API are likely to
change significantly going forward.</p>
</section>
<section id="conformance">
<p>This specification defines conformance criteria that apply to a single
product: the <dfn>user agent</dfn> that implements the interfaces that it
contains.</p>
<p>Conformance requirements phrased as algorithms or specific steps may be
implemented in any manner, so long as the end result is equivalent. (In
particular, the algorithms defined in this specification are intended to be
easy to follow, and not intended to be performant.)</p>
<p>Implementations that use ECMAScript to implement the APIs defined in
this specification <em class="rfc2119" title="MUST">MUST</em> implement them
in a manner consistent with the ECMAScript Bindings defined in the Web IDL
specification [[!WEBIDL-1]], as this specification uses that specification
and terminology.</p>
</section>
<section>
<h2>Terminology</h2>
<p>The <code><a href=
"http://dev.w3.org/html5/spec/webappapis.html#eventhandler">EventHandler</a></code>
interface, representing a callback used for event handlers, and the <a href=
"http://dev.w3.org/html5/spec/webappapis.html#errorevent"><code><dfn>ErrorEvent</dfn></code></a>
interface are defined in [[!HTML51]].</p>
<p>The concepts <dfn><a href=
"http://dev.w3.org/html5/spec/webappapis.html#queue-a-task">queue a task</a></dfn>,
<dfn><a href=
"http://dev.w3.org/html5/spec/webappapis.html#fire-a-simple-event">fires a simple
event</a></dfn> and <dfn><a href=
"http://dev.w3.org/html5/spec/webappapis.html#networking-task-source">networking
task source</a></dfn> are defined in [[!HTML51]].</p>
<p>The term <dfn>finished reading</dfn> means that the application has read all
available data up to the STREAM frame with the FIN bit set, which causes
the <a>[[\Readable]]</a> slot to be set to <code>false</code>.</p>
<p>The terms <dfn>event</dfn>, <dfn><a href=
"http://dev.w3.org/html5/spec/webappapis.html#event-handlers">event
handlers</a></dfn> and <dfn><a href=
"http://dev.w3.org/html5/spec/webappapis.html#event-handler-event-type">event
handler event types</a></dfn> are defined in [[!HTML51]].</p>
<p>When referring to exceptions, the terms <dfn><a
href="https://www.w3.org/TR/WebIDL-1/#dfn-throw">throw</a></dfn> and
<dfn data-dfn-for="exception"><a href=
"https://www.w3.org/TR/WebIDL-1/#dfn-create-exception">create</a></dfn> are
defined in [[!WEBIDL-1]].</p>
<p>The terms <dfn data-lt="fulfill|fulfillment">fulfilled</dfn>, <dfn
data-lt="reject|rejection|rejecting|rejected">rejected</dfn>,
<dfn data-lt="resolve|resolves">resolved</dfn>, <dfn>pending</dfn> and
<dfn data-lt="settled">settled</dfn> used in the context of Promises are defined in
[[!ECMASCRIPT-6.0]].</p>
</section>
<section id="unidirectional-streams-transport*">
<h2><dfn>UnidirectionalStreamsTransport</dfn> Mixin</h2>
<p>
A <code>UnidirectionalStreamsTransport</code> can send and receive unidirectional streams.
Data within a stream is delivered in order, but data between streams may be delivered out of order.
Data is generally sent reliably, but retransmissions may be disabled
or the stream may aborted to produce a form of unreliability.
All stream data is encrypted and congestion-controlled.
</p>
<pre class="idl">
interface mixin UnidirectionalStreamsTransport {
Promise<SendStream> createSendStream (optional SendStreamParameters parameters);
attribute EventHandler onreceivestream;
};</pre>
<section>
<h2>Attributes</h2>
<dl data-link-for="UnidirectionalStreamsTransport" data-dfn-for="UnidirectionalStreamsTransport" class=
"attributes">
<dt><dfn><code>onreceivestream</code></dfn> of type <span class=
"idlAttrType"><a>EventHandler</a></span></dt>
<dd>
<p>This event handler, of event handler event type
<code><a>receivestream</a></code>,
<em class="rfc2119" title="MUST">MUST</em> be fired on when data is received
from a newly created remote <code><a>ReceiveStream</a></code> for the
first time.
</p>
</dd>
</dl>
</section>
<section>
<h2>Methods</h2>
<dl data-link-for="UnidirectionalStreamsTransport" data-dfn-for="UnidirectionalStreamsTransport" class=
"methods">
<dt><dfn><code>createSendStream</code></dfn></dt>
<dd>
<p>Creates an <code><a>SendStream</a></code> object.</p>
<p>When <code>createSendStream</code> is called, the user agent
<em class="rfc2119" title="MUST">MUST</em> run the following
steps:</p>
<ol>
<li>
<p>Let <var>transport</var> be the <code><a>UnidirectionalStreamsTransport</a></code>
on which <code>createSendStream</code> is invoked.</p>
</li>
<li>
<p>If <code><var>transport</var>'s state</code> is <code>"closed"</code> or
<code>"failed"</code>, immediately return a new <a>rejected</a> promise with a
newly created <code>InvalidStateError</code> and abort these steps.</p>
</li>
<li>
<!-- TODO If/when we support 0-RTT, allow resoling the
stream before we are connected. -->
<p>If <code><var>transport</var>'s state</code> is <code>"connected"</code>,
immediately return a new <a>resolved</a> promise with a newly created
<code><a>SendStream</a></code> object,
<a>add the SendStream</a> to the <var>transport</var>
and abort these steps.</p>
</li>
<li>
<p>Let <var>p</var> be a new promise.</p>
</li>
<li>
<p>Return <var>p</var> and continue the following steps in
the background.</p>
</li>
<li>
<p>
<a>Resolve</a> <var>p</var> with a newly created
<code><a>SendStream</a></code> object and
<a>add the SendStream</a> to the <var>transport</var>
when all of the following conditions are met:</p>
<ol>
<li>
<p>The <code><var>transport</var>'s state</code> has transitioned to
<code>"connected"</code></p>
</li>
<li>
<p>Stream creation flow control is not being violated by exceeding
the max stream limit set by the remote endpoint, as specified in
[[QUIC-TRANSPORT]].</p>
</li>
<li>
<p><var>p</var> has not been <a>settled</a></p>
</li>
</ol>
</p>
</li>
<li>
<p>
<a>Reject</a> <var>p</var> with a newly created
<code>InvalidStateError</code> when all of the following conditions are met:
<ol>
<li>
<p>The <code><var>transport</var>'s state</code> transitions to
<code>"closed"</code> or <code>"failed"</code></p>
</li>
<li>
<p><var>p</var> has not been <a>settled</a></p>
</li>
</ol>
</p>
</li>
</ol>
<div>
<em>No parameters.</em>
</div>
<div>
<em>Return type:</em> <code><a>Promise<SendStream></a></code>
</div>
</dd>
</dl>
</section>
<section id="UnidirectionalStreamsTransport-procedures*">
<h3>Procedures</h3>
<section>
<h4 id="add-send-stream-to-transport">Add SendStream to the UnidirectionalStreamsTransport</h4>
<p>To <dfn>add the SendStream</dfn> to the <code><a>UnidirectionalStreamsTransport</a></code>
run the following steps:</p>
<ol>
<li>
<p>Let <var>stream</var> be the newly created
<code><a>SendStream</a></code> object.</p>
</li>
<li>
<p>Add <var>stream</var> to <var>transport</var>'s <a>[[\OutgoingStreams]]</a>
internal slot. </p>
</li>
<li>
<p>Continue the following steps in the background.</p>
</li>
<li>
<p>Create <var>stream</var>'s associated underlying
transport.</p>
</li>
</ol>
</section>
</section>
<section id="streamparameters*">
<h3><dfn>SendStreamParameters</dfn> Dictionary</h3>
<p>The <code>QuicStreamParameters</code> dictionary includes information
relating to stream configuration.</p>
<div>
<pre class="idl">dictionary SendStreamParameters {
bool disableRetransmissions = false;
};</pre>
<section>
<h2>Dictionary <a class="idlType">SendStreamParameters</a> Members</h2>
<dl data-link-for="SendStreamParameters" data-dfn-for="SendStreamParameters" class=
"dictionary-members">
<dt><dfn><code>disableRetransmissions</code></dfn> of type <span class=
"idlMemberType"><a>bool</a></span>, defaulting to
<code>false</code></dt>
<dd>
<p>disableRetransmissions, with a default of <code>false</code>. If
true, the stream will be sent without retransmissions. If false, the
stream will be sent with retransmissions.
If the WebTransport is unable to send without retransmissions, it may ignore this value.
<!-- TODO: Provide some API surface to indidcate
that the transport doesn't support disabling retransmissions -->
</p>
</dd>
</dl>
</section>
</div>
</section>
<section>
<h3><dfn>ReceiveStreamEvent</dfn></h3>
<p>The <code><a>receivestream</a></code> event uses the
<code><a>ReceiveStreamEvent</a></code> interface.</p>
<div>
<pre class="idl">
[ Constructor (DOMString type, ReceiveStreamEventInit eventInitDict), Exposed=Window]
interface ReceiveStreamEvent : Event {
readonly attribute ReceiveStream stream;
};</pre>
<section>
<h2>Constructors</h2>
<dl data-link-for="ReceiveStreamEvent" data-dfn-for="ReceiveStreamEvent"
class="constructors">
<dt><code>ReceiveStreamEvent</code></dt>
<dd>
<table class="parameters">
<tbody>
<tr>
<th>Parameter</th>
<th>Type</th>
<th>Nullable</th>
<th>Optional</th>
<th>Description</th>
</tr>
<tr>
<td class="prmName">type</td>
<td class="prmType"><code>DOMString</code></td>
<td class="prmNullFalse"><span role="img" aria-label=
"False">✘</span></td>
<td class="prmOptFalse"><span role="img" aria-label=
"False">✘</span></td>
<td class="prmDesc"></td>
</tr>
<tr>
<td class="prmName">eventInitDict</td>
<td class="prmType"><code><a>ReceiveStreamEventInit</a></code></td>
<td class="prmNullFalse"><span role="img" aria-label=
"False">✘</span></td>
<td class="prmOptFalse"><span role="img" aria-label=
"False">✘</span></td>
<td class="prmDesc"></td>
</tr>
</tbody>
</table>
</dd>
</dl>
</section>
<section>
<h2>Attributes</h2>
<dl data-link-for="ReceiveStreamEvent" data-dfn-for="ReceiveStreamEvent"
class="attributes">
<dt><code>stream</code> of type <span class=
"idlAttrType"><a>ReceiveStream</a></span>, readonly</dt>
<dd>
<p>The <dfn id="dom-receivequicstreamevent-stream"><code>stream</code></dfn>
attribute represents the <code><a>ReceiveStream</a></code> object
associated with the event.</p>
</dd>
</dl>
</section>
</div>
<div>
<p>The <dfn><code>ReceiveStreamEventInit</code></dfn> dictionary includes
information on the configuration of the stream.</p>
<pre class="idl">
dictionary ReceiveStreamEventInit : EventInit {
ReceiveStream stream;
};</pre>
<section>
<h2>Dictionary ReceiveStreamEventInit Members</h2>
<dl data-link-for="ReceiveStreamEventInit" data-dfn-for=
"ReceiveStreamEventInit" class="dictionary-members">
<dt><dfn><code>stream</code></dfn> of type <span class=
"idlMemberType"><a>ReceiveStream</a></span></dt>
<dd>
<p>The <code><a>ReceiveStream</a></code> object associated with the
event.</p>
</dd>
</dl>
</section>
</div>
</section>
</section>
<section id="bidirectional-streams-transport*">
<h2><dfn>BidirectionalStreamsTransport</dfn> Mixin</h2>
<p>
A <code>BidirectionalStreamsTransport</code> can send and receive bidirectional streams.
Data within a stream is delivered in order, but data between streams may be delivered out of order.
Data is generally sent reliably, but retransmissions may be disabled
or the stream may aborted to produce a form of unreliability.
All stream data is encrypted and congestion-controlled.
</p>
<pre class="idl">
interface BidirectionalStreamsTransport {
Promise<BidirectionalStream> createBidirectionalStream ();
attribute EventHandler onbidirectionalstream;
};</pre>
<section>
<h2>Attributes</h2>
<dl data-link-for="BidirectionalStreamsTransport" data-dfn-for="BidirectionalStreamsTransport" class=
"attributes">
<dt><dfn><code>onbidirectionalstream</code></dfn> of type <span class=
"idlAttrType"><a>EventHandler</a></span></dt>
<dd>
<p>This event handler, of event handler event type
<code><a>bidirectionalstream</a></code>,
<em class="rfc2119" title="MUST">MUST</em> be fired when data is received
from a newly created remote <code><a>BidirectionalStream</a></code> for the
first time.
</p>
</dd>
</dl>
</section>
<section>
<h2>Methods</h2>
<dl data-link-for="BidirectionalStreamsTransport" data-dfn-for="BidirectionalStreamsTransport" class=
"methods">
<dt><dfn><code>createBidirectionalStream</code></dfn></dt>
<dd>
<p>Creates an <code><a>BidirectionalStream</a></code> object.</p>
<p>When <code>createBidectionalStream</code> is called, the user agent
<em class="rfc2119" title="MUST">MUST</em> run the following
steps:</p>
<ol>
<li>
<p>Let <var>transport</var> be the <code><a>BidirectionalStreamsTransport</a></code>
on which <code>createBidectionalStream</code> is invoked.</p>
</li>
<li>
<p>If <code><var>transport</var>'s state</code> is <code>"closed"</code> or
<code>"failed"</code>, immediately return a new <a>rejected</a> promise with a
newly created <code>InvalidStateError</code> and abort these steps.</p>
</li>
<li>
<p>If <code><var>transport</var>'s state</code> is <code>"connected"</code>,
immediately return a new <a>resolved</a> promise with a newly created
<code><a>BidirectionalStream</a></code> object,
<a>add the BidirectionalStream</a> to the <var>transport</var>
and abort these steps.</p>
</li>
<li>
<p>Let <var>p</var> be a new promise.</p>
</li>
<li>
<p>Return <var>p</var> and continue the following steps in
the background.</p>
</li>
<li>
<p>
<a>Resolve</a> <var>p</var> with a newly created
<code><a>BidirectionalStream</a></code> object and
<a>add the BidirectionalStream</a> to the <var>transport</var>
when all of the following conditions are met:</p>
<ol>
<li>
<p>The <code><var>transport</var>'s state</code> has transitioned to
<code>"connected"</code></p>
</li>
<li>
<p>Stream creation flow control is not being violated by exceeding
the max stream limit set by the remote endpoint, as specified in
[[QUIC-TRANSPORT]].</p>
</li>
<li>
<p><var>p</var> has not been <a>settled</a></p>
</li>
</ol>
</p>
</li>
<li>
<p>
<a>Reject</a> <var>p</var> with a newly created
<code>InvalidStateError</code> when all of the following conditions are met:
<ol>
<li>
<p>The <code><var>transport</var>'s state</code> transitions to
<code>"closed"</code> or <code>"failed"</code></p>
</li>
<li>
<p><var>p</var> has not been <a>settled</a></p>
</li>
</ol>
</p>
</li>
</ol>
<div>
<em>No parameters.</em>
</div>
<div>
<em>Return type:</em> <code><a>Promise<BidirectionalStream></a></code>
</div>
</dd>
</dl>
</section>
<section id="BidirectionalStreamsTransport-procedures*">
<h3>Procedures</h3>
<section>
<h4 id="add-bidirectional-stream-to-transport">Add BidirectionalStream
to the BidirectionalStreamsTransport</h4>
<p>To <dfn>add the BidirectionalStream</dfn> to the <code><a>BidirectionalStreamsTransport</a></code>
run the following steps:</p>
<ol>
<li>
<p>Let <var>stream</var> be the newly created
<code><a>BidirectionalStream</a></code> object.</p>
</li>
<li>
<p>Add <var>stream</var> to <var>transport</var>'s <a>[[\IncomingStreams]]</a>
internal slot. </p>
</li>
<li>
<p>Add <var>stream</var> to <var>transport</var>'s <a>[[\OutgoingStreams]]</a>
internal slot. </p>
</li>
<li>
<p>Continue the following steps in the background.</p>
</li>
<li>
<p>Create <var>stream</var>'s associated underlying
transport.</p>
</li>
</ol>
</section>
</section>
<section>
<h3><dfn>BidirectionalStreamEvent</dfn></h3>
<p>The <code><a>bidirectionalstream</a></code> event uses the
<code><a>BidirectionalStreamEvent</a></code> interface.</p>
<div>
<pre class="idl">
[ Constructor (DOMString type, BidirectionalStreamEventInit eventInitDict), Exposed=Window]
interface BidirectionalStreamEvent : Event {
readonly attribute BidirectionalStream stream;
};</pre>
<section>
<h2>Constructors</h2>
<dl data-link-for="BidirectionalStreamEvent" data-dfn-for="BidirectionalStreamEvent"
class="constructors">
<dt><code>BidirectionalStreamEvent</code></dt>
<dd>
<table class="parameters">
<tbody>
<tr>
<th>Parameter</th>
<th>Type</th>
<th>Nullable</th>
<th>Optional</th>
<th>Description</th>
</tr>
<tr>
<td class="prmName">type</td>
<td class="prmType"><code>DOMString</code></td>
<td class="prmNullFalse"><span role="img" aria-label=
"False">✘</span></td>
<td class="prmOptFalse"><span role="img" aria-label=
"False">✘</span></td>
<td class="prmDesc"></td>
</tr>
<tr>
<td class="prmName">eventInitDict</td>
<td class="prmType"><code><a>BidirectionalStreamEventInit</a></code></td>
<td class="prmNullFalse"><span role="img" aria-label=
"False">✘</span></td>
<td class="prmOptFalse"><span role="img" aria-label=
"False">✘</span></td>
<td class="prmDesc"></td>
</tr>
</tbody>
</table>
</dd>
</dl>
</section>
<section>
<h2>Attributes</h2>
<dl data-link-for="BidirectionalStreamEvent" data-dfn-for="BidirectionalStreamEvent"
class="attributes">
<dt><code>stream</code> of type <span class=
"idlAttrType"><a>BidirectionalStream</a></span>, readonly</dt>
<dd>
<p>The <dfn id="dom-bidirectionalquicstreamevent-stream"><code>stream</code></dfn>
attribute represents the <code><a>BidirectionalStream</a></code> object
associated with the event.</p>
</dd>
</dl>
</section>
</div>
<div>
<p>The <dfn><code>BidirectionalStreamEventInit</code></dfn> dictionary includes
information on the configuration of the stream.</p>
<pre class="idl">
dictionary BidirectionalStreamEventInit : EventInit {
BidirectionalStream stream;
};</pre>
<section>
<h2>Dictionary BidirectionalStreamEventInit Members</h2>
<dl data-link-for="BidirectionalStreamEventInit" data-dfn-for=
"BidirectionalStreamEventInit" class="dictionary-members">
<dt><dfn><code>stream</code></dfn> of type <span class=
"idlMemberType"><a>BidirectionalStream</a></span></dt>
<dd>
<p>The <code><a>BidirectionalStream</a></code> object associated with the
event.</p>
</dd>
</dl>
</section>
</div>
</section>
</section>
<section id="datagram-transport*">
<h2><dfn>DatagramTransport</dfn> Mixin</h2>
<p>
A <code>DatagramTransport</code> can send and receive datagrams.
Datagrams are sent out of order, unreliably, and have a limited maximum size.
Datagrams are encrypted and congestion controlled.
</p>
<pre class="idl">
interface mixin DatagramTransport {
readonly attribute unsigned short maxDatagramSize;
Promise<void> readyToSendDatagram ();
Promise<boolean> sendDatagram (Uint8Array data);
Promise<sequence<Uint8Array>> receiveDatagrams ();
};</pre>
<section>
<h2>Attributes</h2>
<dl data-link-for="DatagramTransport" data-dfn-for="DatagramTransport" class=
"attributes">
<dt><dfn><code>maxDatagramSize</code></dfn> of type <span class=
"idlAttrType"><a>unsigned short</a></span>, readonly</dt>
<dd>
<p>The maximum size data that may be passed to sendDatagram.</p>
</dd>
</dl>
</section>
<section>
<h2>Methods</h2>
<dl data-link-for="DatagramTransport" data-dfn-for="DatagramTransport" class=
"methods">
<dt><dfn><code>readyToSendDatagram</code></dfn></dt>
<dd>
<p>Returns a promise that will be <a>resolved</a> when the DatagramTransport can send
a datagram.</p>
<p>When <code>readyToSendDatagram</code> is called, the user agent
<em class="rfc2119" title="MUST">MUST</em> run the following
steps:</p>
<ol>
<li>
<p>Let <var>p</var> be a new promise.</p>
</li>
<li>
<p>Let <var>transport</var> be the
<code><a>DatagramTransport</a></code> on which
<code>readyToSendDatagram</code> is invoked.</p>
</li>
<li>
<p>Return <var>p</var> and continue the following steps in
the background.</p>
</li>
<ol>
<li>
<p>If <var>transport</var> can send a datagram, imediately <a>resolve</a>
<var>p</var> and abort these steps.</p>
</li>
<li>
<p>If <var>transport</var>'s state is <code>"failed"</code>
or <code>"closed"</code> immediately <a>reject</a> <var>p</var> with a newly
created <code>InvalidStateError</code> and abort these steps.</p>
</li>
<li>
<p>If <code>transport</code> is blocked from sending a datagram due to
congestion control, <a>resolve</a> <var>p</var> when <var>transport</var>
is no longer blocked.</p>
</li>
<li>
<p><a>reject</a> <var>p</var> with a newly created
<code>InvalidStateError</code> if the <var>transport</var>'s
state transitions to <code>"failed"</code> or <code>"closed"</code>.</p>
</li>
</ol>
</ol>
<div>
<em>No parameters.</em>
</div>
<div>
<em>Return type:</em> <code>Promise<void></code>
</div>
</dd>
<dt><dfn><code>sendDatagram</code></dfn></dt>
<dd>
<p>Sends a datagram.</p>
<p>When <code>sendDatagram</code> is called, the user agent
<em class="rfc2119" title="MUST">MUST</em> run the following
steps:</p>
<ol>
<li>Let <var>data</var> be the first argument.</li>
<li>
<p>Let <var>transport</var> be
the <code><a>DatagramTransport</a></code> on
which <code>sendDatagram</code> is invoked.</p>
</li>
<li>
<p>If <var>transport</var>'s state is not <code>connected</code> return
a promise <a>rejected</a> with a newly created
<code>InvalidStateError</code> and abort these steps.</p>
</li>
<li>
<p>If <code><var>data</var></code> is too large to fit into a
datagram, return a promise <a>rejected</a> with a newly created
<code>InvalidArgumentError</code> and abort these steps.</p>
</li>
<li>
<p>If <var>transport</var> is unable to send the datagram due
to congestion control, return a promise <a>rejected</a> with
a newly created <code>InvalidStateError</code> and abort
these steps.</p>
</li>
<li>
<p>Let <var>p</var> be a new promise.</p>
</li>
<li>
<p>Return <var>p</var> and continue the following steps in
the background.</p>
</li>
<ol>
<li>
<p>Send <var>data</var> in a datagram.</p>
</li>
<li>
<p>When an ack is received for the sent datagram,
<a>resolve</a> <var>p</var> with <code>true</code>.</p>
</li>
<li>
<p>When the datagram is detemined to be lost, <a>resolve</a>
<var>p</var> with <code>false</code>.</p>
</li>
</ol>
</ol>
<table class="parameters">
<tbody>
<tr>
<th>Parameter</th>
<th>Type</th>
<th>Nullable</th>
<th>Optional</th>
<th>Description</th>
</tr>
<tr>
<td class="prmName">data</td>
<td class="prmType"><code>Uint8Array</code></td>
<td class="prmNullFalse"><span role="img" aria-label=
"False">✘</span></td>
<td class="prmOptFalse"><span role="img" aria-label=
"False">✘</span></td>
<td class="prmDesc"></td>
</tr>
</tbody>
</table>
<div>
<em>Return type:</em> <code>Promise<boolean></code>
</div>
</dd>
<dt><dfn><code>receiveDatagrams</code></dfn></dt>
<dd>
<p>If datagrams have been received since the last call to receiveDatagrams(),
return a new promise resolved with all of the received datagrams. </p>
<p>If not, return a new promise that will resolve when more datagrams are received,
resolved with all datagrams received. </p>
<p>If too many datagrams are queued between calls to receiveDatagrams(),
the implementation may drop datagrams and replace them with a null value
in the sequence of datagrams returned in the next call to receiveDatagrams().
One null value may represent many dropped datagrams.<p>
<p>receiveDatagrams() may only be called once at a time.
If a promised returned from a previous call is still unresolved,
the user agent MUST return a new promise rejected with an InvalidStateError. </p>
<div>
<em>Return type:</em> <code>Promise<sequence<Uint8Array>></code>
</div>
</dd>
</dl>
</section>
</section>
<section id="web-transport*">
<h2><dfn>WebTransport</dfn> Mixin</h2>
<p>
The <code>WebTransport</code> includes the methods common to all transports,
such as state, state changes, and the ability to close the transport.
</p>
<pre class="idl">
interface mixin WebTransport {
readonly attribute WebTransportState state;
void close (WebTransportCloseInfo closeInfo);
attribute EventHandler onstatechange;
attribute EventHandler onerror;
};</pre>
<section>
<h2>Attributes</h2>
<dl data-link-for="WebTransport" data-dfn-for="WebTransport" class=
"attributes">
<dt><dfn><code>state</code></dfn> of type <span class=
"idlAttrType"><a>WebTransportState</a></span>, readonly</dt>
<dd>
<p>The current state of the transport. On getting, it
<em class="rfc2119" title="MUST">MUST</em> return the value
of the <a>[[\WebTransportState]]</a> internal slot.</p>
</dd>
<dt><dfn><code>onstatechange</code></dfn> of type <span class=
"idlAttrType"><a>EventHandler</a></span></dt>
<dd>
<p>This event handler, of event handler event type
<code><a>statechange</a></code>, <em class="rfc2119" title="MUST">MUST</em>
be fired any time the <a>[[\WebTransportState]]</a> slot changes, unless
the state changes due to calling <a><code>close</code></a>.</p>
</dd>
<dt><dfn><code>onerror</code></dfn> of type <span class=
"idlAttrType"><a>EventHandler</a></span></dt>
<dd>
<p>This event handler, of event handler event type <code>error</code>,
<em class="rfc2119" title="MUST">MUST</em> be fired on reception of an
error; an implementation <em class="rfc2119" title=
"SHOULD">SHOULD</em> include error information in
<var>error.message</var> (defined in [[!HTML51]] Section 7.1.3.8.2). This
event <em class="rfc2119" title="MUST">MUST</em> be fired before the
<a><code>onstatechange</code></a> event.</p>
</dd>
</dl>
</section>
<section>
<h2>Methods</h2>
<dl data-link-for="WebTransport" data-dfn-for="WebTransport" class=
"methods">
<!-- TODO: Should this be moved out of WebTransport?
It might different for each type of transport. -->
<dt><dfn><code>close</code></dfn></dt>
<dd>
<p>Closes the <code><a>WebTransport</a></code> object.
<!-- TODO: move reference to QUIC under QuicTransportBase. -->
For QUIC, this triggers an <dfn>Immediate Close</dfn> as described in [[QUIC-TRANSPORT]] section 10.3.
<p>When <code>close</code> is called, the user agent <em class="rfc2119" title="MUST">MUST</em>
run the following steps:</p>
<ol>
<li>Let <var>transport</var> be the <code><a>WebTransport</a></code>
on which <code>close</code> is invoked.</li>
<li>If <var>transport</var>'s <a>[[\WebTransportState]]</a> is <code>"closed"</code>
then abort these steps.</li>
<li>Set <var>transport</var>'s <a>[[\WebTransportState]]</a> to
<code>"closed"</code>.</li>
<li>Let <code>closeInfo</code> be the first argument.</li>
<!-- TODO: move reference to QUIC under QuicTransportBase. -->
<li>For QUIC, start the <a>Immediate Close</a> procedure by sending an CONNECTION_CLOSE frame
with its error code value set to the value of <var>closeInfo</var>.errorCode
and its reason value set to the value of <var>closeInfo</var>.reason.</li>
</ol>
<div>
<em>No parameters.</em>
</div>
<div>
<em>Return type:</em> <code>void</code>
</div>
<table class="parameters">
<tbody>
<tr>
<th>Parameter</th>
<th>Type</th>
<th>Nullable</th>
<th>Optional</th>
<th>Description</th>
</tr>
<tr>
<td class="prmName">closeInfo</td>
<td class="prmType"><code>WebTransportCloseInfo</code></td>
<td class="prmNullFalse"><span role="img" aria-label=
"False">✘</span></td>
<td class="prmOptFalse"><span role="img" aria-label=
"False">✘</span></td>
<td class="prmDesc"></td>
</tr>
</tbody>
</table>
</dd>
</dl>
</section>
<section id="WebTransportState*">
<h3><dfn>WebTransportState</dfn> Enum</h3>
<p><code>WebTransportState</code> indicates the state of the
transport.</p>
<div>
<pre class="idl">
enum WebTransportState {
"new",
"connecting",
"connected",
"closed",
"failed"
};</pre>
<table data-link-for="WebTransportState" data-dfn-for="WebTransportState"
class="simple">
<tbody>
<tr>
<th colspan="2">Enumeration description</th>
</tr>
<tr>
<td><dfn><code id="idl-def-WebTransportState.new">new</code></dfn></td>
<td>
<p>The <code><a>WebTransport</a></code> object has been created and
has not started negotiating yet.</p>
</td>
</tr>
<tr>
<td><dfn><code id=
"idl-def-WebTransportState.connecting">connecting</code></dfn></td>
<td>
<p>The transport is in the process of negotiating a secure connection.
Once a secure connection is negotiated, incoming data can flow through.</p>
</td>
</tr>
<tr>
<td><dfn><code id=
"idl-def-WebTransportState.connected">connected</code></dfn></td>
<td>
<p>The transport has completed negotiation of a secure connection.
Outgoing data and media can now flow through.</p>
</td>
</tr>
<tr>
<td><dfn><code id=
"idl-def-WebTransportState.closed">closed</code></dfn></td>
<td>
<p>The transport has been closed intentionally via a call to
<code>close()</code> or receipt of a closing message from the remote side.
When the <code><a>WebTransport</a></code>'s
internal <a>[[\WebTransportState]]</a> slot transitions to
<code>closed</code> the user agent <em class="rfc2119" title="MUST">MUST</em>
run the following steps:</p>
<ol>
<li>Let <var>transport</var> be the <code><a>WebTransport</a></code>.
<li>For each <code><a>IncomingStream</a></code> in <var>transport</var>'s
<a>[[\IncomingStreams]]</a> internal slot run the
following:</li>
<ol>
<li>Let <var>stream</var> be the <code><a>IncomingStream</a></code>.</li>
<li>Set <var>stream</var>'s <a>[[\Readable]]</a> slot to
<code>false</code>.</li>
<li>Clear the <var>stream</var>'s read buffer.</li>
<li>Remove the <var>stream</var> from the <var>transport</var>'s
<a>[[\IncomingStreams]]</a> internal slot.
</ol>
<li>For each <code><a>OutgoingStream</a></code> in <var>transport</var>'s
<a>[[\OutgoingStreams]]</a> internal slot run the
following:</li>
<ol>
<li>Let <var>stream</var> be the <code><a>OutgoingStream</a></code>.</li>
<li>Set <var>stream</var>'s <a>[[\Writable]]</a> slot to
<code>false</code>.</li>
<li>Clear the <var>stream</var>'s write buffer.</li>
<li>Remove the <var>stream</var> from the <var>transport</var>'s
<a>[[\OutgoingStreams]]</a> internal slot.
</ol>
</ol>
</td>
</tr>
<tr>
<td><dfn><code id=
"idl-def-WebTransportState.failed">failed</code></dfn></td>
<td>
<p>The transport has been closed as the result of an error (such as
receipt of an error alert). When the <code><a>WebTransport</a></code>'s
internal <a>[[\WebTransportState]]</a> slot transitions to
<code>failed</code> the user agent <em class="rfc2119" title="MUST">MUST</em>
run the following steps:</p>
<ol>
<li>Let <var>transport</var> be the <code><a>WebTransport</a></code>.
<li>For each <code><a>IncomingStream</a></code> in <var>transport</var>'s
<a>[[\IncomingStreams]]</a> internal slot run the
following:</li>
<ol>
<li>Let <var>stream</var> be the <code><a>IncomingStream</a></code>.</li>
<li>Set <var>stream</var>'s <a>[[\Readable]]</a> slot to
<code>false</code>.</li>
<li>Clear the <var>stream</var>'s read buffer.</li>
<li>Remove the <var>stream</var> from the <var>transport</var>'s
<a>[[\IncomingStreams]]</a> internal slot.
</ol>
<li>For each <code><a>OutgoingStream</a></code> in <var>transport</var>'s
<a>[[\OutgoingStreams]]</a> internal slot run the
following:</li>
<ol>
<li>Set <var>stream</var>'s <a>[[\Writable]]</a> slot to
<code>false</code>.</li>
<li>Clear the <var>stream</var>'s write buffer.</li>
<li>Remove the <var>stream</var> from the <var>transport</var>'s
<a>[[\OutgoingStreams]]</a> internal slot.
</ol>
</ol>
</td>
</tr>
</tbody>
</table>
</div>
</section>
<section id="webtransportcloseinfo*">
<h3><dfn>WebTransportCloseInfo</dfn> Dictionary</h3>
<p>The <code>WebTransportCloseInfo</code> dictionary includes information
relating to the error code for closing a <code><a>WebTransport</a></code>.
For QUIC, this information is used to set the error code and reason for an CONNECTION_CLOSE
frame.</p>
<div>
<pre class="idl">
dictionary WebTransportCloseInfo {
unsigned short errorCode = 0;
DOMString reason = "";
};</pre>
<section>
<h2>Dictionary <a class="idlType">WebTransportCloseInfo</a> Members</h2>
<dl data-link-for="WebTransportCloseInfo" data-dfn-for="WebTransportCloseInfo" class=
"dictionary-members">
<dt><dfn><code>errorCode</code></dfn> of type <span class=
"idlMemberType"><a>unsigned short</a></span>, defaulting to
<code>0</code>.</dt>
<dd>
<p>The error code.</p>
</dd>
<dt><dfn><code>reason</code></dfn> of type <span class=
"idlMemberType"><a>DOMString</a></span>, defaulting to <code>""</code></dt>
<dd>
<p>The reason for closing the <code><a>WebTransport</a></code></p>
</dd>
</dl>
</section>
</div>
</section>
</section>
<section id="quic-transport-base*">
<h2><dfn>QuicTransportBase</dfn> Interface</h2>
<p>The <code>QuicTransportBase</code> is the base interface
for <code>QuicTransport</code>. Most of the functionality of a
QuicTransport is in the base class to allow for other
subclasses (such as a p2p variant) to share the same interface.
</p>
<section id="quictransportbase-overview*">
<h3>Overview</h3>
<p>A <code><a>QuicTransportBase</a></code> is a
<code>UnidirectionalStreamsTransport</code>, a
<code>BidirectionalStreamsTransport</code>, and a