Skip to content
Browse files

Fixed double-encoding json

  • Loading branch information...
1 parent 61adb23 commit 8a4d810d51ced0ded5d6842d9faaa31c6a0fa5bf @lordnull lordnull committed Apr 2, 2012
Showing with 7 additions and 3 deletions.
  1. +1 −1 src/cpx_agent_connection.erl
  2. +6 −2 src/cpx_agent_tcp_connection.erl
View
2 src/cpx_agent_connection.erl
@@ -321,7 +321,7 @@ handle_json(State, {struct, Json}) ->
end
end;
true ->
- try apply(Mod, Func, [State, Args]) of
+ try apply(Mod, Func, [State | Args]) of
'exit' ->
{exit, ?simple_success(ReqId), State};
{'exit', ResultJson} ->
View
8 src/cpx_agent_tcp_connection.erl
@@ -290,9 +290,13 @@ code_change(_OldVsn, State, _Extra) ->
% Internal functions
% ================================================================
-send_json(Json, State) ->
+send_json({struct, _} = Json, State) ->
+ IoList = mochijson2:encode(Json),
+ send_json(IoList, State);
+
+send_json(IoList, State) ->
#state{socket_mod = Mod, socket = Sock, compression = Zip} = State,
- BigBin = iolist_to_binary(mochijson2:encode(Json)),
+ BigBin = iolist_to_binary(IoList),
Bin = case Zip of
none -> BigBin;
zip -> zlib:zip(BigBin);

0 comments on commit 8a4d810

Please sign in to comment.
Something went wrong with that request. Please try again.