# HG changeset patch # User Kim Alvefur # Date 1577861748 -3600 # Node ID d74509cd35fb408fbaa2455545cbdb65aa9a2620 # Parent dc2b5a412286d6ebad8e9fbfdf8c5e6f2504b5a6 mod_rest: Use HTTP status 422 for stanza problems Means the payload can't be processed for some reason other than syntax errors. diff -r dc2b5a412286 -r d74509cd35fb mod_rest/mod_rest.lua --- a/mod_rest/mod_rest.lua Wed Jan 01 05:36:09 2020 +0100 +++ b/mod_rest/mod_rest.lua Wed Jan 01 07:55:48 2020 +0100 @@ -39,17 +39,17 @@ return errors.new({ code = 400, text = err }); end if payload.attr.xmlns then - return errors.new({ code = 400, text = "'xmlns' attribute must be empty" }); + return errors.new({ code = 422, text = "'xmlns' attribute must be empty" }); end local to = jid.prep(payload.attr.to); if not to then - return errors.new({ code = 400, text = "Invalid destination JID" }); + return errors.new({ code = 422, text = "Invalid destination JID" }); end local from = module.host; if allow_any_source and payload.attr.from then from = jid.prep(payload.attr.from); if not from then - return errors.new({ code = 400, text = "Invalid source JID" }); + return errors.new({ code = 422, text = "Invalid source JID" }); end if validate_from_addresses and not jid.compare(from, module.host) then return errors.new({ code = 403, text = "Source JID must belong to current host" }); @@ -65,7 +65,7 @@ module:log("debug", "Received[rest]: %s", payload:top_tag()); if payload.name == "iq" then if payload.attr.type ~= "get" and payload.attr.type ~= "set" then - return errors.new({ code = 400, text = "'iq' stanza must be of type 'get' or 'set'" }); + return errors.new({ code = 422, text = "'iq' stanza must be of type 'get' or 'set'" }); end return module:send_iq(payload):next( function (result)