couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kxe...@apache.org
Subject couchdb-mango git commit: Correctly handle unsupported HTTP methods per resource
Date Sat, 17 Oct 2015 21:48:37 GMT
Repository: couchdb-mango
Updated Branches:
  refs/heads/master 0cc0fb8d2 -> a297e2e9e


Correctly handle unsupported HTTP methods per resource


Project: http://git-wip-us.apache.org/repos/asf/couchdb-mango/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-mango/commit/a297e2e9
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-mango/tree/a297e2e9
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-mango/diff/a297e2e9

Branch: refs/heads/master
Commit: a297e2e9e2c006381f982e73a08fff29c4f8db8f
Parents: 0cc0fb8
Author: Alexander Shorin <kxepal@apache.org>
Authored: Mon Oct 12 19:22:23 2015 +0300
Committer: Alexander Shorin <kxepal@apache.org>
Committed: Sun Oct 18 00:46:24 2015 +0300

----------------------------------------------------------------------
 src/mango_httpd.erl | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/a297e2e9/src/mango_httpd.erl
----------------------------------------------------------------------
diff --git a/src/mango_httpd.erl b/src/mango_httpd.erl
index 9e56be9..ef7135c 100644
--- a/src/mango_httpd.erl
+++ b/src/mango_httpd.erl
@@ -107,6 +107,9 @@ handle_index_req(#httpd{method='POST', path_parts=[_, _]}=Req, Db) ->
     end,
 	chttpd:send_json(Req, {[{result, Status}, {id, Id}, {name, Name}]});
 
+handle_index_req(#httpd{path_parts=[_, _]}=Req, _Db) ->
+    chttpd:send_method_not_allowed(Req, "GET,POST");
+
 %% Essentially we just iterate through the list of ddoc ids passed in and
 %% delete one by one. If an error occurs, all previous documents will be
 %% deleted, but an error will be thrown for the current ddoc id.
@@ -130,6 +133,10 @@ handle_index_req(#httpd{method='POST', path_parts=[_, <<"_index">>,
     end, {[], []}, DDocs),
     chttpd:send_json(Req, {[{<<"success">>, Success}, {<<"fail">>,
Fail}]});
 
+handle_index_req(#httpd{path_parts=[_, <<"_index">>,
+        <<"_bulk_delete">>]}=Req, _Db) ->
+    chttpd:send_method_not_allowed(Req, "POST");
+
 handle_index_req(#httpd{method='DELETE',
         path_parts=[A, B, <<"_design">>, DDocId0, Type, Name]}=Req, Db) ->
     PathParts = [A, B, <<"_design/", DDocId0/binary>>, Type, Name],
@@ -155,8 +162,8 @@ handle_index_req(#httpd{method='DELETE',
             ?MANGO_ERROR({error_saving_ddoc, Error})
     end;
 
-handle_index_req(Req, _Db) ->
-    chttpd:send_method_not_allowed(Req, "GET,POST,DELETE").
+handle_index_req(#httpd{path_parts=[_, _, _DDocId0, _Type, _Name]}=Req, _Db) ->
+    chttpd:send_method_not_allowed(Req, "DELETE").
 
 
 handle_explain_req(#httpd{method='POST'}=Req, Db) ->


Mime
View raw message