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.erl12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/gun_http2.erl b/src/gun_http2.erl
index 9edabaa..fef1096 100644
--- a/src/gun_http2.erl
+++ b/src/gun_http2.erl
@@ -153,11 +153,17 @@ switch_transport(Transport, Socket, State) ->
%% This function is called before returning from handle/4.
handle_ret(CommandOrCommands, #http2_state{commands_queue=[]}) ->
- CommandOrCommands;
+ empty_commands_queue(CommandOrCommands);
handle_ret(Commands, #http2_state{commands_queue=Queue}) when is_list(Commands) ->
- lists:reverse(Queue, Commands);
+ lists:reverse(Queue, empty_commands_queue(Commands));
handle_ret(Command, #http2_state{commands_queue=Queue}) ->
- lists:reverse([Command|Queue]).
+ lists:reverse([empty_commands_queue(Command)|Queue]).
+
+empty_commands_queue([{state, State}|Tail]) -> [{state, State#http2_state{commands_queue=[]}}|Tail];
+empty_commands_queue([Command|Tail]) -> [Command|empty_commands_queue(Tail)];
+empty_commands_queue([]) -> [];
+empty_commands_queue({state, State}) -> {state, State#http2_state{commands_queue=[]}};
+empty_commands_queue(Command) -> Command.
handle(Data, State=#http2_state{buffer=Buffer}, EvHandler, EvHandlerState) ->
parse(<< Buffer/binary, Data/binary >>, State#http2_state{buffer= <<>>},