aboutsummaryrefslogtreecommitdiffstats
path: root/src/gun_http2.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/gun_http2.erl')
-rw-r--r--src/gun_http2.erl13
1 files changed, 8 insertions, 5 deletions
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.