Software /
code /
prosody
Changeset
1498:481dfc89047a
util.xmlrpc: Support for multiple parameters in requests
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 08 Jul 2009 15:23:07 +0100 |
parents | 1497:4c2c403ca04b |
children | 1499:51e3e22b5316 |
files | util/xmlrpc.lua |
diffstat | 1 files changed, 15 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/util/xmlrpc.lua Wed Jul 08 15:11:11 2009 +0100 +++ b/util/xmlrpc.lua Wed Jul 08 15:23:07 2009 +0100 @@ -14,6 +14,7 @@ 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 @@ 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 @@ 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