# HG changeset patch # User Kim Alvefur # Date 1580008027 -3600 # Node ID 839224be5299e6ea7a705bd596f0de090c1a748e # Parent c0df50ce96f0bd84aaaf646ecbdb06790a6f9ded mod_rest: Skip attempting parse empty response Avoids logging a useless warning diff -r c0df50ce96f0 -r 839224be5299 mod_rest/mod_rest.lua --- a/mod_rest/mod_rest.lua Sat Jan 25 20:22:12 2020 +0100 +++ b/mod_rest/mod_rest.lua Sun Jan 26 04:07:07 2020 +0100 @@ -229,38 +229,41 @@ else module:set_status("info", "Connected"); end - if (code == 202 or code == 204) and not reply_needed then - -- Delivered, no reply - return; - end local reply; - local parsed, err = parse(response.headers["content-type"], body); - if not parsed then - module:log("warn", "Failed parsing data from REST callback: %s, %q", err, body); - elseif parsed.name ~= stanza.name then - module:log("warn", "REST callback responded with the wrong stanza type, got %s but expected %s", parsed.name, stanza.name); + if code == 202 or code == 204 then + if not reply_needed then + -- Delivered, no reply + return; + end else - parsed.attr = { - from = stanza.attr.to, - to = stanza.attr.from, - id = parsed.attr.id or id.medium(); - type = parsed.attr.type, - ["xml:lang"] = parsed.attr["xml:lang"], - }; - if parsed.name == "message" and parsed.attr.type == "groupchat" then - parsed.attr.to = jid.bare(stanza.attr.from); + local parsed, err = parse(response.headers["content-type"], body); + if not parsed then + module:log("warn", "Failed parsing data from REST callback: %s, %q", err, body); + elseif parsed.name ~= stanza.name then + module:log("warn", "REST callback responded with the wrong stanza type, got %s but expected %s", parsed.name, stanza.name); + else + parsed.attr = { + from = stanza.attr.to, + to = stanza.attr.from, + id = parsed.attr.id or id.medium(); + type = parsed.attr.type, + ["xml:lang"] = parsed.attr["xml:lang"], + }; + if parsed.name == "message" and parsed.attr.type == "groupchat" then + parsed.attr.to = jid.bare(stanza.attr.from); + end + if not stanza.attr.type and parsed:get_child("error") then + parsed.attr.type = "error"; + end + if parsed.attr.type == "error" then + parsed.attr.id = stanza.attr.id; + elseif parsed.name == "iq" then + parsed.attr.id = stanza.attr.id; + parsed.attr.type = "result"; + end + reply = parsed; end - if not stanza.attr.type and parsed:get_child("error") then - parsed.attr.type = "error"; - end - if parsed.attr.type == "error" then - parsed.attr.id = stanza.attr.id; - elseif parsed.name == "iq" then - parsed.attr.id = stanza.attr.id; - parsed.attr.type = "result"; - end - reply = parsed; end if not reply then