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
commit3a59dfeb6a33aefe16c65ab012e51ef356a5b8ec (patch)
tree4a5452bd913b8e7315edeff1dfd1eccaf5b74506 /net
parent627e3773704d58642befe01e7c015c4d8db77039 (diff)
downloadprosody-3a59dfeb6a33aefe16c65ab012e51ef356a5b8ec.tar.gz
prosody-3a59dfeb6a33aefe16c65ab012e51ef356a5b8ec.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 {