-
Notifications
You must be signed in to change notification settings - Fork 6
/
cs.html
1815 lines (1814 loc) · 86.9 KB
/
cs.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>QUIC API for Client-to-Server Connections</title>
<script class="remove" src="includes/respec-w3c-common.js" type="text/javascript"></script>
<script src="includes/respec-config-webtransport.js" class="remove"></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 the QUIC
protocol. 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 QUIC [[!QUIC-TRANSPORT]] to send data
to and receive data from servers. It can be used like WebSockets
but with support for multiple streams, unidirectional streams,
out-or-order deliver, and unreliable delivery.</p>
<p class="note">The QUIC 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="quic-transportbase*">
<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>An <code><a>QuicTransportBase</a></code> instance can be associated to
one or more <code><a>QuicBidirectionalStream</a></code>,
<code><a>QuicSendStream</a></code>, or <code><a>QuicReceiveStream</a></code>
instances.</p>
</section>
<section id="quictransportbase-interface-definition*">
<h3>Interface Definition</h3>
<div>
<pre class="idl">
interface QuicTransportBase {
readonly attribute QuicTransportState state;
readonly attribute unsigned short maxDatagramSize;
void stop (QuicTransportStopInfo stopInfo);
Promise<QuicBidirectionalStream> createBidirectionalStream ();
Promise<QuicSendStream> createSendStream (optional QuicStreamParameters parameters);
Promise<void> readyToSendDatagram ();
Promise<boolean> sendDatagram (Uint8Array data);
Promise<sequence<Uint8Array>> receiveDatagrams ();
attribute EventHandler onstatechange;
attribute EventHandler onerror;
attribute EventHandler onreceivestream;
attribute EventHandler onbidirectionalstream;
};</pre>
<section>
<h2>Attributes</h2>
<dl data-link-for="QuicTransportBase" data-dfn-for="QuicTransportBase" class=
"attributes">
<dt><dfn><code>state</code></dfn> of type <span class=
"idlAttrType"><a>QuicTransportState</a></span>, readonly</dt>
<dd>
<p>The current state of the QUIC transport. On getting, it
<em class="rfc2119" title="MUST">MUST</em> return the value
of the <a>[[\QuicTransportState]]</a> internal slot.</p>
</dd>
<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>
<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>[[\QuicTransportState]]</a> slot changes, unless
the state changes due to calling <a><code>stop</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 a QUIC
error; an implementation <em class="rfc2119" title=
"SHOULD">SHOULD</em> include QUIC 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>
<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>QuicReceiveStream</a></code> for the
first time.
</p>
</dd>
<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>QuicBidirectionalStream</a></code> for the
first time.
</p>
</dd>
</dl>
</section>
<section>
<h2>Methods</h2>
<dl data-link-for="QuicTransportBase" data-dfn-for="QuicTransportBase" class=
"methods">
<dt><dfn><code>stop</code></dfn></dt>
<dd>
<p>Stops and closes the <code><a>QuicTransportBase</a></code> object.
This triggers an <dfn>Immediate Close</dfn> as described in [[QUIC-TRANSPORT]] section 10.3.
<p>When <code>stop</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>QuicTransportBase</a></code>
on which <code>stop</code> is invoked.</li>
<li>If <var>transport</var>'s <a>[[\QuicTransportState]]</a> is <code>"closed"</code>
then abort these steps.</li>
<li>Set <var>transport</var>'s <a>[[\QuicTransportState]]</a> to
<code>"closed"</code>.</li>
<li>Let <code>stopInfo</code> be the first argument.</li>
<li>Start the <a>Immediate Close</a> procedure by sending an CONNECTION_CLOSE frame
with its error code value set to the value of <var>stopInfo</var>.errorCode
and its reason value set to the value of <var>stopInfo</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">stopInfo</td>
<td class="prmType"><code>QuicTransportStopInfo</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>
<dt><dfn><code>createBidirectionalStream</code></dfn></dt>
<dd>
<p>Creates an <code><a>QuicBidirectionalStream</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>QuicTransportBase</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>QuicBidirectionalStream</a></code> object,
<a>add the QuicBidirectionalStream</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>
<ol>
<li>
<p><a>Resolve</a> <var>p</var> with a newly created
<code><a>QuicBidirectionalStream</a></code> object,
<a>add the QuicBidirectionalStream</a> to the <var>transport</var>
when all of the following conditions are met:</p>
<ol>
<li>The <code><var>transport</var>'s state</code> has transitioned to
<code>"connected"</code></li>
<li> Stream creation flow control is not being violated by exceeding
the max stream limit set by the remote endpoint, as specified in
[[QUIC-TRANSPORT]].</li>
<li><var>p</var> has not been <a>settled</a></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>The <code><var>transport</var>'s state</code> transitions to
<code>"closed"</code> or <code>"failed"</code></li>
<li><var>p</var> has not been <a>settled</a></li>
</ol>
</li>
</ol>
</ol>
<div>
<em>No parameters.</em>
</div>
<div>
<em>Return type:</em> <code><a>Promise<QuicBidirectionalStream></a></code>
</div>
</dd>
<dt><dfn><code>createSendStream</code></dfn></dt>
<dd>
<p>Creates an <code><a>QuicSendStream</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>QuicTransportBase</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>
<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>QuicSendStream</a></code> object,
<a>add the QuicSendStream</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>
<ol>
<li>
<p><a>Resolve</a> <var>p</var> with a newly created
<code><a>QuicSendStream</a></code> object,
<a>add the QuicSendStream</a> to the <var>transport</var>
when all of the following conditions are met:</p>
<ol>
<li>The <code><var>transport</var>'s state</code> has transitioned to
<code>"connected"</code></li>
<li> Stream creation flow control is not being violated by exceeding
the max stream limit set by the remote endpoint, as specified in
[[QUIC-TRANSPORT]].</li>
<li><var>p</var> has not been <a>settled</a></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>The <code><var>transport</var>'s state</code> transitions to
<code>"closed"</code> or <code>"failed"</code></li>
<li><var>p</var> has not been <a>settled</a></li>
</ol>
</li>
</ol>
</ol>
<div>
<em>No parameters.</em>
</div>
<div>
<em>Return type:</em> <code><a>Promise<QuicSendStream></a></code>
</div>
</dd>
<dt><dfn><code>readyToSendDatagram</code></dfn></dt>
<dd>
<p>Returns a promise that will be <a>resolved</a> when the QuicTransport can send
a datagram as defined by [[QUIC-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>QuicTransportBase</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 as defined by [[QUIC-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>QuicTransportBase</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 QUIC 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>
</div>
</section>
<section id="quictransportbase-procedures*">
<h3>Procedures</h3>
<section>
<h4 id="add-bidirectional-stream-to-transport">Add QuicBidirectionalStream
to the QuicTransport</h4>
<p>To <dfn>add the QuicBidirectionalStream</dfn> to the <code><a>QuicTransportBase</a></code>
run the following steps:</p>
<ol>
<li>
<p>Let <var>stream</var> be the newly created
<code><a>QuicBidirectionalStream</a></code> object.</p>
</li>
<li>
<p>Add <var>stream</var> to <var>transport</var>'s <a>[[\QuicTransportReadableStreams]]</a>
internal slot. </p>
</li>
<li>
<p>Add <var>stream</var> to <var>transport</var>'s <a>[[\QuicTransportWritableStreams]]</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 data
transport.</p>
</li>
</ol>
</section>
<section>
<h4 id="add-send-stream-to-transport">Add QuicSendStream to the QuicTransportBase</h4>
<p>To <dfn>add the QuicSendStream</dfn> to the <code><a>QuicTransportBase</a></code>
run the following steps:</p>
<ol>
<li>
<p>Let <var>stream</var> be the newly created
<code><a>QuicSendStream</a></code> object.</p>
</li>
<li>
<p>Add <var>stream</var> to <var>transport</var>'s <a>[[\QuicTransportWritableStreams]]</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 data
transport.</p>
</li>
</ol>
</section>
</section>
<section id="streamparameters*">
<h3><dfn>QuicStreamParameters</dfn> Dictionary</h3>
<p>The <code>QuicStreamParameters</code> dictionary includes information
relating to QUIC stream configuration.</p>
<div>
<pre class="idl">dictionary QuicStreamParameters {
bool disableRetransmissions = false;
};</pre>
<section>
<h2>Dictionary <a class="idlType">QuicStreamParameters</a> Members</h2>
<dl data-link-for="QuicStreamParameters" data-dfn-for="QuicStreamParameters" 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.</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 QuicReceiveStream 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>QuicReceiveStream</a></span>, readonly</dt>
<dd>
<p>The <dfn id="dom-receivequicstreamevent-stream"><code>stream</code></dfn>
attribute represents the <code><a>QuicReceiveStream</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 QUIC stream.</p>
<pre class="idl">dictionary ReceiveStreamEventInit : EventInit {
QuicReceiveStream 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>QuicReceiveStream</a></span></dt>
<dd>
<p>The <code><a>QuicReceiveStream</a></code> object associated with the
event.</p>
</dd>
</dl>
</section>
</div>
</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 QuicBidirectionalStream 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>QuicBidirectionalStream</a></span>, readonly</dt>
<dd>
<p>The <dfn id="dom-bidirectionalquicstreamevent-stream"><code>stream</code></dfn>
attribute represents the <code><a>QuicBidirectionalStream</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 QUIC stream.</p>
<pre class="idl">dictionary BidirectionalStreamEventInit : EventInit {
QuicBidirectionalStream 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>QuicBidirectionalStream</a></span></dt>
<dd>
<p>The <code><a>QuicBidirectionalStream</a></code> object associated with the
event.</p>
</dd>
</dl>
</section>
</div>
</section>
<section id="quictransportstate*">
<h3><dfn>QuicTransportState</dfn> Enum</h3>
<p><code>QuicTransportState</code> indicates the state of the QUIC
transport.</p>
<div>
<pre class="idl">enum QuicTransportState {
"new",
"connecting",
"connected",
"closed",
"failed"
};</pre>
<table data-link-for="QuicTransportState" data-dfn-for="QuicTransportState"
class="simple">
<tbody>
<tr>
<th colspan="2">Enumeration description</th>
</tr>
<tr>
<td><dfn><code id="idl-def-QuicTransportState.new">new</code></dfn></td>
<td>
<p>The <code><a>QuicTransportBase</a></code> object has been created and
has not started negotiating yet.</p>
</td>
</tr>
<tr>
<td><dfn><code id=
"idl-def-QuicTransportState.connecting">connecting</code></dfn></td>
<td>
<p>QUIC is in the process of negotiating a secure connection.
Once a secure connection is negotiated
(but prior to verification of the remote fingerprint, enabled by calling
<code>start()</code>), incoming data can flow through.</p>
</td>
</tr>
<tr>
<td><dfn><code id=
"idl-def-QuicTransportState.connected">connected</code></dfn></td>
<td>
<p>QUIC 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-QuicTransportState.closed">closed</code></dfn></td>
<td>
<p>The QUIC connection has been closed intentionally via a call to
<code>stop()</code> or receipt of a closing frame as described in
[[QUIC-TRANSPORT]]. When the <code><a>QuicTransportBase</a></code>'s
internal <a>[[\QuicTransportState]]</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>QuicTransportBase</a></code>.
<li>For each <code><a>QuicReadableStream</a></code> in <var>transport</var>'s
<a>[[\QuicTransportReadableStreams]]</a> internal slot run the
following:</li>
<ol>
<li>Let <var>stream</var> be the <code><a>QuicReadableStream</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>[[\QuicTransportReadableStreams]]</a> internal slot.
</ol>
<li>For each <code><a>QuicWritableStream</a></code> in <var>transport</var>'s
<a>[[\QuicTransportWritableStreams]]</a> internal slot run the
following:</li>
<ol>
<li>Let <var>stream</var> be the <code><a>QuicWritableStream</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>[[\QuicTransportWritableStreams]]</a> internal slot.
</ol>
</ol>
</td>
</tr>
<tr>
<td><dfn><code id=
"idl-def-QuicTransportState.failed">failed</code></dfn></td>
<td>
<p>The QUIC connection has been closed as the result of an error (such as
receipt of an error alert or a failure to validate the remote
fingerprint). When the <code><a>QuicTransportBase</a></code>'s
internal <a>[[\QuicTransportState]]</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>QuicTransportBase</a></code>.
<li>For each <code><a>QuicReadableStream</a></code> in <var>transport</var>'s
<a>[[\QuicTransportReadableStreams]]</a> internal slot run the
following:</li>
<ol>
<li>Let <var>stream</var> be the <code><a>QuicReadableStream</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>[[\QuicTransportReadableStreams]]</a> internal slot.
</ol>
<li>For each <code><a>QuicWritableStream</a></code> in <var>transport</var>'s
<a>[[\QuicTransportWritableStreams]]</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>[[\QuicTransportWritableStreams]]</a> internal slot.
</ol>
</ol>
</td>
</tr>
</tbody>
</table>
</div>
</section>
<section id="quictransportstopinfo*">
<h3><dfn>QuicTransportStopInfo</dfn> Dictionary</h3>
<p>The <code>QuicTransportStopInfo</code> dictionary includes information
relating to the error code for stopping a <code><a>QuicTransportBase</a></code>.
This information is used to set the error code and reason for an CONNECTION_CLOSE
frame.</p>
<div>
<pre class="idl">dictionary QuicTransportStopInfo {
unsigned short errorCode = 0;
DOMString reason = "";
};
</pre>
<section>
<h2>Dictionary <a class="idlType">QuicTransportStopInfo</a> Members</h2>
<dl data-link-for="QuicTransportStopInfo" data-dfn-for="QuicTransportStopInfo" 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 used in CONNECTION_CLOSE frame.</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 stopping the <code><a>QuicTransportBase</a></code></p>
</dd>
</dl>
</section>
</div>
</section>
</section>
<section id="quic-transport*">
<h2><dfn>QuicTransport</dfn> Interface</h2>
<p>The <code>QuicTransportBase</code> is a subclass of
<code>QuicTransportBase</code> focused on client/server use cases.</p>
<section id="quictransport-interface-definition*">
<h3>Interface Definition</h3>
<div>
<pre class="idl">
[ Constructor (DOMString host, unsigned short port), Exposed=Window]
interface QuicTransport : QuicTransportBase {
};</pre>
<section>
<h2>Constructors</h2>
When the <code><a>QuicTransport</a></code> constructor is invoked,
the user agent <em class="rfc2119" title="MUST">MUST</em> run the
following steps:
<ol>
<li>
If <var>port</var> is 0,
<a>throw</a> an <code>NotSupportedError</code> and abort these steps.
</li>
<li>
Let <var>quictransport</var> be a newly constructed
<code><a>QuicTransport</a></code> object.
</li>
<li>Let <var>quictransport</var> have a <dfn>[[\QuicTransportWritableStreams]]</dfn>
internal slot representing a sequence of <code><a>QuicWritableStream</a></code>
objects, initialized to empty.
</li>
<li>Let <var>quictransport</var> have a <dfn>[[\QuicTransportReadableStreams]]</dfn>
internal slot representing a sequence of <code><a>QuicReadableStream</a></code>
objects, initialized to empty.
</li>
<li>
Let <var>quictransport</var> have a <dfn>[[\QuicTransportState]]</dfn>
internal slot, initialized to <code>"connecting"</code>.
</li>
<li>Let <var>quictransport</var> have a <dfn>[[\QuicTransportReceivedDatagrams]]</dfn>
internal slot representing a queue of <code>Uint8Array</code>, initialized to empty.
</li>
<li>Let <var>quictransport</var> have a <dfn>[[\QuicTransportReceiveDatagramsPromise]]</dfn>
internal slot representing a <code>Promise<sequence<Uint8Array>>?</code>,
initialized to null.
</li>
<li>Run these steps in parallel:
<ol>
<li>Establish a QUIC connection to the address identified by the
given host and port.
During connection establishment, use of this API must be indicated
by selecting the ALPN [[!ALPN]] token "wq" in the crypto handshake
and including a QUIC transport parameter with ID web_client(0x333C)
and empty value.
<!-- TODO: register "wq" with IANA. -->
</li>
<li>If the connection fails, set <var>quictransport</var>'s <a>[[\QuicTransportState]]</a>
internal slot to <code>"failed"</code> and abort these steps.
</li>
<li>Let <var>joinedAcceptedOrigins</var> be the QUIC transport parameter provided
by the server with ID web_accepted_origins(0x333A). If the transport parameter is
absent, set <var>quictransport</var>'s <a>[[\QuicTransportState]]</a>
internal slot to <code>"failed"</code> and abort these steps.
<!-- TODO: register 0x333A with IANA -->
</li>
<li>
Let <var>serializedAcceptedOrigins</var> be
<var>joinedAcceptedOrigins</var> split by the separator
<code>","</code>.
</li>
<li>
Let <var>serializedOrigin</var> be <var>quictransport</var>'s
<a href="https://html.spec.whatwg.org/multipage/webappapis.html#relevant-settings-object">relevant settings object</a>'s
<a href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-settings-object-origin">origin</a>,
<a href="https://html.spec.whatwg.org/multipage/origin.html#ascii-serialisation-of-an-origin">serialized</a>.
</li>
<li>If <var>serializedOrigin</var> is a member of <var>serializedAcceptedOrigins</var>
or <var>joinedAcceptedOrigins</var> is equal to <code>"*"</code>,
set <var>quictransport</var>'s <a>[[\QuicTransportState]]</a>
internal slot to <code>"connected"</code> and abort these steps.
</li>
<li>
Set <var>quictransport</var>'s <a>[[\QuicTransportState]]</a>
internal slot to <code>"failed"</code>.
</li>
</ol>
</li>
<li>
Return <var>quictransport</var>.
</li>
</ol>
<dl data-link-for="QuicTransport" data-dfn-for="QuicTransport" class=
"constructors">
<dt><code><a>QuicTransport</a></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">host</td>
<td class="prmType"><code><a>DOMString</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">The host to connect to.</td>
</tr>
<tr>
<td class="prmName">port</td>
<td class="prmType"><code><a>unsigned short</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">The port to connect to.</td>
</tr>