From: wessels <> Date: Fri, 2 Dec 2005 05:40:34 +0000 (+0000) Subject: Add X-Client-IP and X-Client-Username extention headers to ICAP X-Git-Tag: SQUID_3_0_PRE4~474 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a97e82a8d478c67ede8fc78cf41b88ea29b4d5ca;p=thirdparty%2Fsquid.git Add X-Client-IP and X-Client-Username extention headers to ICAP requests. --- diff --git a/src/ICAP/ICAPModXact.cc b/src/ICAP/ICAPModXact.cc index 0a7ec96fa8..90affe8445 100644 --- a/src/ICAP/ICAPModXact.cc +++ b/src/ICAP/ICAPModXact.cc @@ -13,6 +13,7 @@ #include "ICAPClient.h" #include "ChunkedCodingParser.h" #include "TextException.h" +#include "AuthUserRequest.h" // flow and terminology: // HTTP| --> receive --> encode --> write --> |network @@ -911,6 +912,19 @@ void ICAPModXact::makeRequestHeaders(MemBuf &buf) virginSendClaim.protectAll(); } + const HttpRequest *request = virgin->data->cause ? + virgin->data->cause : + dynamic_cast(virgin->data->header); + + if (request->client_addr.s_addr != any_addr.s_addr) + buf.Printf("X-Client-IP: %s\r\n", inet_ntoa(request->client_addr)); + + if (request->auth_user_request) + if (request->auth_user_request->username()) + buf.Printf("X-Client-Username: %s\r\n", request->auth_user_request->username()); + + fprintf(stderr, "%s\n", buf.content()); + buf.append(ICAP::crlf, 2); // terminate ICAP header // start ICAP request body with encapsulated HTTP headers @@ -1049,8 +1063,8 @@ void ICAPModXact::estimateVirginBody() if (virgin->data->cause) method = virgin->data->cause->method; else - if (HttpRequest *req= dynamic_cast(virgin->data-> - header)) + if (HttpRequest *req = dynamic_cast(virgin->data-> + header)) method = req->method; else return;