couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject [3/6] git commit: Revert "Document Id and Rev in response headers" patch
Date Wed, 21 Nov 2012 15:14:10 GMT
Revert "Document Id and Rev in response headers" patch

This patch breaks some update handlers and also assumes that any JSON
response body with a property called 'id' is the actual id of a
created or updated document.

This reverts;
0a64f310b43b90176bb59040e7e866978c429c88
4edbb93d2271ac1eb82f4d2bb072b8bdf6829f85
b9af7ea506ac95034a91951f29e1f4249ef4317c


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

Branch: refs/heads/1.3.x
Commit: 15e2ef55736376ba01c20253bb9bcab25d5f8ea1
Parents: 4b035a7
Author: Robert Newson <rnewson@apache.org>
Authored: Wed Nov 21 13:03:04 2012 +0000
Committer: Robert Newson <rnewson@apache.org>
Committed: Wed Nov 21 15:13:25 2012 +0000

----------------------------------------------------------------------
 share/www/script/test/update_documents.js  |    4 +---
 src/couch_mrview/src/couch_mrview_show.erl |   14 +-------------
 src/couchdb/couch_httpd.erl                |   13 +------------
 3 files changed, 3 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/15e2ef55/share/www/script/test/update_documents.js
----------------------------------------------------------------------
diff --git a/share/www/script/test/update_documents.js b/share/www/script/test/update_documents.js
index 1dc1b4e..bbaa07d 100644
--- a/share/www/script/test/update_documents.js
+++ b/share/www/script/test/update_documents.js
@@ -107,7 +107,6 @@ couchTests.update_documents = function(debug) {
   var resp = db.save(doc);
   T(resp.ok);
   var docid = resp.id;
-  T(equals(docid, db.last_req.getResponseHeader("X-Couch-Id"))); 
 
   // update error
   var xhr = CouchDB.request("POST", "/test_suite_db/_design/update/_update/");
@@ -118,8 +117,7 @@ couchTests.update_documents = function(debug) {
   xhr = CouchDB.request("PUT", "/test_suite_db/_design/update/_update/hello/"+docid);
   T(xhr.status == 201);
   T(xhr.responseText == "<p>hello doc</p>");
-  T(/charset=utf-8/.test(xhr.getResponseHeader("Content-Type")));
-  T(equals(docid, xhr.getResponseHeader("X-Couch-Id")));
+  T(/charset=utf-8/.test(xhr.getResponseHeader("Content-Type")))
 
   doc = db.open(docid);
   T(doc.world == "hello");

http://git-wip-us.apache.org/repos/asf/couchdb/blob/15e2ef55/src/couch_mrview/src/couch_mrview_show.erl
----------------------------------------------------------------------
diff --git a/src/couch_mrview/src/couch_mrview_show.erl b/src/couch_mrview/src/couch_mrview_show.erl
index b2c3a32..3bfa035 100644
--- a/src/couch_mrview/src/couch_mrview_show.erl
+++ b/src/couch_mrview/src/couch_mrview_show.erl
@@ -144,21 +144,9 @@ send_doc_update_response(Req, Db, DDoc, UpdateName, Doc, DocId) ->
             couch_doc:validate_docid(NewDoc#doc.id),
             {ok, NewRev} = couch_db:update_doc(Db, NewDoc, Options),
             NewRevStr = couch_doc:rev_to_str(NewRev),
-            DocIdHeader = case DocId of
-                              null -> 
-                                  [{<<"json">>, {Props}}] = JsonResp0,
-                                  case lists:keyfind(<<"id">>, 1, Props) of
-                                      {_, NewDocId} -> 
-                                          [{<<"X-Couch-Id">>, NewDocId}];
-                                      false ->
-                                          []
-                                  end;
-                              DocId -> 
-                                  [{<<"X-Couch-Id">>, DocId}]
-                          end,    
             {[
                 {<<"code">>, 201},
-                {<<"headers">>, {[{<<"X-Couch-Update-NewRev">>, NewRevStr}]
++ DocIdHeader}}
+                {<<"headers">>, {[{<<"X-Couch-Update-NewRev">>, NewRevStr}]}}
                 | JsonResp0]};
         [<<"up">>, _Other, {JsonResp0}] ->
             {[{<<"code">>, 200} | JsonResp0]}

http://git-wip-us.apache.org/repos/asf/couchdb/blob/15e2ef55/src/couchdb/couch_httpd.erl
----------------------------------------------------------------------
diff --git a/src/couchdb/couch_httpd.erl b/src/couchdb/couch_httpd.erl
index a7c3425..cfca0cd 100644
--- a/src/couchdb/couch_httpd.erl
+++ b/src/couchdb/couch_httpd.erl
@@ -696,19 +696,8 @@ send_json(Req, Code, Headers, Value) ->
         {"Content-Type", negotiate_content_type(Req)},
         {"Cache-Control", "must-revalidate"}
     ],
-    IdHeader = case Value of
-                   {Props} when is_list(Props) ->
-                       case lists:keyfind(id, 1, Props) of
-                           {_, Id} ->
-                               [{"X-Couch-Id", Id}];
-                           _ ->
-                               []
-                       end;
-                   _ ->
-                       []
-               end,
     Body = [start_jsonp(), ?JSON_ENCODE(Value), end_jsonp(), $\n],
-    send_response(Req, Code, DefaultHeaders ++ IdHeader ++ Headers, Body).
+    send_response(Req, Code, DefaultHeaders ++ Headers, Body).
 
 start_json_response(Req, Code) ->
     start_json_response(Req, Code, []).


Mime
View raw message