0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-14 12:20:24 +00:00

Fix compress buffering tests before OTP 20.1

This commit is contained in:
Loïc Hoguin 2018-11-22 10:41:02 +01:00
parent 0223f69fcd
commit 3f5af49cfd
No known key found for this signature in database
GPG key ID: 8A9DF795F6FED764

View file

@ -198,8 +198,13 @@ opts_compress_buffering_true(Config0) ->
Z = zlib:open(),
zlib:inflateInit(Z, 31),
%% The data gets buffered because it is too small.
{data, nofin, Data1} = gun:await(ConnPid, Ref, 500),
<<>> = iolist_to_binary(zlib:inflate(Z, Data1)),
%% In zlib versions before OTP 20.1 the gzip header was also buffered.
<<>> = case gun:await(ConnPid, Ref, 500) of
{data, nofin, Data1} ->
iolist_to_binary(zlib:inflate(Z, Data1));
{error, timeout} ->
<<>>
end,
gun:close(ConnPid)
after
cowboy:stop_listener(?FUNCTION_NAME)
@ -258,8 +263,13 @@ set_options_compress_buffering_true(Config0) ->
Z = zlib:open(),
zlib:inflateInit(Z, 31),
%% The data gets buffered because it is too small.
{data, nofin, Data1} = gun:await(ConnPid, Ref, 500),
<<>> = iolist_to_binary(zlib:inflate(Z, Data1)),
%% In zlib versions before OTP 20.1 the gzip header was also buffered.
<<>> = case gun:await(ConnPid, Ref, 500) of
{data, nofin, Data1} ->
iolist_to_binary(zlib:inflate(Z, Data1));
{error, timeout} ->
<<>>
end,
gun:close(ConnPid)
after
cowboy:stop_listener(?FUNCTION_NAME)