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/bf15d2b2 Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/bf15d2b2 Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/bf15d2b2 Branch: refs/heads/1597-update-erlang-oauth-1-3-0 Commit: bf15d2b297f1f52a4dc982d3b57132b46d234798 Parents: 9322770 Author: Robert Newson <[email protected]> Authored: Wed Nov 21 13:03:04 2012 +0000 Committer: Robert Newson <[email protected]> Committed: Wed Nov 21 13:43:18 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/bf15d2b2/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/bf15d2b2/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/bf15d2b2/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, []).
