mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 12:20:24 +00:00
Confirm handler terminates with AppCode/AppMsg
This commit is contained in:
parent
cd327437ba
commit
8393975459
2 changed files with 33 additions and 1 deletions
|
@ -482,6 +482,32 @@ close_wt_session_server(Config) ->
|
||||||
%% 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)
|
%% 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)
|
||||||
|
|
||||||
%% @todo close_wt_session_app_code_msg_client
|
%% @todo close_wt_session_app_code_msg_client
|
||||||
|
close_wt_session_app_code_msg_client(Config) ->
|
||||||
|
doc("The WT client 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 propagate events.
|
||||||
|
{ok, LocalStreamRef} = quicer:start_stream(Conn, #{}),
|
||||||
|
EventPidBin = term_to_binary(self()),
|
||||||
|
{ok, _} = quicer:send(LocalStreamRef, <<1:2, 16#41:14, 0:2, SessionID:6,
|
||||||
|
"TEST:event_pid:", EventPidBin/binary>>),
|
||||||
|
%% Send the CLOSE_WEBTRANSPORT_SESSION capsule on the CONNECT stream.
|
||||||
|
{ok, _} = quicer:send(ConnectStreamRef,
|
||||||
|
cow_capsule:close_wt_session(17, <<"seventeen">>),
|
||||||
|
?QUIC_SEND_FLAG_FIN),
|
||||||
|
%% @todo Stop reading from the CONNECt stream too. (STOP_SENDING)
|
||||||
|
%% Receive the terminate event from the WT handler.
|
||||||
|
receive
|
||||||
|
{'$wt_echo_h', terminate, {closed, 17, <<"seventeen">>}, _, _} ->
|
||||||
|
ok
|
||||||
|
after 1000 ->
|
||||||
|
error({timeout, waiting_for_terminate_event})
|
||||||
|
end.
|
||||||
|
|
||||||
close_wt_session_app_code_server(Config) ->
|
close_wt_session_app_code_server(Config) ->
|
||||||
doc("The WT server can close a single session with an application error code. "
|
doc("The WT server can close a single session with an application error code. "
|
||||||
|
|
|
@ -57,7 +57,9 @@ webtransport_handle(Event = {stream_data, _StreamID, _IsFin, <<"TEST:", Test/bit
|
||||||
<<"close_app_code">> ->
|
<<"close_app_code">> ->
|
||||||
{[{close, 1234567890}], Streams};
|
{[{close, 1234567890}], Streams};
|
||||||
<<"close_app_code_msg">> ->
|
<<"close_app_code_msg">> ->
|
||||||
{[{close, 1234567890, <<"onetwothreefourfivesixseveneightnineten">>}], Streams}
|
{[{close, 1234567890, <<"onetwothreefourfivesixseveneightnineten">>}], Streams};
|
||||||
|
<<"event_pid:", EventPidBin/bits>> ->
|
||||||
|
{[], Streams#{event_pid => binary_to_term(EventPidBin)}}
|
||||||
end;
|
end;
|
||||||
webtransport_handle(Event = {stream_data, StreamID, IsFin, Data}, Streams) ->
|
webtransport_handle(Event = {stream_data, StreamID, IsFin, Data}, Streams) ->
|
||||||
ct:pal("WT handle ~p~n", [Event]),
|
ct:pal("WT handle ~p~n", [Event]),
|
||||||
|
@ -85,6 +87,10 @@ webtransport_info({try_again, Event}, Streams) ->
|
||||||
ct:pal("try_again ~p", [Event]),
|
ct:pal("try_again ~p", [Event]),
|
||||||
webtransport_handle(Event, Streams).
|
webtransport_handle(Event, Streams).
|
||||||
|
|
||||||
|
terminate(Reason, Req, State=#{event_pid := EventPid}) ->
|
||||||
|
ct:pal("terminate ~p ~p ~p", [Reason, Req, State]),
|
||||||
|
EventPid ! {'$wt_echo_h', terminate, Reason, Req, State},
|
||||||
|
ok;
|
||||||
terminate(Reason, Req, State) ->
|
terminate(Reason, Req, State) ->
|
||||||
ct:pal("terminate ~p ~p ~p", [Reason, Req, State]),
|
ct:pal("terminate ~p ~p ~p", [Reason, Req, State]),
|
||||||
ok.
|
ok.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue