]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
A few changes related to how the ICAP request header is built:
authorwessels <>
Fri, 2 Dec 2005 06:23:59 +0000 (06:23 +0000)
committerwessels <>
Fri, 2 Dec 2005 06:23:59 +0000 (06:23 +0000)
 - Added 'icap_persistent_connections' directive to squid.conf to turn
   on/off ICAP server connection reuse.

 - Renamed 'icap_send_auth_user' directive to 'icap_send_client_username'

 - Removed 'icap_auth_scheme' directive since it is not currently used.

 - Fixed ICAPModXact::makeRequestHeaders() to add X-Client-IP and
   X-Client-Username only when those options are enabled in squid.conf.

src/ICAP/ICAPConfig.h
src/ICAP/ICAPModXact.cc
src/cf.data.pre

index 7aef4fdac4467ac5dcb7b2073838dd88b75735b9..0b95ee8742fa637e6e2b7cf2b01319e0ea431ecf 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ICAPConfig.h,v 1.4 2005/12/01 23:19:24 wessels Exp $
+ * $Id: ICAPConfig.h,v 1.5 2005/12/01 23:24:00 wessels Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -95,8 +95,8 @@ public:
     int preview_enable;
     int preview_size;
     int send_client_ip;
-    int auth_user;
-    char *auth_scheme;
+    int send_client_username;
+    int reuse_connections;
 
     Vector<ICAPServiceRep::Pointer> services;
     Vector<ICAPClass*> classes;
index 90affe8445b02b4f9bb32481c5758144eedf57ca..b36156401dee92e69f83bfda20ff3021c6be4e7d 100644 (file)
@@ -14,6 +14,7 @@
 #include "ChunkedCodingParser.h"
 #include "TextException.h"
 #include "AuthUserRequest.h"
+#include "ICAPConfig.h"
 
 // flow and terminology:
 //     HTTP| --> receive --> encode --> write --> |network
@@ -28,6 +29,8 @@ CBDATA_CLASS_INIT(ICAPModXact);
 
 static const size_t TheBackupLimit = ICAP::MsgPipeBufSizeMax;
 
+extern ICAPConfig TheICAPConfig;
+
 
 ICAPModXact::State::State()
 {
@@ -872,12 +875,21 @@ void ICAPModXact::doStop()
 
 void ICAPModXact::makeRequestHeaders(MemBuf &buf)
 {
+    /*
+     * XXX These should use HttpHdr interfaces instead of Printfs
+     */
     const ICAPServiceRep &s = service();
     buf.Printf("%s %s ICAP/1.0\r\n", s.methodStr(), s.uri.buf());
     buf.Printf("Host: %s:%d\r\n", s.host.buf(), s.port);
+    buf.Printf("Date: %s\r\n", mkrfc1123(squid_curtime));
+
+    if (!TheICAPConfig.reuse_connections)
+        buf.Printf("Connection: close\r\n");
+
     buf.Printf("Encapsulated: ");
 
     MemBuf httpBuf;
+
     httpBuf.init();
 
     // build HTTP request header, if any
@@ -916,12 +928,14 @@ void ICAPModXact::makeRequestHeaders(MemBuf &buf)
                                  virgin->data->cause :
                                  dynamic_cast<const HttpRequest*>(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 (TheICAPConfig.send_client_ip)
+        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());
+    if (TheICAPConfig.send_client_username)
+        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());
 
index a6d5142c0c6c0e0ea38372636bc39e925f7034c8..c5ea12afe4fef09fa4073b48da3d178456117c6b 100644 (file)
@@ -1,6 +1,6 @@
 
 #
-# $Id: cf.data.pre,v 1.407 2005/12/01 23:19:22 wessels Exp $
+# $Id: cf.data.pre,v 1.408 2005/12/01 23:23:59 wessels Exp $
 #
 #
 # SQUID Web Proxy Cache                http://www.squid-cache.org/
@@ -4789,6 +4789,17 @@ DOC_START
         basis by OPTIONS requests.
 DOC_END
 
+NAME: icap_persistent_connections
+TYPE: onoff
+IFDEF: ICAP_CLIENT
+COMMENT: on|off
+LOC: TheICAPConfig.reuse_connections
+DEFAULT: on
+DOC_START
+       Whether or not Squid should use persistent connections to
+       an ICAP server.
+DOC_END
+
 NAME: icap_send_client_ip
 TYPE: onoff
 IFDEF: ICAP_CLIENT
@@ -4799,39 +4810,17 @@ DOC_START
         This adds the header "X-Client-IP" to ICAP requests.
 DOC_END
 
-NAME: icap_send_auth_user
+NAME: icap_send_client_username
 TYPE: onoff
 IFDEF: ICAP_CLIENT
 COMMENT: on|off
-LOC: TheICAPConfig.auth_user
+LOC: TheICAPConfig.send_client_username
 DEFAULT: off
 DOC_START
-        This adds the header "X-Authenticated-User" to ICAP requests
+        This adds the header "X-Client-Username" to ICAP requests
         if proxy access is authentified.
 DOC_END
 
-NAME: icap_auth_scheme
-TYPE: string
-IFDEF: ICAP_CLIENT
-LOC: TheICAPConfig.auth_scheme
-DEFAULT: Local://%u
-DOC_START
-        Authentification scheme to pass to ICAP requests if
-        icap_send_auth_user is enabled. The first occurence of "%u"
-        is replaced by the authentified user name. If no "%u" is found,
-        the username is added at the end of the scheme.
-
-        See http://www.ietf.org/internet-drafts/draft-stecher-icap-subid-00.txt,
-        section 3.4 for details on this.
-
-        Examples:
-
-        icap_auth_scheme Local://%u
-        icap_auth_scheme LDAP://ldap-server/cn=%u,dc=company,dc=com
-        icap_auth_scheme WinNT://nt-domain/%u
-        icap_auth_scheme Radius://radius-server/%u
-DOC_END
-
 NAME: icap_service
 TYPE: icap_service_type
 IFDEF: ICAP_CLIENT