aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2013-04-12 18:20:41 +0200
committerLoïc Hoguin <[email protected]>2013-04-12 19:02:00 +0200
commitb58a0549e139b410db50ddd443cc457fb677fa7e (patch)
tree819ab4484bfb6b75262e2d9eb871190453fecadb /test
parentd063511a0e4988d62357f9c17744bb9aa0470a06 (diff)
downloadcowboy-b58a0549e139b410db50ddd443cc457fb677fa7e.tar.gz
cowboy-b58a0549e139b410db50ddd443cc457fb677fa7e.tar.bz2
cowboy-b58a0549e139b410db50ddd443cc457fb677fa7e.zip
Add default operations for OPTIONS method in REST
It defaults to setting the Allow header to "HEAD, GET, OPTIONS".
Diffstat (limited to 'test')
-rw-r--r--test/http_SUITE.erl10
-rw-r--r--test/rest_empty_resource.erl5
2 files changed, 15 insertions, 0 deletions
diff --git a/test/http_SUITE.erl b/test/http_SUITE.erl
index 34a7be1..4a01856 100644
--- a/test/http_SUITE.erl
+++ b/test/http_SUITE.erl
@@ -61,6 +61,7 @@
-export([rest_missing_get_callbacks/1]).
-export([rest_missing_put_callbacks/1]).
-export([rest_nodelete/1]).
+-export([rest_options_default/1]).
-export([rest_param_all/1]).
-export([rest_patch/1]).
-export([rest_resource_etags/1]).
@@ -131,6 +132,7 @@ groups() ->
rest_missing_get_callbacks,
rest_missing_put_callbacks,
rest_nodelete,
+ rest_options_default,
rest_param_all,
rest_patch,
rest_resource_etags,
@@ -367,6 +369,7 @@ init_dispatch(Config) ->
{"/patch", rest_patch_resource, []},
{"/resetags", rest_resource_etags, []},
{"/rest_expires", rest_expires, []},
+ {"/rest_empty_resource", rest_empty_resource, []},
{"/loop_recv", http_handler_loop_recv, []},
{"/loop_timeout", http_handler_loop_timeout, []},
{"/", http_handler, []}
@@ -967,6 +970,13 @@ rest_nodelete(Config) ->
build_url("/nodelete", Config), Client),
{ok, 500, _, _} = cowboy_client:response(Client2).
+rest_options_default(Config) ->
+ Client = ?config(client, Config),
+ {ok, Client2} = cowboy_client:request(<<"OPTIONS">>,
+ build_url("/rest_empty_resource", Config), Client),
+ {ok, 200, Headers, _} = cowboy_client:response(Client2),
+ {_, <<"HEAD, GET, OPTIONS">>} = lists:keyfind(<<"allow">>, 1, Headers).
+
rest_patch(Config) ->
Tests = [
{204, [{<<"content-type">>, <<"text/plain">>}], <<"whatever">>},
diff --git a/test/rest_empty_resource.erl b/test/rest_empty_resource.erl
new file mode 100644
index 0000000..7e7c00a
--- /dev/null
+++ b/test/rest_empty_resource.erl
@@ -0,0 +1,5 @@
+-module(rest_empty_resource).
+-export([init/3]).
+
+init(_Transport, _Req, _Opts) ->
+ {upgrade, protocol, cowboy_rest}.