You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ga...@apache.org on 2016/04/07 16:02:59 UTC
chttpd commit: updated refs/heads/local-docs-2978 to 1ca8642
Repository: couchdb-chttpd
Updated Branches:
refs/heads/local-docs-2978 [created] 1ca86421b
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-chttpd/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/commit/1ca86421
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/tree/1ca86421
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/diff/1ca86421
Branch: refs/heads/local-docs-2978
Commit: 1ca86421bafd17cc5b954d9075e3a053ea951f6a
Parents: cefabd0
Author: Garren Smith <ga...@gmail.com>
Authored: Thu Apr 7 15:47:05 2016 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Thu Apr 7 15:47:05 2016 +0200
----------------------------------------------------------------------
src/chttpd.erl | 4 ++--
src/chttpd_db.erl | 6 +++---
2 files changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/1ca86421/src/chttpd.erl
----------------------------------------------------------------------
diff --git a/src/chttpd.erl b/src/chttpd.erl
index 6e7682a..8400b35 100644
--- a/src/chttpd.erl
+++ b/src/chttpd.erl
@@ -621,8 +621,8 @@ json_body_obj(Httpd) ->
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|_]}}) ->
+ couch_httpd:doc_etag(Id, Body, {Start, DiskRev}).
make_etag(Term) ->
<<SigInt:128/integer>> = couch_crypto:hash(md5, term_to_binary(Term)),
http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/1ca86421/src/chttpd_db.erl
----------------------------------------------------------------------
diff --git a/src/chttpd_db.erl b/src/chttpd_db.erl
index 9aa0474..9347c1a 100644
--- a/src/chttpd_db.erl
+++ b/src/chttpd_db.erl
@@ -950,7 +950,7 @@ http_code_from_status(Status) ->
200
end.
-update_doc(Db, DocId, #doc{deleted=Deleted}=Doc, Options) ->
+update_doc(Db, DocId, #doc{deleted=Deleted, body=DocBody}=Doc, Options) ->
{_, Ref} = spawn_monitor(fun() ->
try fabric:update_doc(Db, Doc, Options) of
Resp ->
@@ -981,8 +981,7 @@ update_doc(Db, DocId, #doc{deleted=Deleted}=Doc, Options) ->
{accepted, NewRev} ->
Accepted = true
end,
- NewRevStr = couch_doc:rev_to_str(NewRev),
- Etag = <<"\"", NewRevStr/binary, "\"">>,
+ Etag = couch_httpd:doc_etag(DocId, DocBody, NewRev),
Status = case {Accepted, Deleted} of
{true, _} ->
accepted;
@@ -991,6 +990,7 @@ update_doc(Db, DocId, #doc{deleted=Deleted}=Doc, Options) ->
{false, false} ->
created
end,
+ NewRevStr = couch_doc:rev_to_str(NewRev),
Body = {[{ok, true}, {id, DocId}, {rev, NewRevStr}]},
{Status, {etag, Etag}, Body}.