mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 12:20:24 +00:00
remove header setting from options/2
This commit is contained in:
parent
c37a6fba75
commit
c804ca4901
1 changed files with 5 additions and 9 deletions
|
@ -337,8 +337,9 @@ allowed_methods(Req, State=#state{method=Method}) ->
|
||||||
Req2 = cowboy_req:set_resp_header(<<"allow">>, Allow, Req),
|
Req2 = cowboy_req:set_resp_header(<<"allow">>, Allow, Req),
|
||||||
next(Req2, State, fun malformed_request/2);
|
next(Req2, State, fun malformed_request/2);
|
||||||
no_call when Method =:= <<"OPTIONS">> ->
|
no_call when Method =:= <<"OPTIONS">> ->
|
||||||
next(Req, State#state{allowed_methods=DefaultAllowedMethods},
|
Allow = stringify_allowed_methods(DefaultAllowedMethods),
|
||||||
fun malformed_request/2);
|
Req2 = cowboy_req:set_resp_header(<<"allow">>, Allow, Req),
|
||||||
|
next(Req2, State, fun malformed_request/2);
|
||||||
no_call ->
|
no_call ->
|
||||||
method_not_allowed(Req, State, DefaultAllowedMethods);
|
method_not_allowed(Req, State, DefaultAllowedMethods);
|
||||||
{stop, Req2, State2} ->
|
{stop, Req2, State2} ->
|
||||||
|
@ -417,15 +418,10 @@ valid_entity_length(Req, State) ->
|
||||||
|
|
||||||
%% If you need to add additional headers to the response at this point,
|
%% If you need to add additional headers to the response at this point,
|
||||||
%% 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{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 = stringify_allowed_methods(Methods),
|
respond(Req, State, 200);
|
||||||
Req2 = cowboy_req:set_resp_header(<<"allow">>, Allow, Req),
|
|
||||||
respond(Req2, State, 200);
|
|
||||||
{stop, Req2, State2} ->
|
{stop, Req2, State2} ->
|
||||||
terminate(Req2, State2);
|
terminate(Req2, State2);
|
||||||
{Switch, Req2, State2} when element(1, Switch) =:= switch_handler ->
|
{Switch, Req2, State2} when element(1, Switch) =:= switch_handler ->
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue