aboutsummaryrefslogtreecommitdiffstats
path: root/test/http_SUITE.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2012-05-21 15:53:31 +0200
committerLoïc Hoguin <[email protected]>2012-05-21 16:33:37 +0200
commit295dc64eaa002c8ce03ac4bedffd7bc4e3be025a (patch)
tree70ffa91498c5ec19155ef764bfc2cec9c83f8af0 /test/http_SUITE.erl
parent040c6dc31af3b17dfec7e2925bc8c4a15f301d7e (diff)
parent8168ae96c8543e02e5899187e6f7c7ed5b40c35d (diff)
downloadcowboy-295dc64eaa002c8ce03ac4bedffd7bc4e3be025a.tar.gz
cowboy-295dc64eaa002c8ce03ac4bedffd7bc4e3be025a.tar.bz2
cowboy-295dc64eaa002c8ce03ac4bedffd7bc4e3be025a.zip
Merge branch 'serve-static-file' of https://github.com/klaar/cowboy
Fix alphabetical order since @klaar seems to have issues with it. ;)
Diffstat (limited to 'test/http_SUITE.erl')
-rw-r--r--test/http_SUITE.erl26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/http_SUITE.erl b/test/http_SUITE.erl
index e247138..095d6b5 100644
--- a/test/http_SUITE.erl
+++ b/test/http_SUITE.erl
@@ -59,6 +59,8 @@
-export([static_attribute_etag/1]).
-export([static_function_etag/1]).
-export([static_mimetypes_function/1]).
+-export([static_specify_file/1]).
+-export([static_specify_file_catchall/1]).
-export([static_test_file/1]).
-export([static_test_file_css/1]).
-export([stream_body_set_resp/1]).
@@ -102,6 +104,8 @@ groups() ->
static_attribute_etag,
static_function_etag,
static_mimetypes_function,
+ static_specify_file,
+ static_specify_file_catchall,
static_test_file,
static_test_file_css,
stream_body_set_resp,
@@ -243,6 +247,10 @@ init_dispatch(Config) ->
{[<<"static_function_etag">>, '...'], cowboy_http_static,
[{directory, ?config(static_dir, Config)},
{etag, {fun static_function_etag/2, etag_data}}]},
+ {[<<"static_specify_file">>, '...'], cowboy_http_static,
+ [{directory, ?config(static_dir, Config)},
+ {mimetypes, [{<<".css">>, [<<"text/css">>]}]},
+ {file, <<"test_file.css">>}]},
{[<<"multipart">>], http_handler_multipart, []},
{[<<"echo">>, <<"body">>], http_handler_echo_body, []},
{[<<"simple">>], rest_simple_resource, []},
@@ -805,6 +813,24 @@ static_mimetypes_function(Config) ->
{<<"content-type">>, <<"text/html">>}
= lists:keyfind(<<"content-type">>, 1, Headers).
+static_specify_file(Config) ->
+ Client = ?config(client, Config),
+ {ok, Client2} = cowboy_client:request(<<"GET">>,
+ build_url("/static_specify_file", Config), Client),
+ {ok, 200, Headers, Client3} = cowboy_client:response(Client2),
+ {<<"content-type">>, <<"text/css">>}
+ = lists:keyfind(<<"content-type">>, 1, Headers),
+ {ok, <<"test_file.css\n">>, _} = cowboy_client:response_body(Client3).
+
+static_specify_file_catchall(Config) ->
+ Client = ?config(client, Config),
+ {ok, Client2} = cowboy_client:request(<<"GET">>,
+ build_url("/static_specify_file/none", Config), Client),
+ {ok, 200, Headers, Client3} = cowboy_client:response(Client2),
+ {<<"content-type">>, <<"text/css">>}
+ = lists:keyfind(<<"content-type">>, 1, Headers),
+ {ok, <<"test_file.css\n">>, _} = cowboy_client:response_body(Client3).
+
static_test_file(Config) ->
Client = ?config(client, Config),
{ok, Client2} = cowboy_client:request(<<"GET">>,