From 8a628a131c8fd85b737e918f0d7e74b622fe3a5d Mon Sep 17 00:00:00 2001 From: Alex Rousskov Date: Sat, 17 Jun 2023 16:34:11 +0000 Subject: [PATCH] Bug 5278: Log %err_code for "early" request handling errors (#1382) Certain "early" request handling errors (e.g., ERR_TOO_BIG, ERR_UNSUP_REQ, ERR_UNSUP_HTTPVERSION, ERR_PROTOCOL_UNKNOWN, and ERR_INVALID_URL) are handled with nil ClientHttpRequest::request object. ErrorState relied on that object to record error type and details, so %err_code expanded to "-" in the corresponding access.log records. Now, ErrorState also uses ALE (where available). ALE already handles the combination of an early error and late HttpRequest (e.g., the fake one clientReplyContext::createStoreEntry() creates when handling the error). This minimal fix does not address known problems with ErrorState::detail and ErrorState::BuildHttpReply(). It also duplicates related xerrno detailing code. We will address some of these problems shortly, including the increased code duplication problem. --- src/errorpage.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/errorpage.cc b/src/errorpage.cc index b23f17a710..50ad3af9b6 100644 --- a/src/errorpage.cc +++ b/src/errorpage.cc @@ -1352,6 +1352,11 @@ ErrorState::BuildHttpReply() request->detailError(type, detail); else request->detailError(type, SysErrorDetail::NewIfAny(xerrno)); + } else if (ale) { + if (detail) + ale->updateError(Error(type, detail)); + else + ale->updateError(Error(type, SysErrorDetail::NewIfAny(xerrno))); } return rep; -- 2.39.5