couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kxe...@apache.org
Subject chttpd commit: updated refs/heads/master to 6bfa947
Date Sat, 31 Jan 2015 20:56:48 GMT
Repository: couchdb-chttpd
Updated Branches:
  refs/heads/master 718911536 -> 6bfa947ff


Enable POST requests to /_changes in clustered CouchDB

Appropriate handling of a POST to _changes is already in place in
single node CouchDB. In clustered CouchDB, allow POST requests to pass
through to the underlying handler and existing logic will do the rest.

This closes #22

COUCHDB-2530

Signed-off-by: Alexander Shorin <kxepal@apache.org>


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

Branch: refs/heads/master
Commit: 6bfa947ffd9ec083c66b103d06e0f91a58eb8ba3
Parents: 7189115
Author: Will Holley <willholley@gmail.com>
Authored: Sat Jan 31 10:46:30 2015 +0000
Committer: Alexander Shorin <kxepal@apache.org>
Committed: Sat Jan 31 23:56:38 2015 +0300

----------------------------------------------------------------------
 src/chttpd_db.erl | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/6bfa947f/src/chttpd_db.erl
----------------------------------------------------------------------
diff --git a/src/chttpd_db.erl b/src/chttpd_db.erl
index f88131a..1d749cb 100644
--- a/src/chttpd_db.erl
+++ b/src/chttpd_db.erl
@@ -61,7 +61,15 @@ handle_request(#httpd{path_parts=[DbName|RestParts],method=Method,
         do_db_req(Req, Handler)
     end.
 
+handle_changes_req(#httpd{method='POST'}=Req, Db) ->
+    couch_httpd:validate_ctype(Req, "application/json"),
+    handle_changes_req1(Req, Db);
 handle_changes_req(#httpd{method='GET'}=Req, Db) ->
+    handle_changes_req1(Req, Db);
+handle_changes_req(#httpd{path_parts=[_,<<"_changes">>]}=Req, _Db) ->
+    send_method_not_allowed(Req, "GET,POST,HEAD").
+
+handle_changes_req1(#httpd{}=Req, Db) ->
     #changes_args{filter=Raw, style=Style} = Args0 = parse_changes_query(Req),
     ChangesArgs = Args0#changes_args{
         filter_fun = couch_changes:configure_filter(Raw, Style, Req, Db)
@@ -87,9 +95,7 @@ handle_changes_req(#httpd{method='GET'}=Req, Db) ->
     _ ->
         Msg = <<"Supported `feed` types: normal, continuous, longpoll, eventsource">>,
         throw({bad_request, Msg})
-    end;
-handle_changes_req(#httpd{path_parts=[_,<<"_changes">>]}=Req, _Db) ->
-    send_method_not_allowed(Req, "GET,HEAD").
+    end.
 
 % callbacks for continuous feed (newline-delimited JSON Objects)
 changes_callback(start, {"continuous", Req}) ->


Mime
View raw message