--- a/mod_rest/mod_rest.lua Wed Feb 26 18:36:40 2020 +0000
+++ b/mod_rest/mod_rest.lua Wed Feb 26 20:14:14 2020 +0100
@@ -68,13 +68,22 @@
return parsed, err;
end
return jsonmap.json2st(parsed);
+ elseif mimetype == "application/x-www-form-urlencoded"then
+ local parsed = http.formdecode(data);
+ if type(parsed) == "string" then
+ return parse("text/plain", parsed);
+ end
+ for i = #parsed, 1, -1 do
+ parsed[i] = nil;
+ end
+ return jsonmap.json2st(parsed);
elseif mimetype == "text/plain" then
return st.message({ type = "chat" }, data);
end
return nil, "unknown-payload-type";
end
-local supported_types = { "application/xmpp+xml", "application/json" };
+local supported_types = { "application/xmpp+xml", "application/json", "application/x-www-form-urlencoded" };
local function decide_type(accept)
-- assumes the accept header is sorted