summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--share/www/script/couch_tests.js4
-rw-r--r--src/couchdb/couch_httpd_db.erl3
2 files changed, 5 insertions, 2 deletions
diff --git a/share/www/script/couch_tests.js b/share/www/script/couch_tests.js
index 8a00dc93..1eb1836e 100644
--- a/share/www/script/couch_tests.js
+++ b/share/www/script/couch_tests.js
@@ -795,11 +795,13 @@ var tests = {
}
}
- T(db.save(binAttDoc).ok);
+ var save_response = db.save(binAttDoc);
+ T(save_response.ok);
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("Etag") == save_response.rev);
// empty attachment
var binAttDoc2 = {
diff --git a/src/couchdb/couch_httpd_db.erl b/src/couchdb/couch_httpd_db.erl
index 16956a86..eb41801f 100644
--- a/src/couchdb/couch_httpd_db.erl
+++ b/src/couchdb/couch_httpd_db.erl
@@ -513,12 +513,13 @@ couch_doc_open(Db, DocId, Rev, Options) ->
db_attachment_req(#httpd{method='GET'}=Req, Db, DocId, FileNameParts) ->
FileName = list_to_binary(mochiweb_util:join(lists:map(fun binary_to_list/1, FileNameParts),"/")),
case couch_db:open_doc(Db, DocId, []) of
- {ok, #doc{attachments=Attachments}} ->
+ {ok, #doc{attachments=Attachments, revs=[LastRev|_OldRevs]}} ->
case proplists:get_value(FileName, Attachments) of
undefined ->
throw({not_found, "Document is missing attachment"});
{Type, Bin} ->
{ok, Resp} = start_chunked_response(Req, 200, [
+ {"ETag", binary_to_list(LastRev)},
{"Cache-Control", "must-revalidate"},
{"Content-Type", binary_to_list(Type)}%,
% My understanding of http://www.faqs.org/rfcs/rfc2616.html