diff options
author | John Christopher Anderson <jchris@apache.org> | 2009-07-10 01:17:15 +0000 |
---|---|---|
committer | John Christopher Anderson <jchris@apache.org> | 2009-07-10 01:17:15 +0000 |
commit | b67a4ec21fed0942cfeba1662eb6e00f3f3a570c (patch) | |
tree | b0f9422b6da1476a0662840608418dbe92a08872 /src | |
parent | 9ccb235a2d58d6b7caf406952f18ca13d9889f3e (diff) |
fix attachment etags, thanks Mark Hammond for the test case. closes COUCHDB-386
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@792774 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r-- | src/couchdb/couch_httpd_db.erl | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/src/couchdb/couch_httpd_db.erl b/src/couchdb/couch_httpd_db.erl index fcbdc4c6..3b5fcbe8 100644 --- a/src/couchdb/couch_httpd_db.erl +++ b/src/couchdb/couch_httpd_db.erl @@ -774,19 +774,22 @@ db_attachment_req(#httpd{method='GET'}=Req, Db, DocId, FileNameParts) -> undefined -> throw({not_found, "Document is missing attachment"}); {Type, Bin} -> - {ok, Resp} = start_chunked_response(Req, 200, [ - {"ETag", couch_httpd:doc_etag(Doc)}, - {"Cache-Control", "must-revalidate"}, - {"Content-Type", 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. - % {"Content-Length", integer_to_list(couch_doc:bin_size(Bin))} - ]), - couch_doc:bin_foldl(Bin, - fun(BinSegment, _) -> send_chunk(Resp, BinSegment) end,[]), - send_chunk(Resp, "") + Etag = couch_httpd:doc_etag(Doc), + couch_httpd:etag_respond(Req, Etag, fun() -> + {ok, Resp} = start_chunked_response(Req, 200, [ + {"ETag", Etag}, + {"Cache-Control", "must-revalidate"}, + {"Content-Type", 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. + % {"Content-Length", integer_to_list(couch_doc:bin_size(Bin))} + ]), + couch_doc:bin_foldl(Bin, + fun(BinSegment, _) -> send_chunk(Resp, BinSegment) end,[]), + send_chunk(Resp, "") + end) end; |