summaryrefslogtreecommitdiff
path: root/src/couch_mrview
diff options
context:
space:
mode:
authorBessenyei Balázs Donát <bessbd@apache.org>2019-12-05 10:29:59 +0100
committergarren smith <garren.smith@gmail.com>2019-12-09 15:07:39 +0200
commit8ac108adcf7dfa2e9223de1568b71780938b57de (patch)
tree751c3ec0a7c630e6401135df26fedf59fec54fdc /src/couch_mrview
parent4815eebe56f175db57f10dabf52fd1bce616cd29 (diff)
downloadcouchdb-8ac108adcf7dfa2e9223de1568b71780938b57de.tar.gz
Allow all params to be passed via body for POST _all_docs
This change should allow users to supply all params in POST that can be supplied for GET now. This way we could avoid the ?key="foo" things that would probably cause a lot of pain for users. As /{db}/_design_docs and /{db}/_local_docs are analogous to _all_docs, this change applies to all three of them.
Diffstat (limited to 'src/couch_mrview')
-rw-r--r--src/couch_mrview/src/couch_mrview_http.erl12
-rw-r--r--src/couch_mrview/src/couch_mrview_show.erl2
2 files changed, 12 insertions, 2 deletions
diff --git a/src/couch_mrview/src/couch_mrview_http.erl b/src/couch_mrview/src/couch_mrview_http.erl
index 69cbb7351..3cf8833d7 100644
--- a/src/couch_mrview/src/couch_mrview_http.erl
+++ b/src/couch_mrview/src/couch_mrview_http.erl
@@ -29,6 +29,7 @@
parse_int/1,
parse_pos_int/1,
prepend_val/1,
+ parse_body_and_query/2,
parse_body_and_query/3,
parse_params/2,
parse_params/3,
@@ -209,7 +210,7 @@ is_public_fields_configured(Db) ->
end.
do_all_docs_req(Req, Db, Keys, NS) ->
- Args0 = parse_params(Req, Keys),
+ Args0 = couch_mrview_http:parse_body_and_query(Req, Keys),
Args1 = set_namespace(NS, Args0),
ETagFun = fun(Sig, Acc0) ->
check_view_etag(Sig, Acc0, Req)
@@ -465,6 +466,15 @@ parse_params(Props, Keys, #mrargs{}=Args0, Options) ->
parse_param(K, V, Acc, IsDecoded)
end, Args1, Props).
+
+parse_body_and_query(#httpd{method='POST'} = Req, Keys) ->
+ Props = chttpd:json_body_obj(Req),
+ parse_body_and_query(Req, Props, Keys);
+
+parse_body_and_query(Req, Keys) ->
+ parse_params(chttpd:qs(Req), Keys, #mrargs{keys=Keys, group=undefined,
+ group_level=undefined}, [keep_group_level]).
+
parse_body_and_query(Req, {Props}, Keys) ->
Args = #mrargs{keys=Keys, group=undefined, group_level=undefined},
BodyArgs = parse_params(Props, Keys, Args, [decoded]),
diff --git a/src/couch_mrview/src/couch_mrview_show.erl b/src/couch_mrview/src/couch_mrview_show.erl
index c9be5b063..9056907fa 100644
--- a/src/couch_mrview/src/couch_mrview_show.erl
+++ b/src/couch_mrview/src/couch_mrview_show.erl
@@ -181,7 +181,7 @@ handle_view_list_req(Req, _Db, _DDoc) ->
handle_view_list(Req, Db, DDoc, LName, VDDoc, VName, Keys) ->
- Args0 = couch_mrview_http:parse_params(Req, Keys),
+ Args0 = couch_mrview_http:parse_body_and_query(Req, Keys),
ETagFun = fun(BaseSig, Acc0) ->
UserCtx = Req#httpd.user_ctx,
Name = UserCtx#user_ctx.name,