Return-Path: Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: (qmail 13327 invoked from network); 30 Nov 2009 18:34:26 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 30 Nov 2009 18:34:26 -0000 Received: (qmail 404 invoked by uid 500); 30 Nov 2009 18:34:25 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 341 invoked by uid 500); 30 Nov 2009 18:34:24 -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 332 invoked by uid 99); 30 Nov 2009 18:34:24 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 30 Nov 2009 18:34:24 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 30 Nov 2009 18:34:21 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 7986223889C5; Mon, 30 Nov 2009 18:34:00 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: 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 Date: Mon, 30 Nov 2009 18:34:00 -0000 To: commits@couchdb.apache.org From: kocolosk@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20091130183400.7986223889C5@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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(