aboutsummaryrefslogtreecommitdiffstats
path: root/test/compress_SUITE.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2024-01-05 15:53:42 +0100
committerLoïc Hoguin <[email protected]>2024-01-05 15:53:42 +0100
commit5b2f600036145653c48a7e8a60853e4a0ecc770b (patch)
tree01ed5b3a36faa666026802356807a53b2805fdca /test/compress_SUITE.erl
parent67df6fedaea83b8159fbadbadf460a1f3dd98c51 (diff)
downloadcowboy-5b2f600036145653c48a7e8a60853e4a0ecc770b.tar.gz
cowboy-5b2f600036145653c48a7e8a60853e4a0ecc770b.tar.bz2
cowboy-5b2f600036145653c48a7e8a60853e4a0ecc770b.zip
Don't automatically compress when response has etag
In the cowboy_compress_h stream handler. Otherwise this could cause issues with caching, with the etag being the same for compressed/uncompressed content. Users that wish to send etags AND compress will have to do it manually for the time being.
Diffstat (limited to 'test/compress_SUITE.erl')
-rw-r--r--test/compress_SUITE.erl20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/compress_SUITE.erl b/test/compress_SUITE.erl
index a25c427..80f588d 100644
--- a/test/compress_SUITE.erl
+++ b/test/compress_SUITE.erl
@@ -109,6 +109,17 @@ gzip_reply_content_encoding(Config) ->
{_, <<"100000">>} = lists:keyfind(<<"content-length">>, 1, Headers),
ok.
+gzip_reply_etag(Config) ->
+ doc("Reply with etag header; get an uncompressed response."),
+ {200, Headers, _} = do_get("/reply/etag",
+ [{<<"accept-encoding">>, <<"gzip">>}], Config),
+ %% We set a strong etag.
+ {_, <<"\"STRONK\"">>} = lists:keyfind(<<"etag">>, 1, Headers),
+ %% The reply didn't include a vary header.
+ false = lists:keyfind(<<"vary">>, 1, Headers),
+ {_, <<"100000">>} = lists:keyfind(<<"content-length">>, 1, Headers),
+ ok.
+
gzip_reply_large_body(Config) ->
doc("Reply a large body; get a gzipped response."),
{200, Headers, GzBody} = do_get("/reply/large",
@@ -174,6 +185,15 @@ gzip_stream_reply_content_encoding(Config) ->
100000 = iolist_size(Body),
ok.
+gzip_stream_reply_etag(Config) ->
+ doc("Stream reply with etag header; get an uncompressed response."),
+ {200, Headers, Body} = do_get("/stream_reply/etag",
+ [{<<"accept-encoding">>, <<"gzip">>}], Config),
+ {_, <<"\"STRONK\"">>} = lists:keyfind(<<"etag">>, 1, Headers),
+ false = lists:keyfind(<<"vary">>, 1, Headers),
+ 100000 = iolist_size(Body),
+ ok.
+
opts_compress_buffering_false(Config0) ->
doc("Confirm that the compress_buffering option can be set to false, "
"which is the default."),