From 266178b6bc1c2c0b07f62175c55e949a397ca7d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Sun, 28 Oct 2018 11:42:18 +0100 Subject: Remove an unnecessary function --- src/cowboy_http2.erl | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/cowboy_http2.erl b/src/cowboy_http2.erl index c7176eb..6a82a93 100644 --- a/src/cowboy_http2.erl +++ b/src/cowboy_http2.erl @@ -293,8 +293,8 @@ headers_frame(State=#state{ref=Ref, peer=Peer, sock=Sock, cert=Cert}, Port = ensure_port(Scheme, Port0), try cow_http:parse_fullpath(PathWithQs) of {<<>>, _} -> - malformed_request(State, StreamID, - 'The path component must not be empty. (RFC7540 8.1.2.3)'); + stream_reset(State, StreamID, {stream_error, protocol_error, + 'The path component must not be empty. (RFC7540 8.1.2.3)'}); {Path, Qs} -> Req0 = #{ ref => Ref, @@ -323,12 +323,12 @@ headers_frame(State=#state{ref=Ref, peer=Peer, sock=Sock, cert=Cert}, end, headers_frame(State, StreamID, Req) catch _:_ -> - malformed_request(State, StreamID, - 'The :path pseudo-header is invalid. (RFC7540 8.1.2.3)') + stream_reset(State, StreamID, {stream_error, protocol_error, + 'The :path pseudo-header is invalid. (RFC7540 8.1.2.3)'}) end catch _:_ -> - malformed_request(State, StreamID, - 'The :authority pseudo-header is invalid. (RFC7540 8.1.2.3)') + stream_reset(State, StreamID, {stream_error, protocol_error, + 'The :authority pseudo-header is invalid. (RFC7540 8.1.2.3)'}) end. ensure_port(<<"http">>, undefined) -> 80; @@ -351,13 +351,6 @@ headers_to_map([{Name, Value}|Tail], Acc0) -> end, headers_to_map(Tail, Acc). -%% @todo Probably not a very useful function, just use stream_reset. -malformed_request(State=#state{socket=Socket, transport=Transport, - http2_machine=HTTP2Machine0}, StreamID, _) -> - Transport:send(Socket, cow_http2:rst_stream(StreamID, protocol_error)), - {ok, HTTP2Machine} = cow_http2_machine:reset_stream(StreamID, HTTP2Machine0), - State#state{http2_machine=HTTP2Machine}. - headers_frame(State=#state{opts=Opts, streams=Streams}, StreamID, Req) -> try cowboy_stream:init(StreamID, Req, Opts) of {Commands, StreamState} -> -- cgit v1.2.3