couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jch...@apache.org
Subject svn commit: r739157 - in /couchdb/trunk: share/www/script/couch_tests.js src/couchdb/couch_httpd.erl src/couchdb/couch_httpd_db.erl
Date Fri, 30 Jan 2009 03:50:44 GMT
Author: jchris
Date: Fri Jan 30 03:50:44 2009
New Revision: 739157

URL: http://svn.apache.org/viewvc?rev=739157&view=rev
Log:
swap 412 ad 409 error codes. fixes COUCHDB-226

Modified:
    couchdb/trunk/share/www/script/couch_tests.js
    couchdb/trunk/src/couchdb/couch_httpd.erl
    couchdb/trunk/src/couchdb/couch_httpd_db.erl

Modified: couchdb/trunk/share/www/script/couch_tests.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/couch_tests.js?rev=739157&r1=739156&r2=739157&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/couch_tests.js [utf-8] (original)
+++ couchdb/trunk/share/www/script/couch_tests.js [utf-8] Fri Jan 30 03:50:44 2009
@@ -34,9 +34,9 @@
     
     db.createDb();
 
-    // PUT on existing DB should return 409 instead of 500
+    // PUT on existing DB should return 412 instead of 500
     xhr = CouchDB.request("PUT", "/test_suite_db/");
-    T(xhr.status == 409);
+    T(xhr.status == 412);
     if (debug) debugger;
 
     // Get the database info, check the db_name
@@ -443,7 +443,7 @@
     var xhr = CouchDB.request("COPY", "/test_suite_db/doc_to_be_copied", {
         headers: {"Destination":"doc_to_be_overwritten"}
     });
-    T(xhr.status == 412); // conflict
+    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", {
@@ -958,7 +958,7 @@
     
     // test without rev, should fail
     var xhr = CouchDB.request("DELETE", "/test_suite_db/bin_doc2/foo2.txt");
-    T(xhr.status == 412);
+    T(xhr.status == 409);
 
     // test with rev, should not fail
     var xhr = CouchDB.request("DELETE", "/test_suite_db/bin_doc2/foo2.txt?rev=" + rev);
@@ -982,7 +982,7 @@
       headers:{"Content-Type":"text/plain;charset=utf-8"},
       body:bin_data
     });
-    T(xhr.status == 412);
+    T(xhr.status == 409);
 
     var xhr = CouchDB.request("PUT", "/test_suite_db/bin_doc3/attachment.txt?rev=" + rev,
{
       headers:{"Content-Type":"text/plain;charset=utf-8"},
@@ -1079,7 +1079,7 @@
         headers:{"Content-Type":"text/plain;charset=utf-8"},
         body:"Just some text"
       });
-      T(xhr.status == 412);    
+      T(xhr.status == 409);    
 
       var xhr = CouchDB.request("PUT", "/"+dbName+"/bin_doc/foo/bar2.txt?rev=" + binAttDoc._rev,
{
         body:"This is no base64 encoded text",
@@ -1148,7 +1148,7 @@
         headers:{"Content-Type":"text/plain;charset=utf-8"},
         body:"Just some text"
       });
-      T(xhr.status == 412);    
+      T(xhr.status == 409);    
 
       var xhr = CouchDB.request("PUT", "/"+dbName+"/_design%2Fbin_doc/foo/bar2.txt?rev="
+ binAttDoc._rev, {
         body:"This is no base64 encoded text",
@@ -2292,7 +2292,7 @@
     xhr = CouchDB.request("PUT", "/test_suite_db/1", {
       body: "{}"
     });
-    T(xhr.status == 412)
+    T(xhr.status == 409)
 
     // verify get w/Etag
     xhr = CouchDB.request("GET", "/test_suite_db/1", {
@@ -2308,7 +2308,7 @@
     xhr = CouchDB.request("DELETE", "/test_suite_db/1", {
       headers: {"if-match": etagOld}
     });
-    T(xhr.status == 412);
+    T(xhr.status == 409);
 
     //now do it for real
     xhr = CouchDB.request("DELETE", "/test_suite_db/1", {

Modified: couchdb/trunk/src/couchdb/couch_httpd.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd.erl?rev=739157&r1=739156&r2=739157&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_httpd.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd.erl Fri Jan 30 03:50:44 2009
@@ -371,7 +371,7 @@
 send_error(Req, {not_found, Reason}) ->
     send_error(Req, 404, <<"not_found">>, Reason);
 send_error(Req, conflict) ->
-    send_error(Req, 412, <<"conflict">>, <<"Document update conflict.">>);
+    send_error(Req, 409, <<"conflict">>, <<"Document update conflict.">>);
 send_error(Req, {forbidden, Msg}) ->
     send_json(Req, 403,
         {[{<<"error">>,  <<"forbidden">>},
@@ -397,7 +397,7 @@
         {[{<<"error">>, proplists:get_value(<<"error">>, Props)},
             {<<"reason">>, proplists:get_value(<<"reason">>, Props)}]});
 send_error(Req, file_exists) ->
-    send_error(Req, 409, <<"file_exists">>, <<"The database could not be
"
+    send_error(Req, 412, <<"file_exists">>, <<"The database could not be
"
         "created, the file already exists.">>);
 send_error(Req, {Error, Reason}) ->
     send_error(Req, 500, Error, Reason);

Modified: couchdb/trunk/src/couchdb/couch_httpd_db.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_db.erl?rev=739157&r1=739156&r2=739157&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_httpd_db.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd_db.erl Fri Jan 30 03:50:44 2009
@@ -369,7 +369,7 @@
 db_doc_req(#httpd{method='DELETE'}=Req, Db, DocId) ->
     case extract_header_rev(Req, couch_httpd:qs_value(Req, "rev")) of
     missing_rev ->
-        couch_httpd:send_error(Req, 412, <<"missing_rev">>,
+        couch_httpd:send_error(Req, 409, <<"missing_rev">>,
             <<"Document rev/etag must be specified to delete">>);
     RevToDelete ->
         {ok, NewRev} = couch_db:delete_doc(Db, DocId, [RevToDelete]),



Mime
View raw message