From 17266b0581a214315ebf8ce7454ef9f73fc2a02a Mon Sep 17 00:00:00 2001 From: John Christopher Anderson Date: Sat, 21 Mar 2009 14:18:46 +0000 Subject: provide a 404 response on deletion of non-existant docs closes COUCHDB-297 git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@756948 13f79535-47bb-0310-9956-ffa450edef68 --- share/www/script/test/basics.js | 4 ++++ src/couchdb/couch_httpd_db.erl | 2 ++ 2 files changed, 6 insertions(+) diff --git a/share/www/script/test/basics.js b/share/www/script/test/basics.js index 2837b77a..06c73ddf 100644 --- a/share/www/script/test/basics.js +++ b/share/www/script/test/basics.js @@ -141,4 +141,8 @@ couchTests.basics = function(debug) { var locs = loc.split('/'); T(locs[4] == resp.id); T(locs[3] == "test_suite_db"); + + // deleting a non-existent doc should be 404 + xhr = CouchDB.request("DELETE", "/test_suite_db/doc-does-not-exist"); + T(xhr.status == 404); }; diff --git a/src/couchdb/couch_httpd_db.erl b/src/couchdb/couch_httpd_db.erl index 03fbb001..2bfc2940 100644 --- a/src/couchdb/couch_httpd_db.erl +++ b/src/couchdb/couch_httpd_db.erl @@ -423,6 +423,8 @@ all_docs_view(Req, Db, Keys) -> db_doc_req(#httpd{method='DELETE'}=Req, Db, DocId) -> + % check for the existence of the doc to handle the 404 case. + couch_doc_open(Db, DocId, nil, []), case couch_httpd:qs_value(Req, "rev") of undefined -> update_doc(Req, Db, DocId, {[{<<"_deleted">>,true}]}); -- cgit v1.2.3