couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cml...@apache.org
Subject svn commit: r660176 - in /incubator/couchdb/trunk: share/www/script/browse.js share/www/script/couch.js share/www/script/couch_tests.js share/www/script/jquery.couch.js src/couchdb/couch_doc.erl src/couchdb/couch_httpd.erl
Date Mon, 26 May 2008 12:47:03 GMT
Author: cmlenz
Date: Mon May 26 05:47:00 2008
New Revision: 660176

URL: http://svn.apache.org/viewvc?rev=660176&view=rev
Log:
* Respond to DELETE requests with a "200 OK" status code instead of "202 Accepted", as the
deletion is performed immediately.
* The "content-type" member in attachment structures is now named "content_type" (underscore)
for consistency and to be more accessible from Javascript (and presumably other languages,
too)

Modified:
    incubator/couchdb/trunk/share/www/script/browse.js
    incubator/couchdb/trunk/share/www/script/couch.js
    incubator/couchdb/trunk/share/www/script/couch_tests.js
    incubator/couchdb/trunk/share/www/script/jquery.couch.js
    incubator/couchdb/trunk/src/couchdb/couch_doc.erl
    incubator/couchdb/trunk/src/couchdb/couch_httpd.erl

Modified: incubator/couchdb/trunk/share/www/script/browse.js
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/share/www/script/browse.js?rev=660176&r1=660175&r2=660176&view=diff
==============================================================================
--- incubator/couchdb/trunk/share/www/script/browse.js [utf-8] (original)
+++ incubator/couchdb/trunk/share/www/script/browse.js [utf-8] Mon May 26 05:47:00 2008
@@ -791,7 +791,7 @@
       .attr("href", db.uri + encodeURIComponent(docId) + "/" + encodeURIComponent(name))
       .wrapInner("<tt></tt>").appendTo(li);
     $("<span>()</span>").text("" + prettyPrintSize(attachment.length) + 
-      ", " + attachment["content-type"]).addClass("info").appendTo(li);
+      ", " + attachment.content_type).addClass("info").appendTo(li);
     _initAttachmentItem(name, attachment, li);
     return li;
   }

Modified: incubator/couchdb/trunk/share/www/script/couch.js
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/share/www/script/couch.js?rev=660176&r1=660175&r2=660176&view=diff
==============================================================================
--- incubator/couchdb/trunk/share/www/script/couch.js [utf-8] (original)
+++ incubator/couchdb/trunk/share/www/script/couch.js [utf-8] Mon May 26 05:47:00 2008
@@ -33,7 +33,7 @@
     if (req.status == 404)
       return false;
     var result = JSON.parse(req.responseText);
-    if (req.status != 202)
+    if (req.status != 200)
       throw result;
     return result;
   }
@@ -73,7 +73,7 @@
   this.deleteDoc = function(doc) {
     var req = request("DELETE", this.uri + encodeURIComponent(doc._id) + "?rev=" + doc._rev);
     var result = JSON.parse(req.responseText);
-    if (req.status != 202)
+    if (req.status != 200)
       throw result;
     doc._rev = result.rev; //record rev in input document
     doc._deleted = true;

Modified: incubator/couchdb/trunk/share/www/script/couch_tests.js
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/share/www/script/couch_tests.js?rev=660176&r1=660175&r2=660176&view=diff
==============================================================================
--- incubator/couchdb/trunk/share/www/script/couch_tests.js [utf-8] (original)
+++ incubator/couchdb/trunk/share/www/script/couch_tests.js [utf-8] Mon May 26 05:47:00 2008
@@ -388,11 +388,11 @@
     if (debug) debugger;
 
     var binAttDoc = {
-      _id:"bin_doc",
+      _id: "bin_doc",
       _attachments:{
         "foo.txt": {
-          "content-type":"text/plain",
-          "data": "VGhpcyBpcyBhIGJhc2U2NCBlbmNvZGVkIHRleHQ="
+          content_type:"text/plain",
+          data: "VGhpcyBpcyBhIGJhc2U2NCBlbmNvZGVkIHRleHQ="
         }
       }
     }
@@ -401,7 +401,7 @@
 
     var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc/foo.txt");
     T(xhr.responseText == "This is a base64 encoded text")
-    T(xhr.getResponseHeader("content-type") == "text/plain")
+    T(xhr.getResponseHeader("Content-Type") == "text/plain")
   },
 
   content_negotiation: function(debug) {
@@ -954,11 +954,11 @@
 
 
     var binAttDoc = {
-      _id:"bin_doc",
+      _id: "bin_doc",
       _attachments:{
         "foo.txt": {
-          "content-type":"text/plain",
-          "data": "VGhpcyBpcyBhIGJhc2U2NCBlbmNvZGVkIHRleHQ="
+          content_type:"text/plain",
+          data: "VGhpcyBpcyBhIGJhc2U2NCBlbmNvZGVkIHRleHQ="
         }
       }
     }
@@ -982,7 +982,7 @@
 
     var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc/foo.txt");
     T(xhr.responseText == "This is a base64 encoded text")
-    T(xhr.getResponseHeader("content-type") == "text/plain")
+    T(xhr.getResponseHeader("Content-Type") == "text/plain")
 
     var compactedsize = db.info().disk_size;
 

Modified: incubator/couchdb/trunk/share/www/script/jquery.couch.js
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/share/www/script/jquery.couch.js?rev=660176&r1=660175&r2=660176&view=diff
==============================================================================
--- incubator/couchdb/trunk/share/www/script/jquery.couch.js [utf-8] (original)
+++ incubator/couchdb/trunk/share/www/script/jquery.couch.js [utf-8] Mon May 26 05:47:00 2008
@@ -78,7 +78,7 @@
             type: "DELETE", url: this.uri, dataType: "json",
             complete: function(req) {
               var resp = $.httpData(req, "json");
-              if (req.status == 202) {
+              if (req.status == 200) {
                 if (options.success) options.success(resp);
               } else if (options.error) {
                 options.error(req.status, resp.error, resp.reason);
@@ -176,7 +176,7 @@
             dataType: "json",
             complete: function(req) {
               var resp = $.httpData(req, "json");
-              if (req.status == 202) {
+              if (req.status == 200) {
                 if (options.success) options.success(resp);
               } else if (options.error) {
                 options.error(req.status, resp.error, resp.reason);

Modified: incubator/couchdb/trunk/src/couchdb/couch_doc.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/src/couchdb/couch_doc.erl?rev=660176&r1=660175&r2=660176&view=diff
==============================================================================
--- incubator/couchdb/trunk/src/couchdb/couch_doc.erl (original)
+++ incubator/couchdb/trunk/src/couchdb/couch_doc.erl Mon May 26 05:47:00 2008
@@ -51,8 +51,10 @@
         true -> % return the full rev list and the binaries as strings.
             BinProps = lists:map(
                 fun({Name, {Type, BinValue}}) ->
-                    {Name, {obj, [{"content-type", Type},
-                                    {"data", couch_util:encodeBase64(bin_to_binary(BinValue))}]}}
+                    {Name, {obj, [
+                        {"content_type", Type},
+                        {"data", couch_util:encodeBase64(bin_to_binary(BinValue))}
+                    ]}}
                 end,
                 Doc#doc.attachments),
             case BinProps of
@@ -62,8 +64,11 @@
         false ->
             BinProps = lists:map(
                 fun({Name, {Type, BinValue}}) ->
-                    {Name, {obj, [{"stub", true}, {"content-type", Type},
-                                    {"length", bin_size(BinValue)}]}}
+                    {Name, {obj, [
+                        {"stub", true},
+                        {"content_type", Type},
+                        {"length", bin_size(BinValue)}
+                    ]}}
                 end,
                 Doc#doc.attachments),
             case BinProps of
@@ -81,7 +86,7 @@
             [{Name, stub}];
         _ ->
             Value = proplists:get_value("data", BinProps),
-            Type = proplists:get_value("content-type", BinProps,
+            Type = proplists:get_value("content_type", BinProps,
                     ?DEFAULT_ATTACHMENT_CONTENT_TYPE),
             [{Name, {Type, couch_util:decodeBase64(Value)}}]
         end

Modified: incubator/couchdb/trunk/src/couchdb/couch_httpd.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/src/couchdb/couch_httpd.erl?rev=660176&r1=660175&r2=660176&view=diff
==============================================================================
--- incubator/couchdb/trunk/src/couchdb/couch_httpd.erl (original)
+++ incubator/couchdb/trunk/src/couchdb/couch_httpd.erl Mon May 26 05:47:00 2008
@@ -164,7 +164,7 @@
 
 handle_db_request(Req, 'DELETE', {DbName, _Db, []}) ->
     ok = couch_server:delete(DbName),
-    send_json(Req, 202, {obj, [
+    send_json(Req, 200, {obj, [
         {ok, true}
     ]});
 
@@ -451,7 +451,7 @@
         throw({bad_request, "Document rev and etag have different values"})
     end,
     {ok, NewRev} = couch_db:delete_doc(Db, DocId, [RevToDelete]),
-    send_json(Req, 202, {obj, [
+    send_json(Req, 200, {obj, [
         {ok, true},
         {id, DocId},
         {rev, NewRev}



Mime
View raw message