couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject chttpd commit: updated refs/heads/master to ab80f31
Date Sun, 19 Apr 2015 09:44:30 GMT
Repository: couchdb-chttpd
Updated Branches:
  refs/heads/master 2f5365260 -> ab80f3131


Use attachment checksum as Etag if possible

Fixes COUCHDB-2668

Originally fixed in COUCHDB-1337


Project: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/commit/ab80f313
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/tree/ab80f313
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/diff/ab80f313

Branch: refs/heads/master
Commit: ab80f3131e244af967e2d162925ee45008d54a50
Parents: 2f53652
Author: Robert Newson <rnewson@apache.org>
Authored: Sun Apr 19 10:41:14 2015 +0100
Committer: Robert Newson <rnewson@apache.org>
Committed: Sun Apr 19 10:43:30 2015 +0100

----------------------------------------------------------------------
 src/chttpd_db.erl | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/ab80f313/src/chttpd_db.erl
----------------------------------------------------------------------
diff --git a/src/chttpd_db.erl b/src/chttpd_db.erl
index ab0b8b0..27fa745 100644
--- a/src/chttpd_db.erl
+++ b/src/chttpd_db.erl
@@ -1011,10 +1011,13 @@ db_attachment_req(#httpd{method='GET',mochi_req=MochiReq}=Req, Db,
DocId, FileNa
     [] ->
         throw({not_found, "Document is missing attachment"});
     [Att] ->
-        [Type, Enc, DiskLen, AttLen] = couch_att:fetch([type, encoding, disk_len, att_len],
Att),
+        [Type, Enc, DiskLen, AttLen, Md5] = couch_att:fetch([type, encoding, disk_len, att_len,
md5], Att),
         Refs = monitor_attachments(Att),
         try
-        Etag = chttpd:doc_etag(Doc),
+        Etag = case Md5 of
+            <<>> -> chttpd:doc_etag(Doc);
+            _ -> "\"" ++ ?b2l(base64:encode(Md5)) ++ "\""
+        end,
         ReqAcceptsAttEnc = lists:member(
            atom_to_list(Enc),
            couch_httpd:accepted_encodings(Req)


Mime
View raw message