adds support for requesting spec and implementation version of http-fileservice-module

This commit is contained in:
steckbrief 2018-10-17 22:28:37 +02:00
parent 3973a5f737
commit cf3467ce1f

View file

@ -195,6 +195,30 @@ local function version(origin, stanza)
local reply = st.reply(stanza); local reply = st.reply(stanza);
reply:tag("version", { xmlns = xmlns_filetransfer_http }); reply:tag("version", { xmlns = xmlns_filetransfer_http });
reply:tag("xmpp-fileservice-module", { spec = spec_version, implementation = impl_version }):up(); reply:tag("xmpp-fileservice-module", { spec = spec_version, implementation = impl_version }):up();
-- the request
local respbody, statuscode = http.request(external_url .. "?action=version");
-- respbody is nil in case the server is not reachable
if respbody ~= nil then
respbody = string.gsub(respbody, "\\/", "/");
end
local http_spec_version = nil;
local http_impl_version = nil;
-- check the response
if statuscode == 200 then
local respobj, pos, err = json.decode(respbody);
if err then
-- do nothing for the moment
else
if respobj["spec"] ~= nil and respobj["impl"] ~= nil then
http_spec_version = respobj.spec;
http_impl_version = respobj.impl;
reply:tag("http-fileservice-module", { spec = http_spec_version, implementation = http_impl_version }):up();
end
end
end
origin.send(reply); origin.send(reply);
return true; return true;
end end