diff options
author | Jan Lehnardt <jan@apache.org> | 2009-03-18 12:15:17 +0000 |
---|---|---|
committer | Jan Lehnardt <jan@apache.org> | 2009-03-18 12:15:17 +0000 |
commit | 56063e82a2ad88a6c4125906d64a6de7e8a8b7ee (patch) | |
tree | 11a0cc21528f67bfd33858162d3b474e92f271aa | |
parent | 2ee3c710ae726c31812cabb4827e777687ab660c (diff) |
remove MOVE requests as they can't sensibly be supported and COPY & DELETE does the same thing
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@755575 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | share/www/script/test/copy_move_doc.js | 25 | ||||
-rw-r--r-- | src/couchdb/couch_httpd_db.erl | 27 |
2 files changed, 5 insertions, 47 deletions
diff --git a/share/www/script/test/copy_move_doc.js b/share/www/script/test/copy_move_doc.js index 050f8113..1b3ab0f9 100644 --- a/share/www/script/test/copy_move_doc.js +++ b/share/www/script/test/copy_move_doc.js @@ -10,7 +10,7 @@ // License for the specific language governing permissions and limitations under // the License. -couchTests.copy_move_doc = function(debug) { +couchTests.copy_doc = function(debug) { var db = new CouchDB("test_suite_db"); db.deleteDb(); db.createDb(); @@ -25,36 +25,19 @@ couchTests.copy_move_doc = function(debug) { T(xhr.status == 201); T(db.open("doc_that_was_copied").v == 1); - // move a doc - - // test error condition - var xhr = CouchDB.request("MOVE", "/test_suite_db/doc_to_be_copied", { - headers: {"Destination":"doc_that_was_moved"} - }); - T(xhr.status == 400); // bad request, MOVE requires source rev. - - var rev = db.open("doc_to_be_copied")._rev; - var xhr = CouchDB.request("MOVE", "/test_suite_db/doc_to_be_copied?rev=" + rev, { - headers: {"Destination":"doc_that_was_moved"} - }); - - T(xhr.status == 201); - T(db.open("doc_that_was_moved").v == 1); - T(db.open("doc_to_be_copied") == null); - // COPY with existing target - T(db.save({_id:"doc_to_be_copied",v:1}).ok); + T(db.save({_id:"doc_to_be_copied2",v:1}).ok); var doc = db.save({_id:"doc_to_be_overwritten",v:2}); T(doc.ok); // error condition - var xhr = CouchDB.request("COPY", "/test_suite_db/doc_to_be_copied", { + var xhr = CouchDB.request("COPY", "/test_suite_db/doc_to_be_copied2", { headers: {"Destination":"doc_to_be_overwritten"} }); T(xhr.status == 409); // conflict var rev = db.open("doc_to_be_overwritten")._rev; - var xhr = CouchDB.request("COPY", "/test_suite_db/doc_to_be_copied", { + var xhr = CouchDB.request("COPY", "/test_suite_db/doc_to_be_copied2", { headers: {"Destination":"doc_to_be_overwritten?rev=" + rev} }); T(xhr.status == 201); diff --git a/src/couchdb/couch_httpd_db.erl b/src/couchdb/couch_httpd_db.erl index 3680d73b..aa491f8c 100644 --- a/src/couchdb/couch_httpd_db.erl +++ b/src/couchdb/couch_httpd_db.erl @@ -494,33 +494,8 @@ db_doc_req(#httpd{method='COPY'}=Req, Db, SourceDocId) -> throw(Error) end; -db_doc_req(#httpd{method='MOVE'}=Req, Db, SourceDocId) -> - SourceRev = {SourceRevPos, SourceRevId} = - case extract_header_rev(Req, couch_httpd:qs_value(Req, "rev")) of - missing_rev -> - throw({bad_request, "MOVE requires a specified rev parameter" - "for the origin resource."}); - Rev -> Rev - end, - - {TargetDocId, TargetRevs} = parse_copy_destination_header(Req), - % open revision Rev or Current - Doc = couch_doc_open(Db, SourceDocId, SourceRev, []), - - % save new doc & delete old doc in one operation - Docs = [ - #doc{id=SourceDocId, revs={SourceRevPos, [SourceRevId]}, deleted=true}, - Doc#doc{id=TargetDocId, revs=TargetRevs} - ], - {ok, [SourceResult, TargetResult]} = couch_db:update_docs(Db, Docs, []), - - send_json(Req, 201, {[ - {SourceDocId, update_result_to_json(SourceResult)}, - {TargetDocId, update_result_to_json(TargetResult)} - ]}); - db_doc_req(Req, _Db, _DocId) -> - send_method_not_allowed(Req, "DELETE,GET,HEAD,POST,PUT,COPY,MOVE"). + send_method_not_allowed(Req, "DELETE,GET,HEAD,POST,PUT,COPY"). update_result_to_json({ok, NewRev}) -> {[{rev, couch_doc:rev_to_str(NewRev)}]}; |