From b42c40225a6be792aa0706bdeefabc6691ae5c2d Mon Sep 17 00:00:00 2001 From: Eduardo Gurgel Date: Sun, 27 Aug 2017 22:07:42 +1200 Subject: Fix gun_http2:handle/2 when goaway is received --- src/gun_http2.erl | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/gun_http2.erl b/src/gun_http2.erl index 38017b3..41ffc2d 100644 --- a/src/gun_http2.erl +++ b/src/gun_http2.erl @@ -103,18 +103,21 @@ init(Owner, Socket, Transport, Opts) -> handle(Data, State=#http2_state{buffer=Buffer}) -> parse(<< Buffer/binary, Data/binary >>, State#http2_state{buffer= <<>>}). -parse(Data0, State=#http2_state{buffer=Buffer}) -> +parse(Data0, State0=#http2_state{buffer=Buffer}) -> %% @todo Parse states: Preface. Continuation. Data = << Buffer/binary, Data0/binary >>, case cow_http2:parse(Data) of {ok, Frame, Rest} -> - parse(Rest, frame(Frame, State)); + case frame(Frame, State0) of + close -> close; + State1 -> parse(Rest, State1) + end; {stream_error, StreamID, Reason, Human, Rest} -> - parse(Rest, stream_reset(State, StreamID, {stream_error, Reason, Human})); + parse(Rest, stream_reset(State0, StreamID, {stream_error, Reason, Human})); Error = {connection_error, _, _} -> - terminate(State, Error); + terminate(State0, Error); more -> - State#http2_state{buffer=Data} + State0#http2_state{buffer=Data} end. %% DATA frame. -- cgit v1.2.3