0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-14 12:20:24 +00:00

Fix signal int sizes

This commit is contained in:
Loïc Hoguin 2025-05-26 14:48:13 +02:00
parent 8c2bdb1e22
commit 2fe2edf4ff
No known key found for this signature in database
GPG key ID: 8A9DF795F6FED764
2 changed files with 8 additions and 22 deletions

View file

@ -556,8 +556,8 @@ early_error(State0=#state{ref=Ref, opts=Opts, peer=Peer},
%% Datagrams. %% Datagrams.
parse_datagram(State, Data) -> parse_datagram(State, Data) ->
case parse_var_int(Data) of case cow_http3:parse_int(Data) of
{ok, QuarterID, Rest} -> {QuarterID, Rest} ->
SessionID = QuarterID * 4, SessionID = QuarterID * 4,
case stream_get(State, SessionID) of case stream_get(State, SessionID) of
#stream{status=webtransport_session} -> #stream{status=webtransport_session} ->
@ -571,18 +571,6 @@ parse_datagram(State, Data) ->
loop(State) loop(State)
end. end.
%% @todo Move to Cowlib and use in cow_http3.
parse_var_int(<<0:2, Int:6, Rest/bits>>) ->
{ok, Int, Rest};
parse_var_int(<<1:2, Int:14, Rest/bits>>) ->
{ok, Int, Rest};
parse_var_int(<<2:2, Int:30, Rest/bits>>) ->
{ok, Int, Rest};
parse_var_int(<<3:2, Int:62, Rest/bits>>) ->
{ok, Int, Rest};
parse_var_int(_) ->
more.
%% Erlang messages. %% Erlang messages.
down(State0=#state{opts=Opts, children=Children0}, Pid, Msg) -> down(State0=#state{opts=Opts, children=Children0}, Pid, Msg) ->

View file

@ -115,7 +115,7 @@ accept_session_when_enabled(Config) ->
} = do_webtransport_connect(Config), } = do_webtransport_connect(Config),
%% Create a bidi stream, send Hello, get Hello back. %% Create a bidi stream, send Hello, get Hello back.
{ok, BidiStreamRef} = quicer:start_stream(Conn, #{}), {ok, BidiStreamRef} = quicer:start_stream(Conn, #{}),
{ok, _} = quicer:send(BidiStreamRef, <<16#41, 0:2, SessionID:6, "Hello">>), {ok, _} = quicer:send(BidiStreamRef, <<1:2, 16#41:14, 0:2, SessionID:6, "Hello">>),
{ok, <<"Hello">>} = rfc9114_SUITE:do_receive_data(BidiStreamRef), {ok, <<"Hello">>} = rfc9114_SUITE:do_receive_data(BidiStreamRef),
ok. ok.
@ -125,8 +125,6 @@ accept_session_when_enabled(Config) ->
%% 3.4. Application Protocol Negotiation %% 3.4. Application Protocol Negotiation
%% The user agent MAY include a WT-Available-Protocols header field in the CONNECT request. The WT-Available-Protocols enumerates the possible protocols in preference order. If the server receives such a header, it MAY include a WT-Protocol field in a successful (2xx) response. If it does, the server SHALL include a single choice from the client's list in that field. Servers MAY reject the request if the client did not include a suitable protocol. (3.4)
application_protocol_negotiation(Config) -> application_protocol_negotiation(Config) ->
doc("Applications can negotiate a protocol to use via WebTransport. " doc("Applications can negotiate a protocol to use via WebTransport. "
"(draft_webtrans_http3 3.4)"), "(draft_webtrans_http3 3.4)"),
@ -162,11 +160,11 @@ unidirectional_streams(Config) ->
{ok, LocalStreamRef} = quicer:start_stream(Conn, {ok, LocalStreamRef} = quicer:start_stream(Conn,
#{open_flag => ?QUIC_STREAM_OPEN_FLAG_UNIDIRECTIONAL}), #{open_flag => ?QUIC_STREAM_OPEN_FLAG_UNIDIRECTIONAL}),
{ok, _} = quicer:send(LocalStreamRef, {ok, _} = quicer:send(LocalStreamRef,
<<16#54, 0:2, SessionID:6, "Hello">>, <<1:2, 16#54:14, 0:2, SessionID:6, "Hello">>,
?QUIC_SEND_FLAG_FIN), ?QUIC_SEND_FLAG_FIN),
%% Accept an identical unidi stream. %% Accept an identical unidi stream.
{unidi, RemoteStreamRef} = do_receive_new_stream(), {unidi, RemoteStreamRef} = do_receive_new_stream(),
{nofin, <<16#54, 0:2, SessionID:6>>} = do_receive_data(RemoteStreamRef), {nofin, <<1:2, 16#54:14, 0:2, SessionID:6>>} = do_receive_data(RemoteStreamRef),
{fin, <<"Hello">>} = do_receive_data(RemoteStreamRef), {fin, <<"Hello">>} = do_receive_data(RemoteStreamRef),
ok. ok.
@ -182,7 +180,7 @@ bidirectional_streams_client(Config) ->
} = do_webtransport_connect(Config), } = do_webtransport_connect(Config),
%% Create a bidi stream, send Hello, get Hello back. %% Create a bidi stream, send Hello, get Hello back.
{ok, LocalStreamRef} = quicer:start_stream(Conn, #{}), {ok, LocalStreamRef} = quicer:start_stream(Conn, #{}),
{ok, _} = quicer:send(LocalStreamRef, <<16#41, 0:2, SessionID:6, "Hello">>), {ok, _} = quicer:send(LocalStreamRef, <<1:2, 16#41:14, 0:2, SessionID:6, "Hello">>),
%% @todo Use the local do_receive_data instead to have the fin flag. %% @todo Use the local do_receive_data instead to have the fin flag.
{ok, <<"Hello">>} = rfc9114_SUITE:do_receive_data(LocalStreamRef), {ok, <<"Hello">>} = rfc9114_SUITE:do_receive_data(LocalStreamRef),
ok. ok.
@ -197,10 +195,10 @@ bidirectional_streams_server(Config) ->
} = do_webtransport_connect(Config), } = do_webtransport_connect(Config),
%% Create a bidi stream, send a special instruction to make it create a bidi stream. %% Create a bidi stream, send a special instruction to make it create a bidi stream.
{ok, LocalStreamRef} = quicer:start_stream(Conn, #{}), {ok, LocalStreamRef} = quicer:start_stream(Conn, #{}),
{ok, _} = quicer:send(LocalStreamRef, <<16#41, 0:2, SessionID:6, "TEST:open_bidi">>), {ok, _} = quicer:send(LocalStreamRef, <<1:2, 16#41:14, 0:2, SessionID:6, "TEST:open_bidi">>),
%% Accept the bidi stream and receive the data. %% Accept the bidi stream and receive the data.
{bidi, RemoteStreamRef} = do_receive_new_stream(), {bidi, RemoteStreamRef} = do_receive_new_stream(),
{nofin, <<16#41, 0:2, SessionID:6>>} = do_receive_data(RemoteStreamRef), {nofin, <<1:2, 16#41:14, 0:2, SessionID:6>>} = do_receive_data(RemoteStreamRef),
{ok, _} = quicer:send(RemoteStreamRef, <<"Hello">>, {ok, _} = quicer:send(RemoteStreamRef, <<"Hello">>,
?QUIC_SEND_FLAG_FIN), ?QUIC_SEND_FLAG_FIN),
{fin, <<"Hello">>} = do_receive_data(RemoteStreamRef), {fin, <<"Hello">>} = do_receive_data(RemoteStreamRef),