<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -202,4 +202,13 @@ couchTests.attachments= function(debug) {
   var doc = db.open(&quot;bin_doc5&quot;, {attachments:true});
   T(doc._attachments[&quot;lorem.txt&quot;].data == lorem_b64);
 
+  // test etags for attachments.
+  var xhr = CouchDB.request(&quot;GET&quot;, &quot;/test_suite_db/bin_doc5/lorem.txt&quot;);
+  T(xhr.status == 200);
+  var etag = xhr.getResponseHeader(&quot;etag&quot;);
+  console.log(etag)
+  xhr = CouchDB.request(&quot;GET&quot;, &quot;/test_suite_db/bin_doc5/lorem.txt&quot;, {
+    headers: {&quot;if-none-match&quot;: etag}
+  });
+  T(xhr.status == 304);
 };</diff>
      <filename>share/www/script/test/attachments.js</filename>
    </modified>
    <modified>
      <diff>@@ -774,19 +774,22 @@ db_attachment_req(#httpd{method='GET'}=Req, Db, DocId, FileNameParts) -&gt;
     undefined -&gt;
         throw({not_found, &quot;Document is missing attachment&quot;});
     {Type, Bin} -&gt;
-        {ok, Resp} = start_chunked_response(Req, 200, [
-            {&quot;ETag&quot;, couch_httpd:doc_etag(Doc)},
-            {&quot;Cache-Control&quot;, &quot;must-revalidate&quot;},
-            {&quot;Content-Type&quot;, binary_to_list(Type)}%,
-            % My understanding of http://www.faqs.org/rfcs/rfc2616.html
-            % says that we should not use Content-Length with a chunked
-            % encoding. Turning this off makes libcurl happy, but I am
-            % open to discussion.
-            % {&quot;Content-Length&quot;, integer_to_list(couch_doc:bin_size(Bin))}
-            ]),
-        couch_doc:bin_foldl(Bin,
-                fun(BinSegment, _) -&gt; send_chunk(Resp, BinSegment) end,[]),
-        send_chunk(Resp, &quot;&quot;)
+        Etag = couch_httpd:doc_etag(Doc),
+        couch_httpd:etag_respond(Req, Etag, fun() -&gt;
+            {ok, Resp} = start_chunked_response(Req, 200, [
+                {&quot;ETag&quot;, Etag},
+                {&quot;Cache-Control&quot;, &quot;must-revalidate&quot;},
+                {&quot;Content-Type&quot;, binary_to_list(Type)}%,
+                % My understanding of http://www.faqs.org/rfcs/rfc2616.html
+                % says that we should not use Content-Length with a chunked
+                % encoding. Turning this off makes libcurl happy, but I am
+                % open to discussion. 
+                % {&quot;Content-Length&quot;, integer_to_list(couch_doc:bin_size(Bin))}
+                ]),
+            couch_doc:bin_foldl(Bin,
+                    fun(BinSegment, _) -&gt; send_chunk(Resp, BinSegment) end,[]),
+            send_chunk(Resp, &quot;&quot;)
+        end)
     end;
 
 </diff>
      <filename>src/couchdb/couch_httpd_db.erl</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>c3b964accf803e3fe48b45cea39a5c7d5ed2ad95</id>
    </parent>
  </parents>
  <author>
    <name>jchris</name>
    <email>jchris@13f79535-47bb-0310-9956-ffa450edef68</email>
  </author>
  <url>http://github.com/halorgium/couchdb/commit/231b7396243c84656c9080adfde22313682dd7ac</url>
  <id>231b7396243c84656c9080adfde22313682dd7ac</id>
  <committed-date>2009-07-09T18:17:15-07:00</committed-date>
  <authored-date>2009-07-09T18:17:15-07:00</authored-date>
  <message>fix attachment etags, thanks Mark Hammond for the test case. closes COUCHDB-386

git-svn-id: http://svn.apache.org/repos/asf/couchdb/trunk@792774 13f79535-47bb-0310-9956-ffa450edef68</message>
  <tree>b0f9422b6da1476a0662840608418dbe92a08872</tree>
  <committer>
    <name>jchris</name>
    <email>jchris@13f79535-47bb-0310-9956-ffa450edef68</email>
  </committer>
</commit>
