Hi all,
First of all sorry for late answer.
I am sending a second version of the patch.
The new patch uses the format code "http::>ha" to log the adapted
headers. The already existing format code http::>h logs the original
request headers.
This patch still does not handle the use of the request_header_access.
Please read below.
Amos Jeffries wrote:
Tsantilas Christos wrote:
Hi all,
This patch adds a new format code which allow the user to log HTTP
request header or header fields before they are adapted.
The existing "http::>h" format code logs HTTP request headers after
adaptation.
The new format code is the "http::>hv".
This is a Measurement Factory project.
Regards,
Christos
Um, I would think this makes more sense done the other way around.
With the default >h displaying the virgin headers received from the
client and some other code ( >ha ?) for the adapted headers. Be it
OK Amos this patch does it.
adaptation or headers_access doing the alteration.
The request_header_access does not modify the request send by the client
but has to do with the http request will be send to the server by squid.
Also currently does not have any effect to request headers logging.
The request_header_access implemented inside http.cc file. If we want
to consider it as request adaptation mechanism maybe we should move it
to client_side* code.
Regards,
Christos
Likewise on replies.
Amos
=== modified file 'src/AccessLogEntry.h'
--- src/AccessLogEntry.h 2009-12-22 01:12:53 +0000
+++ src/AccessLogEntry.h 2010-01-24 18:45:24 +0000
@@ -47,7 +47,11 @@
{
public:
- AccessLogEntry() : url(NULL) , reply(NULL), request(NULL) {}
+ AccessLogEntry() : url(NULL) , reply(NULL), request(NULL),
+#if USE_ADAPTATION
+ adapted_request(NULL)
+#endif
+ {}
const char *url;
@@ -134,6 +138,10 @@
public:
Headers() : request(NULL),
+#if USE_ADAPTATION
+ adapted_request(NULL),
+#endif
+
#if ICAP_CLIENT
icap(NULL),
#endif
@@ -141,6 +149,11 @@
char *request;
+#if USE_ADAPTATION
+ char *adapted_request;
+#endif
+
+
#if ICAP_CLIENT
char * icap; ///< last matching ICAP response header.
#endif
@@ -160,6 +173,10 @@
HierarchyLogEntry hier;
HttpReply *reply;
HttpRequest *request;
+#if USE_ADAPTATION
+ HttpRequest *adapted_request;
+#endif
+
#if ICAP_CLIENT
/** \brief This subclass holds log info for ICAP part of request
=== modified file 'src/cf.data.pre'
--- src/cf.data.pre 2010-01-21 12:48:36 +0000
+++ src/cf.data.pre 2010-01-24 21:53:21 +0000
@@ -2547,7 +2547,7 @@
when multiple ICAP transactions per HTTP
transaction are supported.
- If adaptation is enabled the following two codes become available:
+ If adaptation is enabled the following codes become available:
adapt::sum_trs Summed adaptation transaction response
times recorded as a comma-separated list in
@@ -2567,6 +2567,10 @@
together. Instead, all transaction response
times are recorded individually.
+ http::>ha The adapted HTTP request headers.
+ Optional header name argument on the format
+ header[:[separator]element]
+
You can prefix adapt::*_trs format codes with adaptation
service name in curly braces to record response time(s) specific
to that service. For example: %{my_service}adapt::sum_trs
=== modified file 'src/client_side.cc'
--- src/client_side.cc 2010-01-13 01:13:17 +0000
+++ src/client_side.cc 2010-01-24 21:47:08 +0000
@@ -461,7 +461,23 @@
mb.init();
packerToMemInit(&p, &mb);
request->header.packInto(&p);
+#if USE_ADAPTATION
+ //if Adaptation this is the adapted request
+ aLogEntry->headers.adapted_request = xstrdup(mb.buf);
+#else
aLogEntry->headers.request = xstrdup(mb.buf);
+#endif
+
+#if USE_ADAPTATION
+ // if Adaptation then the virgin request is saved to aLogEntry->request
+ if (aLogEntry->request) {
+ packerClean(&p);
+ mb.reset();
+ packerToMemInit(&p, &mb);
+ aLogEntry->request->header.packInto(&p);
+ aLogEntry->headers.request = xstrdup(mb.buf);
+ }
+#endif
#if ICAP_CLIENT
packerClean(&p);
@@ -559,7 +575,11 @@
if (!Config.accessList.log || checklist->fastCheck()) {
if (request)
+#if USE_ADAPTATION
+ al.adapted_request = HTTPMSGLOCK(request);
+#else
al.request = HTTPMSGLOCK(request);
+#endif
accessLogLog(&al, checklist);
updateCounters();
=== modified file 'src/client_side_request.cc'
--- src/client_side_request.cc 2010-01-22 01:13:11 +0000
+++ src/client_side_request.cc 2010-01-24 18:37:20 +0000
@@ -1266,6 +1266,9 @@
#if USE_ADAPTATION
if (!calloutContext->adaptation_acl_check_done) {
calloutContext->adaptation_acl_check_done = true;
+ /*Save the original request for logging purposes*/
+ calloutContext->http->al.request = HTTPMSGLOCK(request);
+
if (Adaptation::AccessCheck::Start(
Adaptation::methodReqmod, Adaptation::pointPreCache,
request, NULL, adaptationAclCheckDoneWrapper, calloutContext))
=== modified file 'src/log/access_log.cc'
--- src/log/access_log.cc 2009-12-22 01:12:53 +0000
+++ src/log/access_log.cc 2010-01-24 18:44:39 +0000
@@ -359,6 +359,12 @@
LFT_REQUEST_HEADER_ELEM,
LFT_REQUEST_ALL_HEADERS,
+#if USE_ADAPTATION
+ LFT_ADAPTED_REQUEST_HEADER,
+ LFT_ADAPTED_REQUEST_HEADER_ELEM,
+ LFT_ADAPTED_REQUEST_ALL_HEADERS,
+#endif
+
LFT_REPLY_HEADER,
LFT_REPLY_HEADER_ELEM,
LFT_REPLY_ALL_HEADERS,
@@ -512,6 +518,10 @@
{"<tt", LFT_TOTAL_SERVER_SIDE_RESPONSE_TIME},
{"dt", LFT_DNS_WAIT_TIME},
+#if USE_ADAPTATION
+ {">ha", LFT_ADAPTED_REQUEST_HEADER},
+ {">ha", LFT_ADAPTED_REQUEST_ALL_HEADERS},
+#endif
{">h", LFT_REQUEST_HEADER},
{">h", LFT_REQUEST_ALL_HEADERS},
{"<h", LFT_REPLY_HEADER},
@@ -765,6 +775,19 @@
break;
+#if USE_ADAPTATION
+ case LFT_ADAPTED_REQUEST_HEADER:
+
+ if (al->request)
+ sb = al->adapted_request->header.getByName(fmt->data.header.header);
+
+ out = sb.termedBuf();
+
+ quote = 1;
+
+ break;
+#endif
+
case LFT_REPLY_HEADER:
if (al->reply)
sb = al->reply->header.getByName(fmt->data.header.header);
@@ -954,6 +977,18 @@
break;
+#if USE_ADAPTATION
+ case LFT_ADAPTED_REQUEST_HEADER_ELEM:
+ if (al->adapted_request)
+ sb = al->adapted_request->header.getByNameListMember(fmt->data.header.header, fmt->data.header.element, fmt->data.header.separator);
+
+ out = sb.termedBuf();
+
+ quote = 1;
+
+ break;
+#endif
+
case LFT_REPLY_HEADER_ELEM:
if (al->reply)
sb = al->reply->header.getByNameListMember(fmt->data.header.header, fmt->data.header.element, fmt->data.header.separator);
@@ -971,6 +1006,15 @@
break;
+#if USE_ADAPTATION
+ case LFT_ADAPTED_REQUEST_ALL_HEADERS:
+ out = al->headers.adapted_request;
+
+ quote = 1;
+
+ break;
+#endif
+
case LFT_REPLY_ALL_HEADERS:
out = al->headers.reply;
@@ -1393,6 +1437,10 @@
case LFT_ICAP_REP_HEADER:
#endif
+#if USE_ADAPTATION
+ case LFT_ADAPTED_REQUEST_HEADER:
+#endif
+
case LFT_REQUEST_HEADER:
case LFT_REPLY_HEADER:
@@ -1415,6 +1463,13 @@
case LFT_REQUEST_HEADER:
lt->type = LFT_REQUEST_HEADER_ELEM;
break;
+
+#if USE_ADAPTATION
+ case LFT_ADAPTED_REQUEST_HEADER:
+ lt->type = LFT_ADAPTED_REQUEST_HEADER_ELEM;
+ break;
+#endif
+
case LFT_REPLY_HEADER:
lt->type = LFT_REPLY_HEADER_ELEM;
break;
@@ -1440,6 +1495,13 @@
case LFT_REQUEST_HEADER:
lt->type = LFT_REQUEST_ALL_HEADERS;
break;
+
+#if USE_ADAPTATION
+ case LFT_ADAPTED_REQUEST_HEADER:
+ lt->type = LFT_ADAPTED_REQUEST_ALL_HEADERS;
+ break;
+#endif
+
case LFT_REPLY_HEADER:
lt->type = LFT_REPLY_ALL_HEADERS;
break;
@@ -1553,7 +1615,9 @@
case LFT_ICAP_REP_HEADER_ELEM:
#endif
case LFT_REQUEST_HEADER_ELEM:
-
+#if USE_ADAPTATION
+ case LFT_ADAPTED_REQUEST_HEADER_ELEM:
+#endif
case LFT_REPLY_HEADER_ELEM:
if (t->data.header.separator != ',')
@@ -1567,6 +1631,11 @@
case LFT_REQUEST_HEADER_ELEM:
type = LFT_REQUEST_HEADER_ELEM;
break;
+#if USE_ADAPTATION
+ case LFT_ADAPTED_REQUEST_HEADER_ELEM:
+ type = LFT_ADAPTED_REQUEST_HEADER_ELEM;
+ break;
+#endif
case LFT_REPLY_HEADER_ELEM:
type = LFT_REPLY_HEADER_ELEM;
break;
@@ -1588,7 +1657,9 @@
break;
case LFT_REQUEST_ALL_HEADERS:
-
+#if USE_ADAPTATION
+ case LFT_ADAPTED_REQUEST_ALL_HEADERS:
+#endif
case LFT_REPLY_ALL_HEADERS:
#if ICAP_CLIENT
@@ -1601,6 +1672,11 @@
case LFT_REQUEST_ALL_HEADERS:
type = LFT_REQUEST_HEADER;
break;
+#if USE_ADAPTATION
+ case LFT_ADAPTED_REQUEST_ALL_HEADERS:
+ type = LFT_ADAPTED_REQUEST_HEADER;
+ break;
+#endif
case LFT_REPLY_ALL_HEADERS:
type = LFT_REPLY_HEADER;
break;
@@ -2377,6 +2453,11 @@
safe_free(aLogEntry->headers.reply);
safe_free(aLogEntry->cache.authuser);
+#if USE_ADAPTATION
+ safe_free(aLogEntry->headers.adapted_request);
+ HTTPMSGUNLOCK(aLogEntry->adapted_request);
+#endif
+
HTTPMSGUNLOCK(aLogEntry->reply);
HTTPMSGUNLOCK(aLogEntry->request);
#if ICAP_CLIENT