couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject svn commit: r1128111 - in /couchdb/branches/1.0.x: share/www/script/test/attachments.js src/couchdb/couch_httpd_db.erl
Date Thu, 26 May 2011 22:27:36 GMT
Author: rnewson
Date: Thu May 26 22:27:36 2011
New Revision: 1128111

URL: http://svn.apache.org/viewvc?rev=1128111&view=rev
Log:
COUCHDB-1173 - return Content-MD5 when fetching attachments where possible.

Conflicts:

	src/couchdb/couch_httpd_db.erl

Modified:
    couchdb/branches/1.0.x/share/www/script/test/attachments.js
    couchdb/branches/1.0.x/src/couchdb/couch_httpd_db.erl

Modified: couchdb/branches/1.0.x/share/www/script/test/attachments.js
URL: http://svn.apache.org/viewvc/couchdb/branches/1.0.x/share/www/script/test/attachments.js?rev=1128111&r1=1128110&r2=1128111&view=diff
==============================================================================
--- couchdb/branches/1.0.x/share/www/script/test/attachments.js (original)
+++ couchdb/branches/1.0.x/share/www/script/test/attachments.js Thu May 26 22:27:36 2011
@@ -270,4 +270,17 @@ couchTests.attachments= function(debug) 
   } catch (e) {
       T(e.error == "missing_stub");
   }
+
+  // test MD5 header
+  var bin_data = "foo bar"
+  var xhr = CouchDB.request("PUT", "/test_suite_db/bin_doc7/attachment.txt", {
+    headers:{"Content-Type":"application/octet-stream",
+             "Content-MD5":"MntvB0NYESObxH4VRDUycw=="},
+    body:bin_data
+  });
+  TEquals(201, xhr.status);
+
+  var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc7/attachment.txt");
+  TEquals('MntvB0NYESObxH4VRDUycw==', xhr.getResponseHeader("Content-MD5"));
+
 };

Modified: couchdb/branches/1.0.x/src/couchdb/couch_httpd_db.erl
URL: http://svn.apache.org/viewvc/couchdb/branches/1.0.x/src/couchdb/couch_httpd_db.erl?rev=1128111&r1=1128110&r2=1128111&view=diff
==============================================================================
--- couchdb/branches/1.0.x/src/couchdb/couch_httpd_db.erl (original)
+++ couchdb/branches/1.0.x/src/couchdb/couch_httpd_db.erl Thu May 26 22:27:36 2011
@@ -928,6 +928,11 @@ db_attachment_req(#httpd{method='GET'}=R
             [{"Content-Encoding", atom_to_list(Enc)}];
         _ ->
             []
+        end ++ if
+            Enc =:= identity orelse ReqAcceptsAttEnc =:= true ->
+                [{"Content-MD5", base64:encode(Att#att.md5)}];
+            true ->
+                []
         end,
         Len = case {Enc, ReqAcceptsAttEnc} of
         {identity, _} ->



Mime
View raw message