diff options
author | Loïc Hoguin <[email protected]> | 2011-12-08 18:54:20 +0100 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2011-12-08 18:54:20 +0100 |
commit | 1530d45f8e4a356a1be165709a666965b82cde9c (patch) | |
tree | da6565cacf04ac489720a1b931bca08f873630f5 | |
parent | 8d2102fe1174d5fb82d80ca3beba83b9d5bbb238 (diff) | |
download | cowboy-1530d45f8e4a356a1be165709a666965b82cde9c.tar.gz cowboy-1530d45f8e4a356a1be165709a666965b82cde9c.tar.bz2 cowboy-1530d45f8e4a356a1be165709a666965b82cde9c.zip |
Add default values to known_methods and allowed_methods
Only allowing HEAD and GET requests by default.
-rw-r--r-- | src/cowboy_http_rest.erl | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/cowboy_http_rest.erl b/src/cowboy_http_rest.erl index 3ef730f..62e712e 100644 --- a/src/cowboy_http_rest.erl +++ b/src/cowboy_http_rest.erl @@ -81,8 +81,12 @@ service_available(Req, State) -> known_methods(Req=#http_req{method=Method}, State) -> 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); + no_call -> + next(Req, State, 501); {List, Req2, HandlerState2} -> State2 = State#state{handler_state=HandlerState2}, case lists:member(Method, List) of @@ -96,8 +100,10 @@ uri_too_long(Req, State) -> allowed_methods(Req=#http_req{method=Method}, State) -> case call(Req, State, allowed_methods) of - no_call -> + no_call when Method =:= 'HEAD'; Method =:= 'GET' -> next(Req, State, fun malformed_request/2); + no_call -> + method_not_allowed(Req, State, ['GET', 'HEAD']); {List, Req2, HandlerState2} -> State2 = State#state{handler_state=HandlerState2}, case lists:member(Method, List) of |