Skip to content

Commit

Permalink
COUCHDB-1537 Include user_ctx.name in show/list ETag
Browse files Browse the repository at this point in the history
  • Loading branch information
rnewson committed Sep 28, 2012
1 parent 03598c2 commit ac32047
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES
Expand Up @@ -20,6 +20,7 @@ HTTP Interface:
* Added Server-Sent Events protocol to db changes API. * Added Server-Sent Events protocol to db changes API.
See http://www.w3.org/TR/eventsource/ for details. See http://www.w3.org/TR/eventsource/ for details.
* Make password hashing synchronous when using the /_config/admins API. * Make password hashing synchronous when using the /_config/admins API.
* Include user name in show/list ETags.


Storage System: Storage System:


Expand Down
1 change: 1 addition & 0 deletions NEWS
Expand Up @@ -24,6 +24,7 @@ This version has not been released yet.
* Make password hashing synchronous when using the /_config/admins API. * Make password hashing synchronous when using the /_config/admins API.
* Added utc_id UUID algorithm. * Added utc_id UUID algorithm.
* encode database name during URL rewriting. * encode database name during URL rewriting.
* Include user name in show/list ETags.


Version 1.2.1 Version 1.2.1
------------- -------------
Expand Down
5 changes: 3 additions & 2 deletions src/couch_mrview/src/couch_mrview_show.erl
Expand Up @@ -99,7 +99,7 @@ show_etag(#httpd{user_ctx=UserCtx}=Req, Doc, DDoc, More) ->
Doc -> couch_httpd:doc_etag(Doc) Doc -> couch_httpd:doc_etag(Doc)
end, end,
couch_httpd:make_etag({couch_httpd:doc_etag(DDoc), DocPart, Accept, couch_httpd:make_etag({couch_httpd:doc_etag(DDoc), DocPart, Accept,
UserCtx#user_ctx.roles, More}). {UserCtx#user_ctx.name, UserCtx#user_ctx.roles}, More}).


% updates a doc based on a request % updates a doc based on a request
% handle_doc_update_req(#httpd{method = 'GET'}=Req, _Db, _DDoc) -> % handle_doc_update_req(#httpd{method = 'GET'}=Req, _Db, _DDoc) ->
Expand Down Expand Up @@ -191,9 +191,10 @@ handle_view_list(Req, Db, DDoc, LName, VDDoc, VName, Keys) ->
Args0 = couch_mrview_http:parse_qs(Req, Keys), Args0 = couch_mrview_http:parse_qs(Req, Keys),
ETagFun = fun(BaseSig, Acc0) -> ETagFun = fun(BaseSig, Acc0) ->
UserCtx = Req#httpd.user_ctx, UserCtx = Req#httpd.user_ctx,
Name = UserCtx#user_ctx.name,
Roles = UserCtx#user_ctx.roles, Roles = UserCtx#user_ctx.roles,
Accept = couch_httpd:header_value(Req, "Accept"), Accept = couch_httpd:header_value(Req, "Accept"),
Parts = {couch_httpd:doc_etag(DDoc), Accept, Roles}, Parts = {couch_httpd:doc_etag(DDoc), Accept, {Name, Roles}},
ETag = couch_httpd:make_etag({BaseSig, Parts}), ETag = couch_httpd:make_etag({BaseSig, Parts}),
case couch_httpd:etag_match(Req, ETag) of case couch_httpd:etag_match(Req, ETag) of
true -> throw({etag_match, ETag}); true -> throw({etag_match, ETag});
Expand Down

0 comments on commit ac32047

Please sign in to comment.