aboutsummaryrefslogtreecommitdiffstats
path: root/src/gun_http2.erl
diff options
context:
space:
mode:
authorEduardo Gurgel <[email protected]>2017-08-27 22:07:42 +1200
committerLoïc Hoguin <[email protected]>2017-09-02 14:52:50 +0200
commitb42c40225a6be792aa0706bdeefabc6691ae5c2d (patch)
tree677e5a299841338964d79a1e8888912f39a69b8a /src/gun_http2.erl
parent0fe54af72b81fdb198a377198d7f3a91f9ad6d7c (diff)
downloadgun-b42c40225a6be792aa0706bdeefabc6691ae5c2d.tar.gz
gun-b42c40225a6be792aa0706bdeefabc6691ae5c2d.tar.bz2
gun-b42c40225a6be792aa0706bdeefabc6691ae5c2d.zip
Fix gun_http2:handle/2 when goaway is received
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.