mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-15 04:30:25 +00:00
Add default values to known_methods and allowed_methods
Only allowing HEAD and GET requests by default.
This commit is contained in:
parent
8d2102fe11
commit
1530d45f8e
1 changed files with 8 additions and 2 deletions
|
@ -81,8 +81,12 @@ service_available(Req, State) ->
|
||||||
|
|
||||||
known_methods(Req=#http_req{method=Method}, State) ->
|
known_methods(Req=#http_req{method=Method}, State) ->
|
||||||
case call(Req, State, known_methods) of
|
case call(Req, State, known_methods) of
|
||||||
no_call ->
|
no_call when Method =:= 'HEAD'; Method =:= 'GET'; Method =:= 'POST';
|
||||||
|
Method =:= 'PUT'; Method =:= 'DELETE'; Method =:= 'TRACE';
|
||||||
|
Method =:= 'CONNECT'; Method =:= 'OPTIONS' ->
|
||||||
next(Req, State, fun uri_too_long/2);
|
next(Req, State, fun uri_too_long/2);
|
||||||
|
no_call ->
|
||||||
|
next(Req, State, 501);
|
||||||
{List, Req2, HandlerState2} ->
|
{List, Req2, HandlerState2} ->
|
||||||
State2 = State#state{handler_state=HandlerState2},
|
State2 = State#state{handler_state=HandlerState2},
|
||||||
case lists:member(Method, List) of
|
case lists:member(Method, List) of
|
||||||
|
@ -96,8 +100,10 @@ uri_too_long(Req, State) ->
|
||||||
|
|
||||||
allowed_methods(Req=#http_req{method=Method}, State) ->
|
allowed_methods(Req=#http_req{method=Method}, State) ->
|
||||||
case call(Req, State, allowed_methods) of
|
case call(Req, State, allowed_methods) of
|
||||||
no_call ->
|
no_call when Method =:= 'HEAD'; Method =:= 'GET' ->
|
||||||
next(Req, State, fun malformed_request/2);
|
next(Req, State, fun malformed_request/2);
|
||||||
|
no_call ->
|
||||||
|
method_not_allowed(Req, State, ['GET', 'HEAD']);
|
||||||
{List, Req2, HandlerState2} ->
|
{List, Req2, HandlerState2} ->
|
||||||
State2 = State#state{handler_state=HandlerState2},
|
State2 = State#state{handler_state=HandlerState2},
|
||||||
case lists:member(Method, List) of
|
case lists:member(Method, List) of
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue