Skip to content

Commit a8c7177

Browse files
committed
Update to most recent WebTransport draft
WEBTRANSPORT -> WT in most places. Only ENABLE_WEBTRANSPORT remains (since it is a draft-02 setting that was later removed) as well as internal functions and atoms about stream headers, for greater clarity. The draft also clarified that WT_SESSION_GONE can be sent on the session stream and since it's what is already done a related todo was removed.
1 parent 5ec0eeb commit a8c7177

File tree

3 files changed

+25
-26
lines changed

3 files changed

+25
-26
lines changed

src/cowboy_http3.erl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -973,7 +973,6 @@ wt_commands(State0=#state{conn=Conn}, Session=#stream{id=SessionID}, [Cmd|Tail])
973973
Capsule = cow_capsule:wt_close_session(AppCode, AppMsg),
974974
case cowboy_quicer:send(Conn, SessionID, Capsule, fin) of
975975
ok ->
976-
%% @todo The endpoint MAY send a STOP_SENDING to indicate it is no longer reading from the CONNECT stream.
977976
State = webtransport_terminate_session(State0, Session),
978977
%% @todo Because the handler is in a separate process
979978
%% we must wait for it to stop and eventually
@@ -994,7 +993,7 @@ webtransport_terminate_session(State=#state{conn=Conn, http3_machine=HTTP3Machin
994993
(StreamID, #stream{status={webtransport_stream, StreamSessionID}})
995994
when StreamSessionID =:= SessionID ->
996995
cowboy_quicer:shutdown_stream(Conn, StreamID,
997-
both, cow_http3:error_to_code(webtransport_session_gone)),
996+
both, cow_http3:error_to_code(wt_session_gone)),
998997
false;
999998
(_, _) ->
1000999
true

src/cowboy_webtransport.erl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
%% HTTP/3:
2121
%% - SETTINGS_H3_DATAGRAM = 1
2222
%% - SETTINGS_ENABLE_CONNECT_PROTOCOL = 1
23-
%% - SETTINGS_WEBTRANSPORT_MAX_SESSIONS >= 1
23+
%% - SETTINGS_WT_MAX_SESSIONS >= 1
2424

2525
%% Cowboy supports versions 07 through 13 of the WebTransport drafts.
2626
%% Cowboy also has some compatibility with version 02.
@@ -239,10 +239,10 @@ commands([Command={send, _, _}|Tail], State, Res, Acc) ->
239239
%% {send, StreamID, IsFin, Data}.
240240
commands([Command={send, _, _, _}|Tail], State, Res, Acc) ->
241241
commands(Tail, State, Res, [Command|Acc]);
242-
%% initiate_close - DRAIN_WEBTRANSPORT_SESSION
242+
%% initiate_close - DRAIN_WT_SESSION
243243
commands([Command=initiate_close|Tail], State, Res, Acc) ->
244244
commands(Tail, State, Res, [Command|Acc]);
245-
%% close | {close, Code} | {close, Code, Msg} - CLOSE_WEBTRANSPORT_SESSION
245+
%% close | {close, Code} | {close, Code, Msg} - CLOSE_WT_SESSION
246246
%% @todo At this point the handler must not issue stream or send commands.
247247
commands([Command=close|Tail], State, _, Acc) ->
248248
commands(Tail, State, stop, [Command|Acc]);

test/draft_h3_webtransport_SUITE.erl

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ init_per_group(Name = enabled, Config) ->
3636
enable_connect_protocol => true,
3737
h3_datagram => true,
3838
enable_webtransport => true, %% For compatibility with draft-02.
39-
webtransport_max_sessions => 10,
39+
wt_max_sessions => 10,
4040
env => #{dispatch => cowboy_router:compile(init_routes(Config))}
4141
}, Config).
4242

@@ -68,7 +68,7 @@ init_routes(_) -> [
6868

6969
%% 3.1. Establishing a WebTransport-Capable HTTP/3 Connection
7070

71-
%% In order to indicate support for WebTransport, the server MUST send a SETTINGS_WEBTRANSPORT_MAX_SESSIONS value greater than "0" in its SETTINGS frame. (3.1)
71+
%% In order to indicate support for WebTransport, the server MUST send a SETTINGS_WT_MAX_SESSIONS value greater than "0" in its SETTINGS frame. (3.1)
7272
%% @todo reject_session_disabled
7373
%% @todo accept_session_below
7474
%% @todo accept_session_equal
@@ -93,7 +93,7 @@ init_routes(_) -> [
9393

9494
%% 3.2. Extended CONNECT in HTTP/3
9595

96-
%% [RFC8441] defines an extended CONNECT method in Section 4, enabled by the SETTINGS_ENABLE_CONNECT_PROTOCOL setting. That setting is defined for HTTP/3 by [RFC9220]. A server supporting WebTransport over HTTP/3 MUST send both the SETTINGS_WEBTRANSPORT_MAX_SESSIONS setting with a value greater than "0" and the SETTINGS_ENABLE_CONNECT_PROTOCOL setting with a value of "1". (3.2)
96+
%% [RFC8441] defines an extended CONNECT method in Section 4, enabled by the SETTINGS_ENABLE_CONNECT_PROTOCOL setting. That setting is defined for HTTP/3 by [RFC9220]. A server supporting WebTransport over HTTP/3 MUST send both the SETTINGS_WT_MAX_SESSIONS setting with a value greater than "0" and the SETTINGS_ENABLE_CONNECT_PROTOCOL setting with a value of "1". (3.2)
9797
%% @todo settings_enable_connect_protocol_enabled
9898
%% @todo reject_settings_enable_connect_protocol_disabled
9999

@@ -208,7 +208,7 @@ bidirectional_streams_server(Config) ->
208208
{fin, <<"Hello">>} = do_receive_data(RemoteStreamRef),
209209
ok.
210210

211-
%% Endpoints MUST NOT send WEBTRANSPORT_STREAM as a frame type on HTTP/3 streams other than the very first bytes of a request stream. Receiving this frame type in any other circumstances MUST be treated as a connection error of type H3_FRAME_ERROR. (4.2)
211+
%% Endpoints MUST NOT send WT_STREAM as a frame type on HTTP/3 streams other than the very first bytes of a request stream. Receiving this frame type in any other circumstances MUST be treated as a connection error of type H3_FRAME_ERROR. (4.2)
212212

213213
%% 4.3. Resetting Data Streams
214214

@@ -242,7 +242,7 @@ datagrams(Config) ->
242242

243243
%% To handle this case (out of order stream_open/CONNECT), WebTransport endpoints SHOULD buffer streams and datagrams until those can be associated with an established session. (4.5)
244244

245-
%% To avoid resource exhaustion, the endpoints MUST limit the number of buffered streams and datagrams. When the number of buffered streams is exceeded, a stream SHALL be closed by sending a RESET_STREAM and/or STOP_SENDING with the WEBTRANSPORT_BUFFERED_STREAM_REJECTED error code. When the number of buffered datagrams is exceeded, a datagram SHALL be dropped. It is up to an implementation to choose what stream or datagram to discard. (4.5)
245+
%% To avoid resource exhaustion, the endpoints MUST limit the number of buffered streams and datagrams. When the number of buffered streams is exceeded, a stream SHALL be closed by sending a RESET_STREAM and/or STOP_SENDING with the WT_BUFFERED_STREAM_REJECTED error code. When the number of buffered datagrams is exceeded, a datagram SHALL be dropped. It is up to an implementation to choose what stream or datagram to discard. (4.5)
246246

247247
%% 4.6. Interaction with HTTP/3 GOAWAY frame
248248

@@ -356,7 +356,7 @@ wt_drain_session_continue_server(Config) ->
356356

357357
%% 5.1. Limiting the Number of Simultaneous Sessions
358358

359-
%% This document defines a SETTINGS_WEBTRANSPORT_MAX_SESSIONS parameter that allows the server to limit the maximum number of concurrent WebTransport sessions on a single HTTP/3 connection. The client MUST NOT open more simultaneous sessions than indicated in the server SETTINGS parameter. The server MUST NOT close the connection if the client opens sessions exceeding this limit, as the client and the server do not have a consistent view of how many sessions are open due to the asynchronous nature of the protocol; instead, it MUST reset all of the CONNECT streams it is not willing to process with the H3_REQUEST_REJECTED status defined in [HTTP3]. (5.1)
359+
%% This document defines a SETTINGS_WT_MAX_SESSIONS parameter that allows the server to limit the maximum number of concurrent WebTransport sessions on a single HTTP/3 connection. The client MUST NOT open more simultaneous sessions than indicated in the server SETTINGS parameter. The server MUST NOT close the connection if the client opens sessions exceeding this limit, as the client and the server do not have a consistent view of how many sessions are open due to the asynchronous nature of the protocol; instead, it MUST reset all of the CONNECT streams it is not willing to process with the H3_REQUEST_REJECTED status defined in [HTTP3]. (5.1)
360360

361361
%% 5.2. Limiting the Number of Streams Within a Session
362362

@@ -386,9 +386,9 @@ wt_drain_session_continue_server(Config) ->
386386

387387
%% 5.5. Flow Control SETTINGS
388388

389-
%% WT_MAX_STREAMS via SETTINGS_WEBTRANSPORT_INITIAL_MAX_STREAMS_UNI and SETTINGS_WEBTRANSPORT_INITIAL_MAX_STREAMS_BIDI (5.5)
389+
%% WT_MAX_STREAMS via SETTINGS_WT_INITIAL_MAX_STREAMS_UNI and SETTINGS_WT_INITIAL_MAX_STREAMS_BIDI (5.5)
390390

391-
%% WT_MAX_DATA via SETTINGS_WEBTRANSPORT_INITIAL_MAX_DATA (5.5)
391+
%% WT_MAX_DATA via SETTINGS_WT_INITIAL_MAX_DATA (5.5)
392392

393393
%% 5.6. Flow Control Capsules
394394

@@ -404,7 +404,7 @@ wt_drain_session_continue_server(Config) ->
404404

405405
%% Note that this limit includes streams that have been closed as well as those that are open. (5.6.1)
406406

407-
%% Initial values for these limits MAY be communicated by sending non-zero values for SETTINGS_WEBTRANSPORT_INITIAL_MAX_STREAMS_UNI and SETTINGS_WEBTRANSPORT_INITIAL_MAX_STREAMS_BIDI. (5.6.1)
407+
%% Initial values for these limits MAY be communicated by sending non-zero values for SETTINGS_WT_INITIAL_MAX_STREAMS_UNI and SETTINGS_WT_INITIAL_MAX_STREAMS_BIDI. (5.6.1)
408408

409409
%% 5.7. WT_STREAMS_BLOCKED Capsule
410410

@@ -418,7 +418,7 @@ wt_drain_session_continue_server(Config) ->
418418

419419
%% All data sent in WT_STREAM capsules counts toward this limit. The sum of the lengths of Stream Data fields in WT_STREAM capsules MUST NOT exceed the value advertised by a receiver. (5.8)
420420

421-
%% The initial value for this limit MAY be communicated by sending a non-zero value for SETTINGS_WEBTRANSPORT_INITIAL_MAX_DATA. (5.8)
421+
%% The initial value for this limit MAY be communicated by sending a non-zero value for SETTINGS_WT_INITIAL_MAX_DATA. (5.8)
422422

423423
%% 5.9. WT_DATA_BLOCKED Capsule
424424

@@ -504,16 +504,16 @@ wt_session_gone_client(Config) ->
504504
cow_capsule:wt_close_session(0, <<>>),
505505
?QUIC_SEND_FLAG_FIN),
506506
%% All streams from that WT session have been aborted.
507-
#{reason := webtransport_session_gone} = do_wait_stream_aborted(LocalUnidiStreamRef),
508-
#{reason := webtransport_session_gone} = do_wait_stream_aborted(RemoteUnidiStreamRef),
509-
#{reason := webtransport_session_gone} = do_wait_stream_aborted(LocalBidiStreamRef),
510-
#{reason := webtransport_session_gone} = do_wait_stream_aborted(RemoteBidiStreamRef),
507+
#{reason := wt_session_gone} = do_wait_stream_aborted(LocalUnidiStreamRef),
508+
#{reason := wt_session_gone} = do_wait_stream_aborted(RemoteUnidiStreamRef),
509+
#{reason := wt_session_gone} = do_wait_stream_aborted(LocalBidiStreamRef),
510+
#{reason := wt_session_gone} = do_wait_stream_aborted(RemoteBidiStreamRef),
511511
ok.
512512

513513
wt_session_gone_server(Config) ->
514514
doc("After the session has been terminated by the WT server, "
515515
"the WT server must reset associated streams with the "
516-
"WEBTRANSPORT_SESSION_GONE error code. (draft_webtrans_http3 4.6)"),
516+
"WT_SESSION_GONE error code. (draft_webtrans_http3 4.6)"),
517517
%% Connect to the WebTransport server.
518518
#{
519519
conn := Conn,
@@ -545,10 +545,10 @@ wt_session_gone_server(Config) ->
545545
CloseWTSessionCapsule = cow_capsule:wt_close_session(0, <<>>),
546546
{fin, CloseWTSessionCapsule} = do_receive_data(ConnectStreamRef),
547547
%% All streams from that WT session have been aborted.
548-
#{reason := webtransport_session_gone} = do_wait_stream_aborted(LocalUnidiStreamRef),
549-
#{reason := webtransport_session_gone} = do_wait_stream_aborted(RemoteUnidiStreamRef),
550-
#{reason := webtransport_session_gone} = do_wait_stream_aborted(LocalBidiStreamRef),
551-
#{reason := webtransport_session_gone} = do_wait_stream_aborted(RemoteBidiStreamRef),
548+
#{reason := wt_session_gone} = do_wait_stream_aborted(LocalUnidiStreamRef),
549+
#{reason := wt_session_gone} = do_wait_stream_aborted(RemoteUnidiStreamRef),
550+
#{reason := wt_session_gone} = do_wait_stream_aborted(LocalBidiStreamRef),
551+
#{reason := wt_session_gone} = do_wait_stream_aborted(RemoteBidiStreamRef),
552552
ok.
553553

554554
%% Application Error Message: A UTF-8 encoded error message string provided by the application closing the session. The message takes up the remainder of the capsule, and its length MUST NOT exceed 1024 bytes. (6)
@@ -722,8 +722,8 @@ do_webtransport_connect(Config, ExtraHeaders) ->
722722
}),
723723
%% Confirm that SETTINGS_ENABLE_CONNECT_PROTOCOL = 1.
724724
#{enable_connect_protocol := true} = Settings,
725-
%% Confirm that SETTINGS_WEBTRANSPORT_MAX_SESSIONS >= 1.
726-
#{webtransport_max_sessions := WTMaxSessions} = Settings,
725+
%% Confirm that SETTINGS_WT_MAX_SESSIONS >= 1.
726+
#{wt_max_sessions := WTMaxSessions} = Settings,
727727
true = WTMaxSessions >= 1,
728728
%% Confirm that SETTINGS_H3_DATAGRAM = 1.
729729
#{h3_datagram := true} = Settings,

0 commit comments

Comments
 (0)