From: wessels <> Date: Fri, 17 Feb 2006 03:44:07 +0000 (+0000) Subject: An ICAP server is allowed to list multiple methods in an options X-Git-Tag: SQUID_3_0_PRE4~333 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=eadded2e52c63530f2c63b17eb57a47811afdde4;p=thirdparty%2Fsquid.git An ICAP server is allowed to list multiple methods in an options response. Previous code complained if there were multiple methods. --- diff --git a/src/ICAP/ICAPOptions.cc b/src/ICAP/ICAPOptions.cc index a779114c63..766174ac7f 100644 --- a/src/ICAP/ICAPOptions.cc +++ b/src/ICAP/ICAPOptions.cc @@ -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 diff --git a/src/ICAP/ICAPOptions.h b/src/ICAP/ICAPOptions.h index cb0658c1d0..ca5bca9baa 100644 --- a/src/ICAP/ICAPOptions.h +++ b/src/ICAP/ICAPOptions.h @@ -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 methods; String istag; // ICAP server MAY supply this info. If not, Squid supplies defaults. diff --git a/src/ICAP/ICAPServiceRep.cc b/src/ICAP/ICAPServiceRep.cc index 72a1ed514b..7ddcad7e2d 100644 --- a/src/ICAP/ICAPServiceRep.cc +++ b/src/ICAP/ICAPServiceRep.cc @@ -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 ::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()); + } + } /*