couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r954874 - /couchdb/branches/0.11.x/src/couchdb/couch_httpd_external.erl
Date Tue, 15 Jun 2010 13:27:17 GMT
Author: jan
Date: Tue Jun 15 13:27:16 2010
New Revision: 954874

URL: http://svn.apache.org/viewvc?rev=954874&view=rev
Log:
Merge r919949 from trunk:

json startkey, endkey, and key should be decoded before being sent to the query server or
externals

Modified:
    couchdb/branches/0.11.x/src/couchdb/couch_httpd_external.erl

Modified: couchdb/branches/0.11.x/src/couchdb/couch_httpd_external.erl
URL: http://svn.apache.org/viewvc/couchdb/branches/0.11.x/src/couchdb/couch_httpd_external.erl?rev=954874&r1=954873&r2=954874&view=diff
==============================================================================
--- couchdb/branches/0.11.x/src/couchdb/couch_httpd_external.erl (original)
+++ couchdb/branches/0.11.x/src/couchdb/couch_httpd_external.erl Tue Jun 15 13:27:16 2010
@@ -77,7 +77,7 @@ json_req_obj(#httpd{mochi_req=Req,
         {<<"id">>, DocId},
         {<<"method">>, Method},
         {<<"path">>, Path},
-        {<<"query">>, to_json_terms(Req:parse_qs())},
+        {<<"query">>, json_query_keys(to_json_terms(Req:parse_qs()))},
         {<<"headers">>, to_json_terms(Hlist)},
         {<<"body">>, Body},
         {<<"peer">>, ?l2b(Req:get(peer))},
@@ -95,6 +95,19 @@ to_json_terms([{Key, Value} | Rest], Acc
 to_json_terms([{Key, Value} | Rest], Acc) ->
     to_json_terms(Rest, [{list_to_binary(Key), list_to_binary(Value)} | Acc]).
 
+json_query_keys({Json}) ->
+    json_query_keys(Json, []).
+json_query_keys([], Acc) ->
+    {lists:reverse(Acc)};
+json_query_keys([{<<"startkey">>, Value} | Rest], Acc) ->
+    json_query_keys(Rest, [{<<"startkey">>, couch_util:json_decode(Value)}|Acc]);
+json_query_keys([{<<"endkey">>, Value} | Rest], Acc) ->
+    json_query_keys(Rest, [{<<"endkey">>, couch_util:json_decode(Value)}|Acc]);
+json_query_keys([{<<"key">>, Value} | Rest], Acc) ->
+    json_query_keys(Rest, [{<<"key">>, couch_util:json_decode(Value)}|Acc]);
+json_query_keys([Term | Rest], Acc) ->
+    json_query_keys(Rest, [Term|Acc]).
+
 send_external_response(#httpd{mochi_req=MochiReq}=Req, Response) ->
     #extern_resp_args{
         code = Code,



Mime
View raw message