aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsteckbrief <steckbrief@chefmail.de>2018-10-17 22:28:37 +0200
committersteckbrief <steckbrief@chefmail.de>2018-10-17 22:28:37 +0200
commitcf3467ce1f1327856821bd4b10217ec7ddacff80 (patch)
treebf074eef82d8cb67dbe3de5b83f9eafb9e971f5c
parent3973a5f737ff92ba2accba0679f7df6397d630e4 (diff)
adds support for requesting spec and implementation version of http-fileservice-module
-rw-r--r--prosody-module/mod_http_upload_external/mod_http_upload_external.lua24
1 files changed, 24 insertions, 0 deletions
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