diff options
author | Matthew Wild <mwild1@gmail.com> | 2009-07-08 15:23:07 +0100 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2009-07-08 15:23:07 +0100 |
commit | 6776117801de68eddc5da5f793300e5919dbbca3 (patch) | |
tree | 198d6314a61f008a9c87f48dc4c2d8369170db4b /util | |
parent | ddf0fa83fd3d7a11814ea9f442d4602fc7fd5def (diff) | |
download | prosody-6776117801de68eddc5da5f793300e5919dbbca3.tar.gz prosody-6776117801de68eddc5da5f793300e5919dbbca3.zip |
util.xmlrpc: Support for multiple parameters in requests
Diffstat (limited to 'util')
-rw-r--r-- | util/xmlrpc.lua | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/util/xmlrpc.lua b/util/xmlrpc.lua index 2c256aa1..d326e677 100644 --- a/util/xmlrpc.lua +++ b/util/xmlrpc.lua @@ -14,6 +14,7 @@ local t_concat = table.concat; local t_insert = table.insert; local tostring = tostring; local tonumber = tonumber; +local select = select; local st = require "util.stanza"; module "xmlrpc" @@ -45,12 +46,17 @@ local map = { stanza:tag("nil"):up(); end; }; -_lua_to_xmlrpc = function(stanza, object) - local h = map[type(object)]; - if h then - h(stanza, object); - else - error("Type not supported by XML-RPC: " .. type(object)); +_lua_to_xmlrpc = function(stanza, ...) + for i=1,select('#', ...) do + stanza:tag("param"):tag("value"); + local object = select(i, ...); + local h = map[type(object)]; + if h then + h(stanza, object); + else + error("Type not supported by XML-RPC: " .. type(object)); + end + stanza:up():up(); end end function create_response(object) @@ -66,11 +72,11 @@ function create_error_response(faultCode, faultString) return stanza; end -function create_request(method_name, object) +function create_request(method_name, ...) local stanza = st.stanza("methodCall") :tag("methodName"):text(method_name):up() - :tag("params"):tag("param"):tag("value"); - _lua_to_xmlrpc(stanza, object); + :tag("params"); + _lua_to_xmlrpc(stanza, ...); stanza:up():up():up(); return stanza; end |