Changeset

3816:8473fd2d09c1

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.
author Kim Alvefur <zash@zash.se>
date Wed, 01 Jan 2020 16:40:10 +0100
parents 3815:1a0a612d36bc
children 3817:937f8c463be6
files mod_rest/mod_rest.lua
diffstat 1 files changed, 1 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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'" });