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

Fix stream_handler_SUITE test failures due to compression

We always compress when streaming the body back to the client
regardless of the size actually streamed.
This commit is contained in:
Loïc Hoguin 2018-09-23 14:10:04 +02:00
parent f63609cb9c
commit bc43fca9e6
No known key found for this signature in database
GPG key ID: 8A9DF795F6FED764

View file

@ -358,12 +358,20 @@ do_switch_protocol_after_response(TestCase, Config) ->
]), ]),
%% Confirm init/3 is called and receive the response. %% Confirm init/3 is called and receive the response.
Pid = receive {Self, P, init, _, _, _} -> P after 1000 -> error(timeout) end, Pid = receive {Self, P, init, _, _, _} -> P after 1000 -> error(timeout) end,
{response, nofin, 200, _} = gun:await(ConnPid, Ref), {response, nofin, 200, Headers} = gun:await(ConnPid, Ref),
Gzipped =
lists:keyfind(<<"content-encoding">>, 1, Headers)
=:= {<<"content-encoding">>, <<"gzip">>},
case TestCase of case TestCase of
<<"switch_protocol_after_headers">> -> <<"switch_protocol_after_headers">> ->
ok; ok;
_ -> _ ->
{ok, <<"{}">>} = gun:await_body(ConnPid, Ref), <<"{}">> = case gun:await_body(ConnPid, Ref) of
{ok, Body} when Gzipped ->
zlib:gunzip(Body);
{ok, Body} ->
Body
end,
ok ok
end, end,
{error, _} = gun:await(ConnPid, Ref), {error, _} = gun:await(ConnPid, Ref),