aboutsummaryrefslogtreecommitdiffstats
path: root/test/handlers
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/handlers
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/handlers')
-rw-r--r--test/handlers/compress_h.erl5
1 files changed, 5 insertions, 0 deletions
diff --git a/test/handlers/compress_h.erl b/test/handlers/compress_h.erl
index 27edbd3..658c834 100644
--- a/test/handlers/compress_h.erl
+++ b/test/handlers/compress_h.erl
@@ -19,6 +19,9 @@ init(Req0, State=reply) ->
<<"content-encoding">> ->
cowboy_req:reply(200, #{<<"content-encoding">> => <<"compress">>},
lists:duplicate(100000, $a), Req0);
+ <<"etag">> ->
+ cowboy_req:reply(200, #{<<"etag">> => <<"\"STRONK\"">>},
+ lists:duplicate(100000, $a), Req0);
<<"sendfile">> ->
AppFile = code:where_is_file("cowboy.app"),
Size = filelib:file_size(AppFile),
@@ -34,6 +37,8 @@ init(Req0, State=stream_reply) ->
stream_reply(#{}, Req0);
<<"content-encoding">> ->
stream_reply(#{<<"content-encoding">> => <<"compress">>}, Req0);
+ <<"etag">> ->
+ stream_reply(#{<<"etag">> => <<"\"STRONK\"">>}, Req0);
<<"sendfile">> ->
Data = lists:duplicate(10000, $a),
AppFile = code:where_is_file("cowboy.app"),