summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Christopher Anderson <jchris@apache.org>2009-02-13 18:33:16 +0000
committerJohn Christopher Anderson <jchris@apache.org>2009-02-13 18:33:16 +0000
commiteb81ff32d07cb8cbe1a13a495a2aabd968313821 (patch)
tree191539e4bc0bc62e6221b6c11a6368a8309f9a4b
parent9b2e6ed37184709e70def81d53246a9fe58f18ba (diff)
Apply COUCHDB-251.
Allow _list functions to accept arbitrary GET parameters. Thanks Paul Davis. git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@744210 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--share/www/script/couch_tests.js8
-rw-r--r--src/couchdb/couch_httpd_show.erl2
-rw-r--r--src/couchdb/couch_httpd_view.erl15
3 files changed, 20 insertions, 5 deletions
diff --git a/share/www/script/couch_tests.js b/share/www/script/couch_tests.js
index e9594918..bc4e067a 100644
--- a/share/www/script/couch_tests.js
+++ b/share/www/script/couch_tests.js
@@ -2795,6 +2795,10 @@ db.createDb();
}
}
})
+ }),
+ qsParams: stringFun(function(head, row, req, row_number) {
+ if(head) return {body: req.query.foo};
+ else return {body: "\n"};
})
}
};
@@ -2862,6 +2866,10 @@ db.createDb();
T(xhr.getResponseHeader("Content-Type") == "application/xml");
T(xhr.responseText.match(/XML/));
T(xhr.responseText.match(/entry/));
+
+ // now with extra qs params
+ xhr = CouchDB.request("GET", "/test_suite_db/_list/lists/qsParams/basicView?foo=blam");
+ T(xhr.responseText.match(/blam/));
},
compact: function(debug) {
diff --git a/src/couchdb/couch_httpd_show.erl b/src/couchdb/couch_httpd_show.erl
index f724098a..2771a1c9 100644
--- a/src/couchdb/couch_httpd_show.erl
+++ b/src/couchdb/couch_httpd_show.erl
@@ -75,7 +75,7 @@ send_view_list_response(Lang, ListSrc, ViewName, DesignId, Req, Db) ->
#view_query_args{
stale = Stale,
reduce = Reduce
- } = QueryArgs = couch_httpd_view:parse_view_query(Req),
+ } = QueryArgs = couch_httpd_view:parse_view_query(Req, nil, nil, true),
case couch_view:get_map_view(Db, DesignId, ViewName, Stale) of
{ok, View} ->
output_map_list(Req, Lang, ListSrc, View, Db, QueryArgs);
diff --git a/src/couchdb/couch_httpd_view.erl b/src/couchdb/couch_httpd_view.erl
index 7666da98..7696bb0d 100644
--- a/src/couchdb/couch_httpd_view.erl
+++ b/src/couchdb/couch_httpd_view.erl
@@ -15,7 +15,7 @@
-export([handle_view_req/2,handle_temp_view_req/2]).
--export([parse_view_query/1,parse_view_query/2,make_view_fold_fun/5,
+-export([parse_view_query/1,parse_view_query/2,parse_view_query/4,make_view_fold_fun/5,
finish_view_fold/3, view_row_obj/3]).
-import(couch_httpd,
@@ -210,6 +210,8 @@ parse_view_query(Req) ->
parse_view_query(Req, Keys) ->
parse_view_query(Req, Keys, nil).
parse_view_query(Req, Keys, IsReduce) ->
+ parse_view_query(Req, Keys, IsReduce, false).
+parse_view_query(Req, Keys, IsReduce, IgnoreExtra) ->
QueryList = couch_httpd:qs(Req),
#view_query_args{
group_level = GroupLevel
@@ -332,9 +334,14 @@ parse_view_query(Req, Keys, IsReduce) ->
% we just ignore format, so that JS can have it
Args;
_ -> % unknown key
- Msg = lists:flatten(io_lib:format(
- "Bad URL query key:~s", [Key])),
- throw({query_parse_error, Msg})
+ case IgnoreExtra of
+ true ->
+ Args;
+ false ->
+ Msg = lists:flatten(io_lib:format(
+ "Bad URL query key:~s", [Key])),
+ throw({query_parse_error, Msg})
+ end
end
end, #view_query_args{}, QueryList),
case IsReduce of