From b15f4636337c45b487651e8d442afed0d4141725 Mon Sep 17 00:00:00 2001 From: Magnus Ahltorp Date: Sat, 25 Oct 2014 01:51:46 +0200 Subject: Move internal HTTP APIs to mochiweb. Stop using jiffy. Conflicts: src/frontend.erl src/plop.erl src/storage.erl --- src/plop.erl | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'src/plop.erl') diff --git a/src/plop.erl b/src/plop.erl index 4c94f2b..57febf5 100644 --- a/src/plop.erl +++ b/src/plop.erl @@ -109,7 +109,8 @@ handle_cast(_Request, State) -> handle_http_reply(State, {storage_sendentry_http, {OwnRequestId}}, StatusCode, Body) -> - {PropList} = (catch jiffy:decode(Body)), + lager:debug("http_reply: ~p", [Body]), + {struct, PropList} = mochijson2:decode(Body), Result = proplists:get_value(<<"result">>, PropList), case dict:fetch(OwnRequestId, State#state.own_requests) of undefined -> @@ -200,23 +201,24 @@ storage_nodes_quorum() -> Value. send_storage_sendentry(URLBase, LogEntry, TreeLeafHash) -> - Request = jiffy:encode( + Request = mochijson2:encode( {[{plop_version, 1}, {entry, base64:encode(LogEntry)}, {treeleafhash, base64:encode(TreeLeafHash)} ]}), + lager:debug("send sendentry to storage node ~p: ~p", [URLBase, Request]), httpc:request(post, {URLBase ++ "sendentry", [], - "text/json", Request}, + "text/json", list_to_binary(Request)}, [], [{sync, false}]). send_storage_entrycommitted(URLBase, EntryHash, TreeLeafHash) -> - Request = jiffy:encode( - {[{plop_version, 1}, - {entryhash, base64:encode(EntryHash)}, - {treeleafhash, base64:encode(TreeLeafHash)} - ]}), + Request = mochijson2:encode( + {[{plop_version, 1}, + {entryhash, base64:encode(EntryHash)}, + {treeleafhash, base64:encode(TreeLeafHash)} + ]}), httpc:request(post, {URLBase ++ "entrycommitted", [], - "text/json", Request}, + "text/json", list_to_binary(Request)}, [], [{sync, false}]). store_at_all_nodes(Nodes, {LogEntry, TreeLeafHash, EntryHash}, From, State) -> -- cgit v1.1