Software /
code /
prosody
Changeset
8690:0f6623712239
net.http: Allow enabling/disabling error suppression, useful for tests
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 24 Mar 2018 11:29:33 +0000 |
parents | 8689:c7122fbe1600 |
children | 8691:564e2c63e0d4 |
files | net/http.lua |
diffstat | 1 files changed, 7 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/net/http.lua Sat Mar 24 11:29:04 2018 +0000 +++ b/net/http.lua Sat Mar 24 11:29:33 2018 +0000 @@ -37,9 +37,12 @@ -- 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 @@ 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 @@ local default_http = new({ sslctx = { mode = "client", protocol = "sslv23", options = { "no_sslv2", "no_sslv3" } }; + suppress_errors = true; }); return {