aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2017-11-29 17:49:42 +0100
committerLoïc Hoguin <[email protected]>2017-11-29 17:49:42 +0100
commit0246d9a4e652a78396e8753487131af73b36b7f6 (patch)
tree69f0ad466017928a0f8b8b5d69513afe23d75024 /src
parentbd6c32d3b7af8bfd8c4887b1c8711c615c51ee19 (diff)
downloadcowboy-0246d9a4e652a78396e8753487131af73b36b7f6.tar.gz
cowboy-0246d9a4e652a78396e8753487131af73b36b7f6.tar.bz2
cowboy-0246d9a4e652a78396e8753487131af73b36b7f6.zip
Don't send a GOAWAY frame on close when the h2 preface is invalid
Diffstat (limited to 'src')
-rw-r--r--src/cowboy_http2.erl4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/cowboy_http2.erl b/src/cowboy_http2.erl
index 8011196..81e2a88 100644
--- a/src/cowboy_http2.erl
+++ b/src/cowboy_http2.erl
@@ -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