couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r729992 - in /couchdb/trunk: share/www/script/couch_tests.js src/couchdb/couch_httpd_db.erl
Date Mon, 29 Dec 2008 20:14:37 GMT
Author: jan
Date: Mon Dec 29 12:14:37 2008
New Revision: 729992

URL: http://svn.apache.org/viewvc?rev=729992&view=rev
Log:
add etags to standalone attachment requests. Closes COUCHDB-184

Modified:
    couchdb/trunk/share/www/script/couch_tests.js
    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=729992&r1=729991&r2=729992&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/couch_tests.js [utf-8] (original)
+++ couchdb/trunk/share/www/script/couch_tests.js [utf-8] Mon Dec 29 12:14:37 2008
@@ -795,11 +795,13 @@
       }
     }
 
-    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 = {

Modified: couchdb/trunk/src/couchdb/couch_httpd_db.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_db.erl?rev=729992&r1=729991&r2=729992&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_httpd_db.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd_db.erl Mon Dec 29 12:14:37 2008
@@ -513,12 +513,13 @@
 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



Mime
View raw message