]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
An ICAP server is allowed to list multiple methods in an options
authorwessels <>
Fri, 17 Feb 2006 03:44:07 +0000 (03:44 +0000)
committerwessels <>
Fri, 17 Feb 2006 03:44:07 +0000 (03:44 +0000)
response.  Previous code complained if there were multiple methods.

src/ICAP/ICAPOptions.cc
src/ICAP/ICAPOptions.h
src/ICAP/ICAPServiceRep.cc

index a779114c63f9f98b857dc120bc22d98df51ed7cd..766174ac7f7b9c60380b0b51c1dbba462827bac0 100644 (file)
@@ -6,7 +6,7 @@
 
 extern ICAPConfig TheICAPConfig;
 
-ICAPOptions::ICAPOptions(): error("unconfigured"), method(ICAP::methodNone),
+ICAPOptions::ICAPOptions(): error("unconfigured"),
         max_connections(-1), allow204(false),
         preview(-1), theTTL(-1), transfer_ext(NULL)
 {
@@ -176,11 +176,7 @@ void ICAPOptions::configure(const HttpReply *reply)
 void ICAPOptions::cfgMethod(ICAP::Method m)
 {
     Must(m != ICAP::methodNone);
-
-    if (method == ICAP::methodNone)
-        method = m;
-    else
-        error = "the service claims to support several request methods";
+    methods += m;
 }
 
 // TODO: HttpHeader should provide a general method for this type of conversion
index cb0658c1d0102899ce81469f3760df1c50e2b4d7..ca5bca9baa07a5fca1cb50d5d4d9c9117e7ef5bd 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ICAPOptions.h,v 1.6 2005/12/23 17:36:19 wessels Exp $
+ * $Id: ICAPOptions.h,v 1.7 2006/02/16 20:44:07 wessels Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -68,7 +68,7 @@ public:
     const char *error; // human-readable information; set iff !valid()
 
     // ICAP server MUST supply this info
-    ICAP::Method method;
+    Vector<ICAP::Method> methods;
     String istag;
 
     // ICAP server MAY supply this info. If not, Squid supplies defaults.
index 72a1ed514bb63a78bec57e351e3fcf3bcc37964c..7ddcad7e2d7d3df7e18b8439a430fb8df3017527 100644 (file)
@@ -283,14 +283,39 @@ void ICAPServiceRep::changeOptions(ICAPOptions *newOptions)
         return;
 
     /*
-     * Maybe it would be better if squid.conf just listed the URI and
-     * then discovered the method via OPTIONS
+     * Issue a warning if the ICAP server returned methods in the
+     * options response that don't match the method from squid.conf.
      */
 
-    if (theOptions->method != method && theOptions->method != ICAP::methodNone)
-        debugs(93,1, "WARNING: Squid is configured to use ICAP method " << ICAP::methodStr(method) <<
-               " for service " << uri.buf() <<
-               " but OPTIONS response declares the method is " << ICAP::methodStr(theOptions->method));
+    if (!theOptions->methods.empty()) {
+        bool method_found = false;
+        String method_list;
+        Vector <ICAP::Method>::iterator iter = theOptions->methods.begin();
+        debugs(0,0,HERE);
+
+        while (iter != theOptions->methods.end()) {
+            debugs(0,0,HERE);
+
+            if (*iter == method) {
+                method_found = true;
+                break;
+            }
+
+            method_list.append(ICAP::methodStr(*iter));
+            method_list.append(" ", 1);
+            iter++;
+            debugs(0,0,HERE);
+        }
+
+        debugs(0,0,HERE);
+
+        if (!method_found) {
+            debugs(93,1, "WARNING: Squid is configured to use ICAP method " <<
+                   ICAP::methodStr(method) <<
+                   " for service " << uri.buf() <<
+                   " but OPTIONS response declares the methods are " << method_list.buf());
+        }
+    }
 
 
     /*