You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ko...@apache.org on 2009/11/30 19:34:00 UTC
svn commit: r885529 - in /couchdb/trunk:
share/www/script/test/etags_views.js share/www/script/test/list_views.js
src/couchdb/couch_httpd_show.erl src/couchdb/couch_httpd_view.erl
Author: kocolosk
Date: Mon Nov 30 18:33:59 2009
New Revision: 885529
URL: http://svn.apache.org/viewvc?rev=885529&view=rev
Log:
ETags on POSTs to _view and _list should depend on Keys. COUCHDB-586
Modified:
couchdb/trunk/share/www/script/test/etags_views.js
couchdb/trunk/share/www/script/test/list_views.js
couchdb/trunk/src/couchdb/couch_httpd_show.erl
couchdb/trunk/src/couchdb/couch_httpd_view.erl
Modified: couchdb/trunk/share/www/script/test/etags_views.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/etags_views.js?rev=885529&r1=885528&r2=885529&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/test/etags_views.js (original)
+++ couchdb/trunk/share/www/script/test/etags_views.js Mon Nov 30 18:33:59 2009
@@ -63,6 +63,29 @@
});
T(xhr.status == 304);
+ // confirm ETag changes with different POST bodies
+ xhr = CouchDB.request("POST", "/test_suite_db/_design/etags/_view/basicView",
+ {body: JSON.stringify({keys:[1]})}
+ );
+ var etag1 = xhr.getResponseHeader("etag");
+ xhr = CouchDB.request("POST", "/test_suite_db/_design/etags/_view/basicView",
+ {body: JSON.stringify({keys:[2]})}
+ );
+ var etag2 = xhr.getResponseHeader("etag");
+ T(etag1 != etag2, "POST to map view generates key-depdendent ETags");
+
+ xhr = CouchDB.request("POST",
+ "/test_suite_db/_design/etags/_view/withReduce?group=true",
+ {body: JSON.stringify({keys:[1]})}
+ );
+ etag1 = xhr.getResponseHeader("etag");
+ xhr = CouchDB.request("POST",
+ "/test_suite_db/_design/etags/_view/withReduce?group=true",
+ {body: JSON.stringify({keys:[2]})}
+ );
+ etag2 = xhr.getResponseHeader("etag");
+ T(etag1 != etag2, "POST to reduce view generates key-depdendent ETags");
+
// all docs
xhr = CouchDB.request("GET", "/test_suite_db/_all_docs");
T(xhr.status == 200);
Modified: couchdb/trunk/share/www/script/test/list_views.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/list_views.js?rev=885529&r1=885528&r2=885529&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/test/list_views.js (original)
+++ couchdb/trunk/share/www/script/test/list_views.js Mon Nov 30 18:33:59 2009
@@ -224,6 +224,17 @@
headers: {"if-none-match": etag}
});
T(xhr.status == 304);
+
+ // confirm ETag changes with different POST bodies
+ xhr = CouchDB.request("POST", "/test_suite_db/_design/lists/_list/basicBasic/basicView",
+ {body: JSON.stringify({keys:[1]})}
+ );
+ var etag1 = xhr.getResponseHeader("etag");
+ xhr = CouchDB.request("POST", "/test_suite_db/_design/lists/_list/basicBasic/basicView",
+ {body: JSON.stringify({keys:[2]})}
+ );
+ var etag2 = xhr.getResponseHeader("etag");
+ T(etag1 != etag2, "POST to map _list generates key-depdendent ETags");
// test the richness of the arguments
xhr = CouchDB.request("GET", "/test_suite_db/_design/lists/_list/basicJSON/basicView");
@@ -310,6 +321,17 @@
});
T(xhr.status == 304);
+ // confirm ETag changes with different POST bodies
+ xhr = CouchDB.request("POST", "/test_suite_db/_design/lists/_list/simpleForm/withReduce?group=true",
+ {body: JSON.stringify({keys:[1]})}
+ );
+ var etag1 = xhr.getResponseHeader("etag");
+ xhr = CouchDB.request("POST", "/test_suite_db/_design/lists/_list/simpleForm/withReduce?group=true",
+ {body: JSON.stringify({keys:[2]})}
+ );
+ var etag2 = xhr.getResponseHeader("etag");
+ T(etag1 != etag2, "POST to reduce _list generates key-depdendent ETags");
+
// verify the etags expire correctly
var docs = makeDocs(11, 12);
db.bulkSave(docs);
Modified: couchdb/trunk/src/couchdb/couch_httpd_show.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_show.erl?rev=885529&r1=885528&r2=885529&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_httpd_show.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd_show.erl Mon Nov 30 18:33:59 2009
@@ -191,7 +191,7 @@
Headers = MReq:get(headers),
Hlist = mochiweb_headers:to_list(Headers),
Accept = proplists:get_value('Accept', Hlist),
- CurrentEtag = couch_httpd_view:view_group_etag(Group, Db, {Lang, ListSrc, Accept, UserCtx}),
+ CurrentEtag = couch_httpd_view:view_group_etag(Group, Db, {Lang, ListSrc, Accept, UserCtx, Keys}),
couch_httpd:etag_respond(Req, CurrentEtag, fun() ->
% get the os process here
% pass it into the view fold with closures
Modified: couchdb/trunk/src/couchdb/couch_httpd_view.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_view.erl?rev=885529&r1=885528&r2=885529&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_httpd_view.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd_view.erl Mon Nov 30 18:33:59 2009
@@ -202,7 +202,7 @@
skip = Skip,
group_level = GroupLevel
} = QueryArgs,
- CurrentEtag = view_group_etag(Group, Db),
+ CurrentEtag = view_group_etag(Group, Db, Keys),
couch_httpd:etag_respond(Req, CurrentEtag, fun() ->
{ok, GroupRowsFun, RespFun} = make_reduce_fold_funs(Req, GroupLevel, QueryArgs, CurrentEtag, #reduce_fold_helper_funs{}),
{Resp, _RedAcc3} = lists:foldl(