mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 04:10:24 +00:00
WIP close
This commit is contained in:
parent
70629673c5
commit
b63e18d2cc
2 changed files with 41 additions and 6 deletions
|
@ -460,11 +460,42 @@ close_wt_session_server(Config) ->
|
|||
|
||||
%% @todo close_wt_session_app_code_msg_client
|
||||
|
||||
%% @todo
|
||||
%close_wt_session_app_code_server(Config) ->
|
||||
% error(todo).
|
||||
%close_wt_session_app_code_msg_server(Config) ->
|
||||
% error(todo).
|
||||
close_wt_session_app_code_server(Config) ->
|
||||
doc("The WT server can close a single session with an application error code. "
|
||||
"(draft_webtrans_http3 4.6)"),
|
||||
%% Connect to the WebTransport server.
|
||||
#{
|
||||
conn := Conn,
|
||||
connect_stream_ref := ConnectStreamRef,
|
||||
session_id := SessionID
|
||||
} = do_webtransport_connect(Config),
|
||||
%% Create a bidi stream, send a special instruction to make it initiate the close.
|
||||
{ok, LocalStreamRef} = quicer:start_stream(Conn, #{}),
|
||||
{ok, _} = quicer:send(LocalStreamRef, <<1:2, 16#41:14, 0:2, SessionID:6,
|
||||
"TEST:close_app_code">>),
|
||||
%% Receive the CLOSE_WEBTRANSPORT_SESSION capsule on the CONNECT stream.
|
||||
CloseWTSessionCapsule = cow_capsule:close_wt_session(1234567890, <<>>),
|
||||
{fin, CloseWTSessionCapsule} = do_receive_data(ConnectStreamRef),
|
||||
ok.
|
||||
|
||||
close_wt_session_app_code_msg_server(Config) ->
|
||||
doc("The WT server can close a single session with an application error code "
|
||||
"and an application error message. (draft_webtrans_http3 4.6)"),
|
||||
%% Connect to the WebTransport server.
|
||||
#{
|
||||
conn := Conn,
|
||||
connect_stream_ref := ConnectStreamRef,
|
||||
session_id := SessionID
|
||||
} = do_webtransport_connect(Config),
|
||||
%% Create a bidi stream, send a special instruction to make it initiate the close.
|
||||
{ok, LocalStreamRef} = quicer:start_stream(Conn, #{}),
|
||||
{ok, _} = quicer:send(LocalStreamRef, <<1:2, 16#41:14, 0:2, SessionID:6,
|
||||
"TEST:close_app_code_msg">>),
|
||||
%% Receive the CLOSE_WEBTRANSPORT_SESSION capsule on the CONNECT stream.
|
||||
CloseWTSessionCapsule = iolist_to_binary(cow_capsule:close_wt_session(1234567890,
|
||||
<<"onetwothreefourfivesixseveneightnineten">>)),
|
||||
{fin, CloseWTSessionCapsule} = do_receive_data(ConnectStreamRef),
|
||||
ok.
|
||||
|
||||
%% An endpoint that sends a CLOSE_WEBTRANSPORT_SESSION capsule MUST immediately send a FIN. The endpoint MAY send a STOP_SENDING to indicate it is no longer reading from the CONNECT stream. The recipient MUST either close or reset the stream in response. (6)
|
||||
%% @todo close_wt_session_server_fin
|
||||
|
|
|
@ -52,7 +52,11 @@ webtransport_handle(Event = {stream_data, _StreamID, _IsFin, <<"TEST:", Test/bit
|
|||
<<"initiate_close">> ->
|
||||
{[initiate_close], Streams};
|
||||
<<"close">> ->
|
||||
{[close], Streams}
|
||||
{[close], Streams};
|
||||
<<"close_app_code">> ->
|
||||
{[{close, 1234567890}], Streams};
|
||||
<<"close_app_code_msg">> ->
|
||||
{[{close, 1234567890, <<"onetwothreefourfivesixseveneightnineten">>}], Streams}
|
||||
end;
|
||||
webtransport_handle(Event = {stream_data, StreamID, IsFin, Data}, Streams) ->
|
||||
ct:pal("WT handle ~p~n", [Event]),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue