From e9c2571947b21f8a5ba4da5ed52ab4f7d0a3b395 Mon Sep 17 00:00:00 2001 From: Adam Kocoloski Date: Wed, 9 Jun 2010 16:46:22 -0400 Subject: minor fixes to _all_docs with keys --- src/chttpd_db.erl | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/chttpd_db.erl b/src/chttpd_db.erl index 50adc276..dead8a9b 100644 --- a/src/chttpd_db.erl +++ b/src/chttpd_db.erl @@ -297,13 +297,12 @@ db_req(#httpd{method='GET',path_parts=[_,<<"_all_docs">>]}=Req, Db) -> db_req(#httpd{method='POST',path_parts=[_,<<"_all_docs">>]}=Req, Db) -> {Fields} = chttpd:json_body_obj(Req), - Keys = couch_util:get_value(<<"keys">>, Fields, nil), - case Keys of - Keys when is_list(Keys) -> ok; - nil -> ?LOG_DEBUG("POST to _all_docs with no keys member.", []); - _ -> throw({bad_request, "`keys` member must be a array."}) - end, - all_docs_view(Req, Db, Keys); + case couch_util:get_value(<<"keys">>, Fields) of + Keys when is_list(Keys) -> + all_docs_view(Req, Db, Keys); + _ -> + throw({bad_request, "`keys` body member must be an array."}) + end; db_req(#httpd{path_parts=[_,<<"_all_docs">>]}=Req, _Db) -> send_method_not_allowed(Req, "GET,HEAD,POST"); @@ -397,7 +396,7 @@ all_docs_callback({row, Row}, {Prepend, Resp}) -> all_docs_callback(complete, {_, Resp}) -> send_chunk(Resp, "\r\n]}"), end_json_response(Resp), - {stop, Resp}; + {ok, Resp}; all_docs_callback({error, Reason}, Resp) -> chttpd:send_chunked_error(Resp, {error, Reason}). -- cgit v1.2.3