# HG changeset patch # User Kim Alvefur # Date 1577893210 -3600 # Node ID 8473fd2d09c1ddf16076b745d3f3157e38d40071 # Parent 1a0a612d36bc43b39934bc69aa2bd72896263b02 mod_rest: Default to replying with same type as request If you send JSON then you get JSON back unless you say something different with the Accept header. diff -r 1a0a612d36bc -r 8473fd2d09c1 mod_rest/mod_rest.lua --- a/mod_rest/mod_rest.lua Wed Jan 01 16:37:18 2020 +0100 +++ b/mod_rest/mod_rest.lua Wed Jan 01 16:40:10 2020 +0100 @@ -102,7 +102,7 @@ ["xml:lang"] = payload.attr["xml:lang"], }; module:log("debug", "Received[rest]: %s", payload:top_tag()); - local send_type = decide_type(request.headers.accept) + local send_type = decide_type((request.headers.accept or "") ..",".. request.headers.content_type) if payload.name == "iq" then if payload.attr.type ~= "get" and payload.attr.type ~= "set" then return errors.new({ code = 422, text = "'iq' stanza must be of type 'get' or 'set'" });