From cf3467ce1f1327856821bd4b10217ec7ddacff80 Mon Sep 17 00:00:00 2001 From: steckbrief Date: Wed, 17 Oct 2018 22:28:37 +0200 Subject: adds support for requesting spec and implementation version of http-fileservice-module --- .../mod_http_upload_external.lua | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/prosody-module/mod_http_upload_external/mod_http_upload_external.lua b/prosody-module/mod_http_upload_external/mod_http_upload_external.lua index 10d3d64..f6f724f 100644 --- a/prosody-module/mod_http_upload_external/mod_http_upload_external.lua +++ b/prosody-module/mod_http_upload_external/mod_http_upload_external.lua @@ -195,6 +195,30 @@ local function version(origin, stanza) local reply = st.reply(stanza); reply:tag("version", { xmlns = xmlns_filetransfer_http }); 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); return true; end -- cgit v1.2.3