0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-15 12:40:25 +00:00

Don't send a GOAWAY frame on close when the h2 preface is invalid

This commit is contained in:
Loïc Hoguin 2017-11-29 17:49:42 +01:00
parent bd6c32d3b7
commit 0246d9a4e6
No known key found for this signature in database
GPG key ID: 8A9DF795F6FED764

View file

@ -274,7 +274,6 @@ parse(State=#state{socket=Socket, transport=Transport, parse_state={preface, seq
<< Preface:Len/binary, _/bits >> = <<"PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n">>,
case Data of
Preface ->
%% @todo OK we should have a timeout when waiting for the preface.
before_loop(State, Data);
_ ->
Transport:close(Socket),
@ -795,6 +794,9 @@ headers_encode(Headers0, EncodeState) ->
-spec terminate(#state{}, _) -> no_return().
terminate(undefined, Reason) ->
exit({shutdown, Reason});
terminate(#state{socket=Socket, transport=Transport, parse_state={preface, _, _}}, Reason) ->
Transport:close(Socket),
exit({shutdown, Reason});
terminate(#state{socket=Socket, transport=Transport, client_streamid=LastStreamID,
streams=Streams, children=Children}, Reason) ->
%% @todo We might want to optionally send the Reason value