---------------------
PatchSet 1923 
Date: 2005/10/03 16:10:01
Author: dwsquid
Branch: squid3-icap
Tag: (none) 
Log:
Added icap access check to REQMOD processing

Members: 
	src/ClientRequestContext.h:1.1.2.1->1.1.2.2 
	src/ICAPClientSideHook.cc:1.1.2.8->1.1.2.9 
	src/ICAPClientSideHook.h:1.1.2.3->1.1.2.4 
	src/client_side_request.cc:1.34.4.9->1.34.4.10 
	src/client_side_request.h:1.17.12.4->1.17.12.5 

Index: squid3/src/ClientRequestContext.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/ClientRequestContext.h,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- squid3/src/ClientRequestContext.h	24 Sep 2005 18:19:23 -0000	1.1.2.1
+++ squid3/src/ClientRequestContext.h	3 Oct 2005 16:10:01 -0000	1.1.2.2
@@ -1,3 +1,6 @@
+#if ICAP_CLIENT
+#include "ICAPServiceRep.h"
+#endif
 
 class ClientRequestContext : public RefCountable
 {
@@ -16,6 +19,11 @@
     void clientRedirectDone(char *result);
     void checkNoCache();
     void checkNoCacheDone(int answer);
+#if ICAP_CLIENT
+
+    void icapAccessCheck();
+    void icapAclCheckDone(ICAPServiceRep::Pointer service);
+#endif
 
     ClientHttpRequest *http;
     ACLChecklist *acl_checklist;        /* need ptr back so we can unreg if needed */
@@ -25,7 +33,7 @@
     1;
 #if ICAP_CLIENT
 
-int icap_reqmod_done:
+int icap_acl_check_done:
     1;
 #endif
 
Index: squid3/src/ICAPClientSideHook.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/Attic/ICAPClientSideHook.cc,v
retrieving revision 1.1.2.8
retrieving revision 1.1.2.9
diff -u -r1.1.2.8 -r1.1.2.9
--- squid3/src/ICAPClientSideHook.cc	1 Oct 2005 05:09:11 -0000	1.1.2.8
+++ squid3/src/ICAPClientSideHook.cc	3 Oct 2005 16:10:01 -0000	1.1.2.9
@@ -16,7 +16,7 @@
 
 CBDATA_CLASS_INIT(ICAPClientSideHook);
 
-ICAPClientSideHook::ICAPClientSideHook(): http(NULL), virgin(NULL), adapted(NULL)
+ICAPClientSideHook::ICAPClientSideHook(ICAPServiceRep::Pointer aService): service(aService), http(NULL), virgin(NULL), adapted(NULL)
 {
     debug(93,3)("ICAPClientSideHook constructed, this=%p\n", this);
 }
@@ -52,8 +52,7 @@
     leakTouch(adapted.getRaw(), MsgPipeLeaker);
     adapted->sink = this;
 
-    fatal("fix following ICAPInitXaction() call");
-    ICAPInitXaction(NULL, virgin, adapted);
+    ICAPInitXaction(service, virgin, adapted);
 
     virgin->sendSourceStart(); // we may have virgin data to provide
     adapted->sendSinkNeed();   // we want adapted response, eventially
Index: squid3/src/ICAPClientSideHook.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/Attic/ICAPClientSideHook.h,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -r1.1.2.3 -r1.1.2.4
--- squid3/src/ICAPClientSideHook.h	21 Sep 2005 20:36:07 -0000	1.1.2.3
+++ squid3/src/ICAPClientSideHook.h	3 Oct 2005 16:10:01 -0000	1.1.2.4
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ICAPClientSideHook.h,v 1.1.2.3 2005/09/21 20:36:07 dwsquid Exp $
+ * $Id: ICAPClientSideHook.h,v 1.1.2.4 2005/10/03 16:10:01 dwsquid Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -54,7 +54,7 @@
 {
 
 public:
-    ICAPClientSideHook();
+    ICAPClientSideHook(ICAPServiceRep::Pointer);
     virtual ~ICAPClientSideHook();
 
     // synchronous calls called by ClientHttpRequest
@@ -75,6 +75,7 @@
     virtual void noteSourceAbort(MsgPipe *p);
 
 public:
+    ICAPServiceRep::Pointer service;
     ClientHttpRequest *http;
     MsgPipe::Pointer virgin;
     MsgPipe::Pointer adapted;
Index: squid3/src/client_side_request.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/client_side_request.cc,v
retrieving revision 1.34.4.9
retrieving revision 1.34.4.10
diff -u -r1.34.4.9 -r1.34.4.10
--- squid3/src/client_side_request.cc	30 Sep 2005 22:57:21 -0000	1.34.4.9
+++ squid3/src/client_side_request.cc	3 Oct 2005 16:10:01 -0000	1.34.4.10
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client_side_request.cc,v 1.34.4.9 2005/09/30 22:57:21 dwsquid Exp $
+ * $Id: client_side_request.cc,v 1.34.4.10 2005/10/03 16:10:01 dwsquid Exp $
  * 
  * DEBUG: section 85    Client-side Request Routines
  * AUTHOR: Robert Collins (Originally Duane Wessels in client_side.c)
@@ -57,6 +57,8 @@
 
 #if ICAP_CLIENT
 #include "ICAPClientSideHook.h"
+#include "ICAPConfig.h"
+static void icapAclCheckDoneWrapper(ICAPServiceRep::Pointer service, void *data);
 #endif
 
 #if LINGERING_CLOSE
@@ -457,6 +459,43 @@
     http->doCallouts();
 }
 
+#if ICAP_CLIENT
+void
+ClientRequestContext::icapAccessCheck()
+{
+    ICAPAccessCheck *icap_access_check;
+
+    if (icap_access_check = new ICAPAccessCheck(ICAPServiceRep::reqmod, ICAPServiceRep::precache, http->request, NULL, icapAclCheckDoneWrapper, this)) {
+        icap_access_check->check();
+        return;
+    }
+
+    http->doCallouts();
+}
+
+static void
+icapAclCheckDoneWrapper(ICAPServiceRep::Pointer service, void *data)
+{
+    ClientRequestContext *calloutContext = (ClientRequestContext *)data;
+    calloutContext->icapAclCheckDone(service);
+}
+
+void
+ClientRequestContext::icapAclCheckDone(ICAPServiceRep::Pointer service)
+{
+    if (service == NULL) {
+        assert(false);
+        return;
+    }
+
+    if (0 == http->doIcap(service))
+        return;
+
+    http->doCallouts();
+}
+
+#endif
+
 static void
 clientRedirectAccessCheckDone(int answer, void *data)
 {
@@ -980,18 +1019,15 @@
         return;
     }
 
-#if ICAP_CLIENT && 0
-    if (!calloutContext->icap_reqmod_done) {
-        calloutContext->icap_reqmod_done = 1;
-
-        if (0 == doIcap()) {
-            icap->startReqMod(this, request);
-            icap->doneSending();
-            return;
-        }
+#if ICAP_CLIENT
+    if (!calloutContext->icap_acl_check_done) {
+        calloutContext->icap_acl_check_done = 1;
+        calloutContext->icapAccessCheck();
+        return;
     }
 
 #endif
+
     if (!calloutContext->redirect_done) {
         calloutContext->redirect_done = 1;
         assert(calloutContext->redirect_state == REDIRECT_NONE);
@@ -1035,12 +1071,14 @@
  * or take other action.
  */
 int
-ClientHttpRequest::doIcap()
+ClientHttpRequest::doIcap(ICAPServiceRep::Pointer service)
 {
     debug(85,3)("ClientHttpRequest::doIcap() called\n");
     assert(NULL == icap);
-    icap = new ICAPClientSideHook;
+    icap = new ICAPClientSideHook(service);
     (void) cbdataReference(icap);
+    icap->startReqMod(this, request);
+    icap->doneSending();
     return 0;
 }
 
Index: squid3/src/client_side_request.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/client_side_request.h,v
retrieving revision 1.17.12.4
retrieving revision 1.17.12.5
diff -u -r1.17.12.4 -r1.17.12.5
--- squid3/src/client_side_request.h	21 Sep 2005 20:33:38 -0000	1.17.12.4
+++ squid3/src/client_side_request.h	3 Oct 2005 16:10:01 -0000	1.17.12.5
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client_side_request.h,v 1.17.12.4 2005/09/21 20:33:38 dwsquid Exp $
+ * $Id: client_side_request.h,v 1.17.12.5 2005/10/03 16:10:01 dwsquid Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -40,6 +40,7 @@
 #include "AccessLogEntry.h"
 
 #if ICAP_CLIENT
+#include "ICAPServiceRep.h"
 
 class ICAPClientSideHook;
 
@@ -155,7 +156,7 @@
 
 public:
     ICAPClientSideHook *icap;
-    int doIcap();
+    int doIcap(ICAPServiceRep::Pointer);
     void icapSpaceAvailable();
     void takeAdaptedHeaders(HttpMsg *);
     void takeAdaptedBody(MemBuf *);
