From ae96aa6e494d8cb4bf3525ecf7575552d1e6f5e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Mon, 19 Nov 2018 12:24:28 +0100 Subject: Add an additional test to the static test suite --- src/cowboy_static.erl | 2 +- test/static_handler_SUITE.erl | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/cowboy_static.erl b/src/cowboy_static.erl index 19c15c2..d6ef45c 100644 --- a/src/cowboy_static.erl +++ b/src/cowboy_static.erl @@ -340,7 +340,7 @@ charsets_provided(Req, State={Path, _, Extra}) -> no_call; {charset, Module, Function} -> {[Module:Function(Path)], Req, State}; - {charset, Charset} -> + {charset, Charset} when is_binary(Charset) -> {[Charset], Req, State} end. diff --git a/test/static_handler_SUITE.erl b/test/static_handler_SUITE.erl index 7ac31f8..69bd284 100644 --- a/test/static_handler_SUITE.erl +++ b/test/static_handler_SUITE.erl @@ -195,6 +195,7 @@ execute(Req=#{path := Path}, Env) -> <<"/bad/options">> -> ct_helper:ignore(cowboy_static, content_types_provided, 2); <<"/bad/options/mime">> -> ct_helper:ignore(cowboy_rest, set_content_type, 2); <<"/bad/options/etag">> -> ct_helper:ignore(cowboy_static, generate_etag, 2); + <<"/bad/options/charset">> -> ct_helper:ignore(cowboy_static, charsets_provided, 2); _ -> ok end, {ok, Req, Env}. @@ -279,6 +280,11 @@ bad_options(Config) -> {500, _, _} = do_get("/bad/options", Config), ok. +bad_options_charset(Config) -> + doc("Bad cowboy_static extra options: invalid charset option."), + {500, _, _} = do_get("/bad/options/charset", Config), + ok. + bad_options_etag(Config) -> doc("Bad cowboy_static extra options: invalid etag option."), {500, _, _} = do_get("/bad/options/etag", Config), -- cgit v1.2.3