summaryrefslogtreecommitdiff
path: root/src/couch_mrview
diff options
context:
space:
mode:
authorBessenyei Balázs Donát <Balazs.Donat.Bessenyei@ibm.com>2019-12-02 12:31:35 +0100
committergarren smith <garren.smith@gmail.com>2019-12-05 14:53:07 +0200
commit4815eebe56f175db57f10dabf52fd1bce616cd29 (patch)
tree6c99a226e55fc00253a0c4e29716fd1912ad5081 /src/couch_mrview
parent87edbaecd2cdb7f9266364e5fec65e31fe1fc251 (diff)
downloadcouchdb-4815eebe56f175db57f10dabf52fd1bce616cd29.tar.gz
Allow all params to be passed via body for POST view
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.
Diffstat (limited to 'src/couch_mrview')
-rw-r--r--src/couch_mrview/src/couch_mrview_http.erl14
-rw-r--r--src/couch_mrview/src/couch_mrview_util.erl1
2 files changed, 12 insertions, 3 deletions
diff --git a/src/couch_mrview/src/couch_mrview_http.erl b/src/couch_mrview/src/couch_mrview_http.erl
index 74d5ca274..69cbb7351 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/3,
parse_params/2,
parse_params/3,
parse_params/4,
@@ -453,12 +454,21 @@ parse_params(Props, Keys, Args) ->
parse_params(Props, Keys, #mrargs{}=Args0, Options) ->
IsDecoded = lists:member(decoded, Options),
- % group_level set to undefined to detect if explicitly set by user
- Args1 = Args0#mrargs{keys=Keys, group=undefined, group_level=undefined},
+ Args1 = case lists:member(keep_group_level, Options) of
+ true ->
+ Args0;
+ _ ->
+ % group_level set to undefined to detect if explicitly set by user
+ Args0#mrargs{keys=Keys, group=undefined, group_level=undefined}
+ end,
lists:foldl(fun({K, V}, Acc) ->
parse_param(K, V, Acc, IsDecoded)
end, Args1, Props).
+parse_body_and_query(Req, {Props}, Keys) ->
+ Args = #mrargs{keys=Keys, group=undefined, group_level=undefined},
+ BodyArgs = parse_params(Props, Keys, Args, [decoded]),
+ parse_params(chttpd:qs(Req), Keys, BodyArgs, [keep_group_level]).
parse_param(Key, Val, Args, IsDecoded) when is_binary(Key) ->
parse_param(binary_to_list(Key), Val, Args, IsDecoded);
diff --git a/src/couch_mrview/src/couch_mrview_util.erl b/src/couch_mrview/src/couch_mrview_util.erl
index d0d2b3949..e971720c9 100644
--- a/src/couch_mrview/src/couch_mrview_util.erl
+++ b/src/couch_mrview/src/couch_mrview_util.erl
@@ -1152,7 +1152,6 @@ extract_view_reduce({red, {N, _Lang, #mrview{reduce_funs=Reds}}, _Ref}) ->
get_view_keys({Props}) ->
case couch_util:get_value(<<"keys">>, Props) of
undefined ->
- couch_log:debug("POST with no keys member.", []),
undefined;
Keys when is_list(Keys) ->
Keys;