couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject [44/49] chttpd commit: updated refs/heads/windsor-merge to 554ef74
Date Fri, 01 Aug 2014 09:06:20 GMT
Separate update doc and sending the response in update_doc


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

Branch: refs/heads/windsor-merge
Commit: 8d66fa43b0f0ab6a4c69db873a124b66dcb99571
Parents: 5e2f7c3
Author: Russell Branca <chewbranca@gmail.com>
Authored: Tue Apr 8 15:42:22 2014 -0700
Committer: Robert Newson <rnewson@apache.org>
Committed: Thu Jul 31 11:55:11 2014 +0100

----------------------------------------------------------------------
 src/chttpd_db.erl | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/8d66fa43/src/chttpd_db.erl
----------------------------------------------------------------------
diff --git a/src/chttpd_db.erl b/src/chttpd_db.erl
index c1a3297..27ead6a 100644
--- a/src/chttpd_db.erl
+++ b/src/chttpd_db.erl
@@ -851,7 +851,11 @@ update_doc(#httpd{user_ctx=Ctx} = Req, Db, DocId, #doc{deleted=Deleted}=Doc,
         _ ->
             [UpdateType, {user_ctx,Ctx}, {w,W}]
         end,
+    {HttpCode, ResponseHeaders, Body} = update_doc_int(Db, DocId,
+        #doc{deleted=Deleted}=Doc, Headers, Options),
+    send_json(Req, HttpCode, ResponseHeaders, Body).
 
+update_doc_int(Db, DocId, #doc{deleted=Deleted}=Doc, Headers, Options) ->
     {_, Ref} = spawn_monitor(fun() ->
         try fabric:update_doc(Db, Doc, Options) of
             Resp ->
@@ -892,11 +896,8 @@ update_doc(#httpd{user_ctx=Ctx} = Req, Db, DocId, #doc{deleted=Deleted}=Doc,
     {false, false} ->
         HttpCode = 201
     end,
-    send_json(Req, HttpCode, ResponseHeaders, {[
-        {ok, true},
-        {id, DocId},
-        {rev, NewRevStr}
-    ]}).
+    Body = {[{ok, true}, {id, DocId}, {rev, NewRevStr}]},
+    {HttpCode, ResponseHeaders, Body}.
 
 couch_doc_from_req(Req, DocId, #doc{revs=Revs} = Doc) ->
     validate_attachment_names(Doc),


Mime
View raw message