From commits-return-25958-apmail-couchdb-commits-archive=couchdb.apache.org@couchdb.apache.org Thu Apr 7 14:08:07 2016 Return-Path: X-Original-To: apmail-couchdb-commits-archive@www.apache.org Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 48BB0190D4 for ; Thu, 7 Apr 2016 14:08:07 +0000 (UTC) Received: (qmail 97147 invoked by uid 500); 7 Apr 2016 14:08:07 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 97102 invoked by uid 500); 7 Apr 2016 14:08:07 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 97093 invoked by uid 99); 7 Apr 2016 14:08:07 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Apr 2016 14:08:07 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id F3E47DFC73; Thu, 7 Apr 2016 14:08:06 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: garren@apache.org To: commits@couchdb.apache.org Message-Id: <264f82f095b84d32a89260145d9801ec@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: couch commit: updated refs/heads/local-docs-2978 to 50722ae Date: Thu, 7 Apr 2016 14:08:06 +0000 (UTC) Repository: couchdb-couch Updated Branches: refs/heads/local-docs-2978 [created] 50722ae6f Create md5 etag for _local docs This makes a unique ETAG for _local docs, so that they are cached correctly, and fetched again when the document changes. fixes COUCHDB-2978 Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/50722ae6 Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/50722ae6 Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/50722ae6 Branch: refs/heads/local-docs-2978 Commit: 50722ae6f3263a06c07550c29392966088c0336c Parents: c256ef5 Author: Garren Smith Authored: Thu Apr 7 16:06:31 2016 +0200 Committer: Garren Smith Committed: Thu Apr 7 16:06:31 2016 +0200 ---------------------------------------------------------------------- src/couch_httpd.erl | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/50722ae6/src/couch_httpd.erl ---------------------------------------------------------------------- diff --git a/src/couch_httpd.erl b/src/couch_httpd.erl index 7370594..c4f5a9c 100644 --- a/src/couch_httpd.erl +++ b/src/couch_httpd.erl @@ -21,7 +21,7 @@ -export([make_fun_spec_strs/1]). -export([make_arity_1_fun/1, make_arity_2_fun/1, make_arity_3_fun/1]). -export([parse_form/1,json_body/1,json_body_obj/1,body/1]). --export([doc_etag/1, make_etag/1, etag_match/2, etag_respond/3, etag_maybe/2]). +-export([doc_etag/1, doc_etag/3, make_etag/1, etag_match/2, etag_respond/3, etag_maybe/2]). -export([primary_header_value/2,partition/1,serve_file/3,serve_file/4, server_header/0]). -export([start_chunked_response/3,send_chunk/2,log_request/2]). -export([start_response_length/4, start_response/3, send/2]). @@ -594,8 +594,17 @@ maybe_decompress(Httpd, Body) -> throw({bad_ctype, [Else, " is not a supported content encoding."]}) end. -doc_etag(#doc{revs={Start, [DiskRev|_]}}) -> - "\"" ++ ?b2l(couch_doc:rev_to_str({Start, DiskRev})) ++ "\"". +doc_etag(#doc{id=Id, body=Body, revs={Start, [DiskRev|_]}}) -> + doc_etag(Id, Body, {Start, DiskRev}). + +doc_etag(<<"_local/", _/binary>>, Body, {Start, DiskRev}) -> + make_etag({Start, DiskRev, Body}); +doc_etag(_Id, _Body, {Start, DiskRev}) -> + rev_etag({Start, DiskRev}). + +rev_etag({Start, DiskRev}) -> + Rev = couch_doc:rev_to_str({Start, DiskRev}), + <<$", Rev/binary, $">>. make_etag(Term) -> <> = couch_crypto:hash(md5, term_to_binary(Term)),