mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 12:20:24 +00:00
Always add vary: accept-encoding in cowboy_compress_h
We must add it even if we don't end up compressing because it indicates that we might. This indication doesn't mean that the user agent's accept-encoding values will ever result in content encoding being applied.
This commit is contained in:
parent
e0adf0a19c
commit
9784179498
3 changed files with 38 additions and 21 deletions
|
@ -67,7 +67,7 @@ gzip_accept_encoding_malformed(Config) ->
|
|||
{200, Headers, _} = do_get("/reply/large",
|
||||
[{<<"accept-encoding">>, <<";">>}], Config),
|
||||
false = lists:keyfind(<<"content-encoding">>, 1, Headers),
|
||||
false = lists:keyfind(<<"vary">>, 1, Headers),
|
||||
{_, <<"accept-encoding">>} = lists:keyfind(<<"vary">>, 1, Headers),
|
||||
{_, <<"100000">>} = lists:keyfind(<<"content-length">>, 1, Headers),
|
||||
ok.
|
||||
|
||||
|
@ -76,7 +76,7 @@ gzip_accept_encoding_missing(Config) ->
|
|||
{200, Headers, _} = do_get("/reply/large",
|
||||
[], Config),
|
||||
false = lists:keyfind(<<"content-encoding">>, 1, Headers),
|
||||
false = lists:keyfind(<<"vary">>, 1, Headers),
|
||||
{_, <<"accept-encoding">>} = lists:keyfind(<<"vary">>, 1, Headers),
|
||||
{_, <<"100000">>} = lists:keyfind(<<"content-length">>, 1, Headers),
|
||||
ok.
|
||||
|
||||
|
@ -85,7 +85,7 @@ gzip_accept_encoding_no_gzip(Config) ->
|
|||
{200, Headers, _} = do_get("/reply/large",
|
||||
[{<<"accept-encoding">>, <<"compress">>}], Config),
|
||||
false = lists:keyfind(<<"content-encoding">>, 1, Headers),
|
||||
false = lists:keyfind(<<"vary">>, 1, Headers),
|
||||
{_, <<"accept-encoding">>} = lists:keyfind(<<"vary">>, 1, Headers),
|
||||
{_, <<"100000">>} = lists:keyfind(<<"content-length">>, 1, Headers),
|
||||
ok.
|
||||
|
||||
|
@ -94,7 +94,7 @@ gzip_accept_encoding_not_supported(Config) ->
|
|||
{200, Headers, _} = do_get("/reply/large",
|
||||
[{<<"accept-encoding">>, <<"application/gzip">>}], Config),
|
||||
false = lists:keyfind(<<"content-encoding">>, 1, Headers),
|
||||
false = lists:keyfind(<<"vary">>, 1, Headers),
|
||||
{_, <<"accept-encoding">>} = lists:keyfind(<<"vary">>, 1, Headers),
|
||||
{_, <<"100000">>} = lists:keyfind(<<"content-length">>, 1, Headers),
|
||||
ok.
|
||||
|
||||
|
@ -105,7 +105,7 @@ gzip_reply_content_encoding(Config) ->
|
|||
%% We set the content-encoding to compress; without actually compressing.
|
||||
{_, <<"compress">>} = lists:keyfind(<<"content-encoding">>, 1, Headers),
|
||||
%% The reply didn't include a vary header.
|
||||
false = lists:keyfind(<<"vary">>, 1, Headers),
|
||||
{_, <<"accept-encoding">>} = lists:keyfind(<<"vary">>, 1, Headers),
|
||||
{_, <<"100000">>} = lists:keyfind(<<"content-length">>, 1, Headers),
|
||||
ok.
|
||||
|
||||
|
@ -116,7 +116,7 @@ gzip_reply_etag(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),
|
||||
{_, <<"accept-encoding">>} = lists:keyfind(<<"vary">>, 1, Headers),
|
||||
{_, <<"100000">>} = lists:keyfind(<<"content-length">>, 1, Headers),
|
||||
ok.
|
||||
|
||||
|
@ -136,7 +136,7 @@ gzip_reply_sendfile(Config) ->
|
|||
{200, Headers, Body} = do_get("/reply/sendfile",
|
||||
[{<<"accept-encoding">>, <<"gzip">>}], Config),
|
||||
false = lists:keyfind(<<"content-encoding">>, 1, Headers),
|
||||
false = lists:keyfind(<<"vary">>, 1, Headers),
|
||||
{_, <<"accept-encoding">>} = lists:keyfind(<<"vary">>, 1, Headers),
|
||||
ct:log("Body received:~n~p~n", [Body]),
|
||||
ok.
|
||||
|
||||
|
@ -145,7 +145,7 @@ gzip_reply_small_body(Config) ->
|
|||
{200, Headers, _} = do_get("/reply/small",
|
||||
[{<<"accept-encoding">>, <<"gzip">>}], Config),
|
||||
false = lists:keyfind(<<"content-encoding">>, 1, Headers),
|
||||
false = lists:keyfind(<<"vary">>, 1, Headers),
|
||||
{_, <<"accept-encoding">>} = lists:keyfind(<<"vary">>, 1, Headers),
|
||||
{_, <<"100">>} = lists:keyfind(<<"content-length">>, 1, Headers),
|
||||
ok.
|
||||
|
||||
|
@ -181,7 +181,7 @@ gzip_stream_reply_content_encoding(Config) ->
|
|||
{200, Headers, Body} = do_get("/stream_reply/content-encoding",
|
||||
[{<<"accept-encoding">>, <<"gzip">>}], Config),
|
||||
{_, <<"compress">>} = lists:keyfind(<<"content-encoding">>, 1, Headers),
|
||||
false = lists:keyfind(<<"vary">>, 1, Headers),
|
||||
{_, <<"accept-encoding">>} = lists:keyfind(<<"vary">>, 1, Headers),
|
||||
100000 = iolist_size(Body),
|
||||
ok.
|
||||
|
||||
|
@ -190,7 +190,7 @@ gzip_stream_reply_etag(Config) ->
|
|||
{200, Headers, Body} = do_get("/stream_reply/etag",
|
||||
[{<<"accept-encoding">>, <<"gzip">>}], Config),
|
||||
{_, <<"\"STRONK\"">>} = lists:keyfind(<<"etag">>, 1, Headers),
|
||||
false = lists:keyfind(<<"vary">>, 1, Headers),
|
||||
{_, <<"accept-encoding">>} = lists:keyfind(<<"vary">>, 1, Headers),
|
||||
100000 = iolist_size(Body),
|
||||
ok.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue