mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 12:20:24 +00:00
Use cow_http2:parse_sequence/1
This commit is contained in:
parent
e1d970b5eb
commit
7d118b547f
1 changed files with 7 additions and 19 deletions
|
@ -215,27 +215,15 @@ loop(State=#state{parent=Parent, socket=Socket, transport=Transport,
|
||||||
|
|
||||||
%% HTTP/2 protocol parsing.
|
%% HTTP/2 protocol parsing.
|
||||||
|
|
||||||
parse(State=#state{socket=Socket, transport=Transport, preface={sequence, TRef}}, Data) ->
|
parse(State=#state{preface={sequence, TRef}}, Data) ->
|
||||||
case Data of
|
case cow_http2:parse_sequence(Data) of
|
||||||
<< "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n", Rest/bits >> ->
|
{ok, Rest} ->
|
||||||
parse(State#state{preface={settings, TRef}}, Rest);
|
parse(State#state{preface={settings, TRef}}, Rest);
|
||||||
_ when byte_size(Data) >= 24 ->
|
more ->
|
||||||
Transport:close(Socket),
|
before_loop(State, Data);
|
||||||
exit({shutdown, {connection_error, protocol_error,
|
Error = {connection_error, _, _} ->
|
||||||
'The connection preface was invalid. (RFC7540 3.5)'}});
|
terminate(State, Error)
|
||||||
_ ->
|
|
||||||
Len = byte_size(Data),
|
|
||||||
<< Preface:Len/binary, _/bits >> = <<"PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n">>,
|
|
||||||
case Data of
|
|
||||||
Preface ->
|
|
||||||
before_loop(State, Data);
|
|
||||||
_ ->
|
|
||||||
Transport:close(Socket),
|
|
||||||
exit({shutdown, {connection_error, protocol_error,
|
|
||||||
'The connection preface was invalid. (RFC7540 3.5)'}})
|
|
||||||
end
|
|
||||||
end;
|
end;
|
||||||
%% @todo Perhaps instead of just more we can have {more, Len} to avoid all the checks.
|
|
||||||
parse(State=#state{http2_machine=HTTP2Machine}, Data) ->
|
parse(State=#state{http2_machine=HTTP2Machine}, Data) ->
|
||||||
MaxFrameSize = cow_http2_machine:get_local_setting(max_frame_size, HTTP2Machine),
|
MaxFrameSize = cow_http2_machine:get_local_setting(max_frame_size, HTTP2Machine),
|
||||||
case cow_http2:parse(Data, MaxFrameSize) of
|
case cow_http2:parse(Data, MaxFrameSize) of
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue