]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Propagate details of ICAP errors happened after adapted HTTP header creation.
authorAlex Rousskov <rousskov@measurement-factory.com>
Wed, 23 Mar 2011 00:18:28 +0000 (18:18 -0600)
committerAlex Rousskov <rousskov@measurement-factory.com>
Wed, 23 Mar 2011 00:18:28 +0000 (18:18 -0600)
We used to update the virgin HTTP request with error details even after REQMOD
resulted in creation of a new/adapted HTTP request object. When the client
side replaced the old/virgin request headers with the new adapted request
object, the error details were lost and %err_detail was not logged to the
transaction log.

This is one more place where a Master Transaction object (with a shared error
detail field) should be extracted from the HttpRequest and persist throughout
the HTTP transaction lifetime.

src/adaptation/icap/ModXact.cc

index c2f11a2b25634d2b68dfcf811cae47ca3c40edc6..acb6147c2d3726c6ec327eb57e7f096246363525 100644 (file)
@@ -1845,10 +1845,14 @@ bool Adaptation::Icap::ModXact::fillVirginHttpHeader(MemBuf &mb) const
 
 void Adaptation::Icap::ModXact::detailError(int errDetail)
 {
-    if (HttpRequest *request = virgin.cause ?
-                               virgin.cause : dynamic_cast<HttpRequest*>(virgin.header)) {
+    HttpRequest *request = dynamic_cast<HttpRequest*>(adapted.header);
+    // if no adapted request, update virgin (and inherit its properties later)
+    // TODO: make this and HttpRequest::detailError constant, like adaptHistory
+    if (!request)
+        request = const_cast<HttpRequest*>(&virginRequest());
+
+    if (request)
         request->detailError(ERR_ICAP_FAILURE, errDetail);
-    }
 }
 
 /* Adaptation::Icap::ModXactLauncher */