mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 20:30:23 +00:00
Unknown HTTP/2 frames are ignored
This commit is contained in:
parent
a3636adcac
commit
bb83a6ce33
2 changed files with 27 additions and 0 deletions
|
@ -231,6 +231,8 @@ parse(State=#state{local_settings=#{max_frame_size := MaxFrameSize},
|
||||||
{continuation, _, _, _} ->
|
{continuation, _, _, _} ->
|
||||||
parse(continuation_frame(State, Frame), Rest)
|
parse(continuation_frame(State, Frame), Rest)
|
||||||
end;
|
end;
|
||||||
|
{ignore, Rest} ->
|
||||||
|
parse(State, Rest);
|
||||||
{stream_error, StreamID, Reason, Human, Rest} ->
|
{stream_error, StreamID, Reason, Human, Rest} ->
|
||||||
parse(stream_reset(State, StreamID, {stream_error, Reason, Human}), Rest);
|
parse(stream_reset(State, StreamID, {stream_error, Reason, Human}), Rest);
|
||||||
Error = {connection_error, _, _} ->
|
Error = {connection_error, _, _} ->
|
||||||
|
|
|
@ -809,6 +809,31 @@ prior_knowledge(Config) ->
|
||||||
%% * Prior knowledge handshake fails (3.4)
|
%% * Prior knowledge handshake fails (3.4)
|
||||||
%% * ALPN selects HTTP/1.1 (3.3)
|
%% * ALPN selects HTTP/1.1 (3.3)
|
||||||
|
|
||||||
|
%% Frame format.
|
||||||
|
|
||||||
|
ignore_unknown_frames(Config) ->
|
||||||
|
doc("Frames of unknown type must be ignored and discarded. (RFC7540 4.1)"),
|
||||||
|
{ok, Socket} = do_handshake(Config),
|
||||||
|
%% Send a POST request with a single DATA frame,
|
||||||
|
%% and an unknown frame type interleaved.
|
||||||
|
{HeadersBlock, _} = cow_hpack:encode([
|
||||||
|
{<<":method">>, <<"POST">>},
|
||||||
|
{<<":scheme">>, <<"http">>},
|
||||||
|
{<<":authority">>, <<"localhost">>}, %% @todo Correct port number.
|
||||||
|
{<<":path">>, <<"/echo/read_body">>}
|
||||||
|
]),
|
||||||
|
ok = gen_tcp:send(Socket, [
|
||||||
|
cow_http2:headers(1, nofin, HeadersBlock),
|
||||||
|
<< 10:24, 99:8, 0:40, 0:80 >>,
|
||||||
|
cow_http2:data(1, fin, << 0:100/unit:8 >>)
|
||||||
|
]),
|
||||||
|
%% Receive a response with the same DATA frame.
|
||||||
|
{ok, << SkipLen:24, 1:8, _:8, 1:32 >>} = gen_tcp:recv(Socket, 9, 1000),
|
||||||
|
{ok, _} = gen_tcp:recv(Socket, SkipLen, 1000),
|
||||||
|
{ok, << 100:24, 0:8, 1:8, 1:32 >>} = gen_tcp:recv(Socket, 9, 1000),
|
||||||
|
{ok, << 0:100/unit:8 >>} = gen_tcp:recv(Socket, 100, 1000),
|
||||||
|
ok.
|
||||||
|
|
||||||
%% Frame size.
|
%% Frame size.
|
||||||
|
|
||||||
max_frame_size_allow_exactly_default(Config) ->
|
max_frame_size_allow_exactly_default(Config) ->
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue