changeset 3866:c0df50ce96f0

mod_rest: Handle internal http request errors early and then return Skips over attempted parsing of the payload which usually failed since the body is an error string like "connection refused", so this produced useless errors.
author Kim Alvefur <zash@zash.se>
date Sat, 25 Jan 2020 20:22:12 +0100 (2020-01-25)
parents a44e20cbd986
children 839224be5299
files mod_rest/mod_rest.lua
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mod_rest/mod_rest.lua	Sat Jan 25 20:16:01 2020 +0100
+++ b/mod_rest/mod_rest.lua	Sat Jan 25 20:22:12 2020 +0100
@@ -224,6 +224,8 @@
 			}, function (body, code, response)
 				if code == 0 then
 					module:log_status("error", "Could not connect to callback URL %q: %s", rest_url, body);
+					origin.send(st.error_reply(stanza, "wait", "recipient-unavailable", body));
+					return;
 				else
 					module:set_status("info", "Connected");
 				end
@@ -275,8 +277,6 @@
 						reply = st.error_reply(stanza, "modify", "bad-request", body);
 					elseif code_hundreds == 500 then
 						reply = st.error_reply(stanza, "cancel", "internal-server-error", body);
-					elseif code == 0 then
-						reply = st.error_reply(stanza, "wait", "recipient-unavailable", body);
 					else
 						reply = st.error_reply(stanza, "cancel", "undefined-condition", body);
 					end