# HG changeset patch # User Kim Alvefur # Date 1579979208 -3600 # Node ID 3b6b8dcff78e6833d3a8ea8d53dbbb6fa3966fd8 # Parent ede3d1724dd1fcfcbc82292a6a32d9426360e4a0 mod_rest: Log connectivity problems via module status API diff -r ede3d1724dd1 -r 3b6b8dcff78e mod_rest/mod_rest.lua --- a/mod_rest/mod_rest.lua Sat Jan 25 20:04:39 2020 +0100 +++ b/mod_rest/mod_rest.lua Sat Jan 25 20:06:48 2020 +0100 @@ -153,9 +153,15 @@ send_type = "application/json"; end + module:set_status("info", "Not yet connected"); http.request(rest_url, { method = "OPTIONS", }, function (body, code, response) + if code == 0 then + return module:log_status("error", "Could not connect to callback URL %q: %s", rest_url, body); + else + module:set_status("info", "Connected"); + end if code == 200 and response.headers.accept then send_type = decide_type(response.headers.accept); module:log("debug", "Set 'rest_callback_content_type' = %q based on Accept header", send_type); @@ -216,6 +222,11 @@ Accept = table.concat(supported_types, ", "); }, }, function (body, code, response) + if code == 0 then + return module:log_status("error", "Could not connect to callback URL %q: %s", rest_url, body); + else + module:set_status("info", "Connected"); + end if (code == 202 or code == 204) and not reply_needed then -- Delivered, no reply return;