diff options
author | Robert Newson <rnewson@apache.org> | 2012-11-21 13:03:04 +0000 |
---|---|---|
committer | Robert Newson <rnewson@apache.org> | 2012-11-21 13:43:18 +0000 |
commit | bf15d2b297f1f52a4dc982d3b57132b46d234798 (patch) | |
tree | 9d5b88fd87da10153b1fb2ceaf9238775dc589ef | |
parent | 93227701717de80b369a0cbfc17edf99266e5f3d (diff) | |
download | couchdb-bf15d2b297f1f52a4dc982d3b57132b46d234798.tar.gz |
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
-rw-r--r-- | share/www/script/test/update_documents.js | 4 | ||||
-rw-r--r-- | src/couch_mrview/src/couch_mrview_show.erl | 14 | ||||
-rw-r--r-- | src/couchdb/couch_httpd.erl | 13 |
3 files changed, 3 insertions, 28 deletions
diff --git a/share/www/script/test/update_documents.js b/share/www/script/test/update_documents.js index 1dc1b4e9c..bbaa07da7 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"); diff --git a/src/couch_mrview/src/couch_mrview_show.erl b/src/couch_mrview/src/couch_mrview_show.erl index b2c3a32f9..3bfa035f7 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]} diff --git a/src/couchdb/couch_httpd.erl b/src/couchdb/couch_httpd.erl index a7c3425a5..cfca0cdaf 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, []). |