aboutsummaryrefslogtreecommitdiffstats
path: root/src/cowboy_rest.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2013-05-31 15:13:24 +0200
committerLoïc Hoguin <[email protected]>2013-05-31 15:13:24 +0200
commitcab1a8fb4575b931daf1df56f64abb9460f5911e (patch)
treef7b9e47cf41bf66f5c4c9621d5631fd9a8c8c999 /src/cowboy_rest.erl
parent9a2d35c2e800ee73c27b6d6cc324453c5219f715 (diff)
parentcacf924936cbaf533a6a9ff4c6035b2dd244bc55 (diff)
downloadcowboy-cab1a8fb4575b931daf1df56f64abb9460f5911e.tar.gz
cowboy-cab1a8fb4575b931daf1df56f64abb9460f5911e.tar.bz2
cowboy-cab1a8fb4575b931daf1df56f64abb9460f5911e.zip
Merge branch 'rest_method' of git://github.com/dvv/cowboy
Diffstat (limited to 'src/cowboy_rest.erl')
-rw-r--r--src/cowboy_rest.erl6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/cowboy_rest.erl b/src/cowboy_rest.erl
index b87c7df..ecbe7bc 100644
--- a/src/cowboy_rest.erl
+++ b/src/cowboy_rest.erl
@@ -145,6 +145,9 @@ allowed_methods(Req, State=#state{method=Method}) ->
end
end.
+method_not_allowed(Req, State, []) ->
+ Req2 = cowboy_req:set_resp_header(<<"allow">>, <<>>, Req),
+ respond(Req2, State, 405);
method_not_allowed(Req, State, Methods) ->
<< ", ", Allow/binary >> = << << ", ", M/binary >> || M <- Methods >>,
Req2 = cowboy_req:set_resp_header(<<"allow">>, Allow, Req),
@@ -186,6 +189,9 @@ valid_entity_length(Req, State) ->
%% you should do it directly in the options/2 call using set_resp_headers.
options(Req, State=#state{allowed_methods=Methods, method= <<"OPTIONS">>}) ->
case call(Req, State, options) of
+ no_call when Methods =:= [] ->
+ Req2 = cowboy_req:set_resp_header(<<"allow">>, <<>>, Req),
+ respond(Req2, State, 200);
no_call ->
<< ", ", Allow/binary >>
= << << ", ", M/binary >> || M <- Methods >>,