aboutsummaryrefslogtreecommitdiffstats
path: root/src/cowboy_compress_h.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/cowboy_compress_h.erl')
-rw-r--r--src/cowboy_compress_h.erl8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/cowboy_compress_h.erl b/src/cowboy_compress_h.erl
index 9c2ae34..9dcb805 100644
--- a/src/cowboy_compress_h.erl
+++ b/src/cowboy_compress_h.erl
@@ -128,8 +128,12 @@ fold([Response0={headers, _, Headers}|Tail], State0, Acc) ->
fold([Data0={data, _, _}|Tail], State0=#state{compress=gzip}, Acc) ->
{Data, State} = gzip_data(Data0, State0),
fold(Tail, State, [Data|Acc]);
-%% Otherwise, we either have an unrelated command, or a data command
-%% with compression disabled.
+%% When trailers are sent we need to end the compression.
+%% This results in an extra data command being sent.
+fold([Trailers={trailers, _}|Tail], State0=#state{compress=gzip}, Acc) ->
+ {{data, fin, Data}, State} = gzip_data({data, fin, <<>>}, State0),
+ fold(Tail, State, [Trailers, {data, nofin, Data}|Acc]);
+%% Otherwise, we have an unrelated command or compression is disabled.
fold([Command|Tail], State, Acc) ->
fold(Tail, State, [Command|Acc]).