diff options
author | Loïc Hoguin <[email protected]> | 2018-09-23 14:10:04 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2018-09-23 14:10:04 +0200 |
commit | bc43fca9e61b770ed9d6aa003fd56272ce4d2d59 (patch) | |
tree | 0a45682a5b7195ce5192cc0f8eae360f29cc152b /test/stream_handler_SUITE.erl | |
parent | f63609cb9c71ecd5d86bfff201c84915b7116c27 (diff) | |
download | cowboy-bc43fca9e61b770ed9d6aa003fd56272ce4d2d59.tar.gz cowboy-bc43fca9e61b770ed9d6aa003fd56272ce4d2d59.tar.bz2 cowboy-bc43fca9e61b770ed9d6aa003fd56272ce4d2d59.zip |
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.
Diffstat (limited to 'test/stream_handler_SUITE.erl')
-rw-r--r-- | test/stream_handler_SUITE.erl | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/test/stream_handler_SUITE.erl b/test/stream_handler_SUITE.erl index 9003e23..738a4a2 100644 --- a/test/stream_handler_SUITE.erl +++ b/test/stream_handler_SUITE.erl @@ -358,12 +358,20 @@ do_switch_protocol_after_response(TestCase, Config) -> ]), %% Confirm init/3 is called and receive the response. 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 <<"switch_protocol_after_headers">> -> 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 end, {error, _} = gun:await(ConnPid, Ref), |