From: Otto Moerbeek Date: Tue, 16 Aug 2022 08:00:52 +0000 (+0200) Subject: An HttpException creates a new response body. X-Git-Tag: rec-4.8.0-alpha1~66^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F11854%2Fhead;p=thirdparty%2Fpdns.git An HttpException creates a new response body. Initialize the s_dlog field of that new response. I would prefer to do that in the exception's ct, but we do not have the uniqueid there. --- diff --git a/pdns/webserver.cc b/pdns/webserver.cc index 7803989010..9565f4ba04 100644 --- a/pdns/webserver.cc +++ b/pdns/webserver.cc @@ -262,15 +262,16 @@ void WebServer::handleRequest(HttpRequest& req, HttpResponse& resp) const // set default headers resp.headers["Content-Type"] = "text/html; charset=utf-8"; +#ifdef RECURSOR + auto log = req.d_slog->withValues("urlpath", Logging::Loggable(req.url.path)); +#endif + try { if (!req.complete) { SLOG(g_log<info(Logr::Debug, "Incomplete request")); throw HttpBadRequestException(); } -#ifdef RECURSOR - auto log = req.d_slog->withValues("urlpath", Logging::Loggable(req.url.path)); -#endif SLOG(g_log<info(Logr::Debug, "Handling request")); @@ -323,6 +324,12 @@ void WebServer::handleRequest(HttpRequest& req, HttpResponse& resp) const } catch(HttpException &e) { resp = e.response(); +#ifdef RECURSOR + // An HttpException does not initialize d_slog + if (!resp.d_slog) { + resp.setSLog(log); + } +#endif // TODO rm this logline? SLOG(g_log<error(Logr::Debug, resp.status, "Error result", "urlpath", Logging::Loggable(req.url.path)));