mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-15 12:40:25 +00:00
Empty methods list allowed
This commit is contained in:
parent
68a365b85a
commit
cacf924936
1 changed files with 6 additions and 0 deletions
|
@ -145,6 +145,9 @@ allowed_methods(Req, State=#state{method=Method}) ->
|
||||||
end
|
end
|
||||||
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) ->
|
method_not_allowed(Req, State, Methods) ->
|
||||||
<< ", ", Allow/binary >> = << << ", ", M/binary >> || M <- Methods >>,
|
<< ", ", Allow/binary >> = << << ", ", M/binary >> || M <- Methods >>,
|
||||||
Req2 = cowboy_req:set_resp_header(<<"allow">>, Allow, Req),
|
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.
|
%% you should do it directly in the options/2 call using set_resp_headers.
|
||||||
options(Req, State=#state{allowed_methods=Methods, method= <<"OPTIONS">>}) ->
|
options(Req, State=#state{allowed_methods=Methods, method= <<"OPTIONS">>}) ->
|
||||||
case call(Req, State, options) of
|
case call(Req, State, options) of
|
||||||
|
no_call when Methods =:= [] ->
|
||||||
|
Req2 = cowboy_req:set_resp_header(<<"allow">>, <<>>, Req),
|
||||||
|
respond(Req2, State, 200);
|
||||||
no_call ->
|
no_call ->
|
||||||
<< ", ", Allow/binary >>
|
<< ", ", Allow/binary >>
|
||||||
= << << ", ", M/binary >> || M <- Methods >>,
|
= << << ", ", M/binary >> || M <- Methods >>,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue