This patch adds the logging codes:
 %>ru - Request URL from the client original request.
 %<ru - Request URL sent to the server.

Ideally these will log the original syntax, but Squid does not preserve that. For now the canonical URI are used instead.

The %ru is retained to display the same old historic logging URL it used to. This appears to be the client original in most cases, but has been observed with different content to both the canonical client URL and canonical server URL in some cases.

These are desired so as to be able to log and identify the actual outgoing URLs in relation to what is incoming.


This depends on bug fixes to re-write cloning and URL handling in the accompanying patch.

Amos
--
Please be using
  Current Stable Squid 2.7.STABLE9 or 3.1.12
  Beta testers wanted for 3.2.0.7 and 3.1.12.1
=== modified file 'src/log/FormatSquidCustom.cc'
--- src/log/FormatSquidCustom.cc	2011-03-30 04:29:35 +0000
+++ src/log/FormatSquidCustom.cc	2011-05-18 06:24:56 +0000
@@ -655,6 +655,14 @@
 
             break;
 
+        case LFT_CLIENT_REQ_URI:
+            // original client URI
+            if (al->request) {
+                out = al->request->canonical;
+                quote = 1;
+            }
+            break;
+
         case LFT_REQUEST_METHOD:
             out = al->_private.method_str;
 
@@ -666,7 +674,10 @@
             break;
 
         case LFT_REQUEST_URLPATH:
-            if (al->request) {
+            if (al->adapted_request) {
+                out = al->adapted_request->urlpath.termedBuf();
+                quote = 1;
+            } else if (al->request) {
                 out = al->request->urlpath.termedBuf();
                 quote = 1;
             }
@@ -677,6 +688,14 @@
             out = tmp;
             break;
 
+        case LFT_SERVER_REQ_URI:
+            // adapted request URI sent to server/peer
+            if (al->adapted_request) {
+                out = al->adapted_request->canonical;
+                quote = 1;
+            }
+            break;
+
         case LFT_REQUEST_SIZE_TOTAL:
             outoff = al->cache.requestSize;
             dooff = 1;

=== modified file 'src/log/Tokens.cc'
--- src/log/Tokens.cc	2011-03-30 04:29:35 +0000
+++ src/log/Tokens.cc	2011-05-18 06:24:56 +0000
@@ -131,6 +131,12 @@
 
     {"mt", LFT_MIME_TYPE},
 
+    /*{">rm", LFT_CLIENT_REQ_METHOD},*/
+    {">ru", LFT_CLIENT_REQ_URI},
+    /*{">rp", LFT_CLIENT_REQ_URLPATH},*/
+    /*{">rq", LFT_CLIENT_REQ_QUERY},*/
+    /*{">rv", LFT_CLIENT_REQ_VERSION},*/
+
     {"rm", LFT_REQUEST_METHOD},
     {"ru", LFT_REQUEST_URI},	/* doesn't include the query-string */
     {"rp", LFT_REQUEST_URLPATH},	/* doesn't include the host */
@@ -138,6 +144,12 @@
     {">v", LFT_REQUEST_VERSION},
     {"rv", LFT_REQUEST_VERSION},
 
+    /*{"<rm", LFT_SERVERT_REQ_METHOD},*/
+    {"<ru", LFT_SERVER_REQ_URI},
+    /*{"<rp", LFT_SERVER_REQ_URLPATH},*/
+    /*{"<rq", LFT_SERVER_REQ_QUERY},*/
+    /*{"<rv", LFT_SERVER_REQ_VERSION},*/
+
     { ">st", LFT_REQUEST_SIZE_TOTAL },
     /*{ ">sl", LFT_REQUEST_SIZE_LINE }, * / / * the request line "GET ... " */
     { ">sh", LFT_REQUEST_SIZE_HEADERS },

=== modified file 'src/log/Tokens.h'
--- src/log/Tokens.h	2011-03-30 04:29:35 +0000
+++ src/log/Tokens.h	2011-05-18 06:24:56 +0000
@@ -105,12 +105,27 @@
 
     LFT_MIME_TYPE,
 
+    /* original Request-Line details receved from client */
+    /* LFT_CLIENT_REQ_METHOD, */
+    LFT_CLIENT_REQ_URI,
+    /* LFT_CLIENT_REQ_URLPATH, */
+    /* LFT_CLIENT_REQ_QUERY, */
+    /* LFT_CLIENT_REQ_VERSION, */
+
+    /* Request-Line details receved from client (filtered) */
     LFT_REQUEST_METHOD,
     LFT_REQUEST_URI,
     LFT_REQUEST_URLPATH,
-    /*LFT_REQUEST_QUERY, * // * this is not needed. see strip_query_terms */
+    /*LFT_REQUEST_QUERY, */
     LFT_REQUEST_VERSION,
 
+    /* Request-Line details sent to the server/peer */
+    /* LFT_SERVER_REQ_METHOD, */
+    LFT_SERVER_REQ_URI,
+    /* LFT_SERVER_REQ_URLPATH, */
+    /* LFT_SERVER_REQ_QUERY, */
+    /* LFT_SERVER_REQ_VERSION, */
+
     LFT_REQUEST_SIZE_TOTAL,
     /*LFT_REQUEST_SIZE_LINE, */
     LFT_REQUEST_SIZE_HEADERS,

=== modified file 'src/cf.data.pre'
--- src/cf.data.pre	2011-05-13 21:04:03 +0000
+++ src/cf.data.pre	2011-05-18 14:28:27 +0000
@@ -2911,7 +2911,9 @@
 		[http::]Sh	Squid hierarchy status (DEFAULT_PARENT etc)
 		[http::]mt	MIME content type
 		[http::]rm	Request method (GET/POST etc)
-		[http::]ru	Request URL
+		[http::]ru	Request URL from client (historic, filtered for logging)
+		[http::]>ru	Request URL from client
+		[http::]<ru	Request URL sent to server or peer
 		[http::]rp	Request URL-Path excluding hostname
 		[http::]rv	Request protocol version
 		[http::]et	Tag returned by external acl

Reply via email to