25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-26 17:38:45 +01:00

Switch to P1 implementation of XML-RPC

This commit is contained in:
Evgeniy Khramtsov 2014-10-04 12:37:31 +04:00
parent 1d782db84f
commit 7b3209cc7f

View File

@ -209,18 +209,26 @@ process(_, #request{method = 'POST', data = Data, opts = Opts}) ->
_ -> true _ -> true
end, end,
State = #state{access_commands = AccessCommands, get_auth = GetAuth}, State = #state{access_commands = AccessCommands, get_auth = GetAuth},
case xmlrpc_decode:payload(Data) of case xml_stream:parse_element(Data) of
{error, _} = Err -> {error, _} ->
?ERROR_MSG("XML-RPC request ~s failed with reason: ~p",
[Data, Err]),
{400, [], {400, [],
#xmlel{name = <<"h1">>, attrs = [], #xmlel{name = <<"h1">>, attrs = [],
children = [{xmlcdata, <<"Malformed Request">>}]}}; children = [{xmlcdata, <<"Malformed XML">>}]}};
{ok, RPC} -> El ->
?DEBUG("got XML-RPC request: ~p", [RPC]), case p1_xmlrpc:decode(El) of
{false, Result} = handler(State, RPC), {error, _} = Err ->
{ok, XML} = xmlrpc_encode:payload(Result), ?ERROR_MSG("XML-RPC request ~s failed with reason: ~p",
{200, [], [{<<"Content-Type">>, <<"text/xml">>}], XML} [Data, Err]),
{400, [],
#xmlel{name = <<"h1">>, attrs = [],
children = [{xmlcdata, <<"Malformed Request">>}]}};
{ok, RPC} ->
?DEBUG("got XML-RPC request: ~p", [RPC]),
{false, Result} = handler(State, RPC),
XML = xml:element_to_binary(p1_xmlrpc:encode(Result)),
{200, [], [{<<"Content-Type">>, <<"text/xml">>}],
<<"<?xml version=\"1.0\"?>", XML/binary>>}
end
end; end;
process(_, _) -> process(_, _) ->
{400, [], {400, [],