diff options
author | Vladimir Dronnikov <[email protected]> | 2013-04-30 18:22:40 +0400 |
---|---|---|
committer | Vladimir Dronnikov <[email protected]> | 2013-04-30 19:02:58 +0400 |
commit | cacf924936cbaf533a6a9ff4c6035b2dd244bc55 (patch) | |
tree | 454fe65aac1bef2453391ce292fde9f3f0da30b2 /src | |
parent | 68a365b85ad90cfba8755dcaa9aa6d9c8aecf800 (diff) | |
download | cowboy-cacf924936cbaf533a6a9ff4c6035b2dd244bc55.tar.gz cowboy-cacf924936cbaf533a6a9ff4c6035b2dd244bc55.tar.bz2 cowboy-cacf924936cbaf533a6a9ff4c6035b2dd244bc55.zip |
Empty methods list allowed
Diffstat (limited to 'src')
-rw-r--r-- | src/cowboy_rest.erl | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/cowboy_rest.erl b/src/cowboy_rest.erl index b44ccef..0913b26 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 >>, |