]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 5278: Log %err_code for "early" request handling errors (#1382)
authorAlex Rousskov <rousskov@measurement-factory.com>
Sat, 17 Jun 2023 16:34:11 +0000 (16:34 +0000)
committerAmos Jeffries <yadij@users.noreply.github.com>
Fri, 30 Jun 2023 12:55:30 +0000 (00:55 +1200)
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

index c4287f4140db0047f1a3a937cb8b45965d8e8094..ec970aabd154d57777b11757e890378f7258dae1 100644 (file)
@@ -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;