aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2018-03-24 11:29:33 +0000
committerMatthew Wild <mwild1@gmail.com>2018-03-24 11:29:33 +0000
commite944901cf2b9eede653c696bb95755e57e86a285 (patch)
tree4a5452bd913b8e7315edeff1dfd1eccaf5b74506 /net
parentcf9743127cbca95472fde5f6d57956002272bd2d (diff)
downloadprosody-e944901cf2b9eede653c696bb95755e57e86a285.tar.gz
prosody-e944901cf2b9eede653c696bb95755e57e86a285.zip
net.http: Allow enabling/disabling error suppression, useful for tests
Diffstat (limited to 'net')
-rw-r--r--net/http.lua9
1 files changed, 7 insertions, 2 deletions
diff --git a/net/http.lua b/net/http.lua
index 01dfd7bc..c85fa056 100644
--- a/net/http.lua
+++ b/net/http.lua
@@ -37,9 +37,12 @@ local listener = { default_port = 80, default_mode = "*a" };
-- Request-related helper functions
local function handleerr(err) log("error", "Traceback[http]: %s", traceback(tostring(err), 2)); return err; end
-local function log_if_failed(id, ret, ...)
+local function log_if_failed(req, ret, ...)
if not ret then
- log("error", "Request '%s': error in callback: %s", id, tostring((...)));
+ log("error", "Request '%s': error in callback: %s", req.id, tostring((...)));
+ if not req.suppress_errors then
+ error(...);
+ end
end
return ...;
end
@@ -237,6 +240,7 @@ local function request(self, u, ex, callback)
end
end
req.insecure = ex.insecure;
+ req.suppress_errors = ex.suppress_errors;
end
log("debug", "Making %s %s request '%s' to %s", req.scheme:upper(), method or "GET", req.id, (ex and ex.suppress_url and host_header) or u);
@@ -276,6 +280,7 @@ end
local default_http = new({
sslctx = { mode = "client", protocol = "sslv23", options = { "no_sslv2", "no_sslv3" } };
+ suppress_errors = true;
});
return {