From: wessels <> Date: Mon, 26 Jun 2000 04:41:21 +0000 (+0000) Subject: DW: X-Git-Tag: SQUID_3_0_PRE1~1923 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=56fe752ea48149adccb1333e25b114f4b0eb0cbb;p=thirdparty%2Fsquid.git DW: - Support for extension methods via squid.conf. The admin can define up to 20 additional methods with the 'extension_methods' wordlist. Methods are converted to uppercase, and put into the RequestMethodStr[] array, replacing some placeholders. --- diff --git a/src/cache_cf.cc b/src/cache_cf.cc index 21e05acd6f..c9a328c171 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -1,6 +1,6 @@ /* - * $Id: cache_cf.cc,v 1.351 2000/06/25 22:28:42 wessels Exp $ + * $Id: cache_cf.cc,v 1.352 2000/06/25 22:41:21 wessels Exp $ * * DEBUG: section 3 Configuration File Parsing * AUTHOR: Harvest Derived @@ -413,6 +413,7 @@ configDoConfigure(void) xstrerror()); Config2.effectiveGroupID = grp->gr_gid; } + urlExtMethodConfigure(); } /* Parse a time specification from the config file. Store the diff --git a/src/cf.data.pre b/src/cf.data.pre index 3488e763ec..1a395f7261 100644 --- a/src/cf.data.pre +++ b/src/cf.data.pre @@ -1,6 +1,6 @@ # -# $Id: cf.data.pre,v 1.188 2000/06/08 18:05:35 hno Exp $ +# $Id: cf.data.pre,v 1.189 2000/06/25 22:41:21 wessels Exp $ # # # SQUID Internet Object Cache http://squid.nlanr.net/Squid/ @@ -3185,5 +3185,14 @@ DOC_START disable persistent connections with clients and/or servers. DOC_END +NAME: extension_methods +TYPE: wordlist +LOC: Config.ext_methods +DEFAULT: none +DOC_START + Squid only knows about standardized HTTP request methods. + You can add up to 20 additional "extension" methods here. +DOC_END + EOF diff --git a/src/enums.h b/src/enums.h index 301abb32e6..e8f01958a0 100644 --- a/src/enums.h +++ b/src/enums.h @@ -1,6 +1,6 @@ /* - * $Id: enums.h,v 1.167 2000/05/03 17:15:41 adrian Exp $ + * $Id: enums.h,v 1.168 2000/06/25 22:41:22 wessels Exp $ * * * SQUID Internet Object Cache http://squid.nlanr.net/Squid/ @@ -384,6 +384,26 @@ enum { METHOD_MOVE, METHOD_LOCK, METHOD_UNLOCK, + METHOD_EXT00, + METHOD_EXT01, + METHOD_EXT02, + METHOD_EXT03, + METHOD_EXT04, + METHOD_EXT05, + METHOD_EXT06, + METHOD_EXT07, + METHOD_EXT08, + METHOD_EXT09, + METHOD_EXT10, + METHOD_EXT11, + METHOD_EXT12, + METHOD_EXT13, + METHOD_EXT14, + METHOD_EXT15, + METHOD_EXT16, + METHOD_EXT17, + METHOD_EXT18, + METHOD_EXT19, METHOD_ENUM_END }; typedef unsigned int method_t; diff --git a/src/protos.h b/src/protos.h index 5235c335ea..8d0ef363e4 100644 --- a/src/protos.h +++ b/src/protos.h @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.372 2000/06/25 22:28:43 wessels Exp $ + * $Id: protos.h,v 1.373 2000/06/25 22:41:22 wessels Exp $ * * * SQUID Internet Object Cache http://squid.nlanr.net/Squid/ @@ -1029,6 +1029,7 @@ extern int urlCheckRequest(const request_t *); extern int urlDefaultPort(protocol_t p); extern char *urlCanonicalClean(const request_t *); extern char *urlHostname(const char *url); +extern void urlExtMethodConfigure(); extern void useragentOpenLog(void); extern void useragentRotateLog(void); diff --git a/src/structs.h b/src/structs.h index 81b66f1ab6..a401f96bed 100644 --- a/src/structs.h +++ b/src/structs.h @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.340 2000/06/25 22:28:43 wessels Exp $ + * $Id: structs.h,v 1.341 2000/06/25 22:41:22 wessels Exp $ * * * SQUID Internet Object Cache http://squid.nlanr.net/Squid/ @@ -498,6 +498,7 @@ struct _SquidConfig { int rebuild_chunk_percentage; } digest; #endif + wordlist *ext_methods; }; struct _SquidConfig2 { diff --git a/src/url.cc b/src/url.cc index c5c0cc13ed..809184f930 100644 --- a/src/url.cc +++ b/src/url.cc @@ -1,6 +1,6 @@ /* - * $Id: url.cc,v 1.125 2000/05/16 07:06:08 wessels Exp $ + * $Id: url.cc,v 1.126 2000/06/25 22:41:22 wessels Exp $ * * DEBUG: section 23 URL Parsing * AUTHOR: Duane Wessels @@ -54,6 +54,26 @@ const char *RequestMethodStr[] = "MOVE", "LOCK", "UNLOCK", + "%EXT00", + "%EXT01", + "%EXT02", + "%EXT03", + "%EXT04", + "%EXT05", + "%EXT06", + "%EXT07", + "%EXT08", + "%EXT09", + "%EXT10", + "%EXT11", + "%EXT12", + "%EXT13", + "%EXT14", + "%EXT15", + "%EXT16", + "%EXT17", + "%EXT18", + "%EXT19", "ERROR" }; @@ -150,6 +170,13 @@ method_t urlParseMethod(const char *s) { method_t method = METHOD_NONE; + /* + * This check for '%' makes sure that we don't + * match one of the extension method placeholders, + * which have the form %EXT[0-9][0-9] + */ + if (*s == '%') + return METHOD_NONE; for (method++; method < METHOD_ENUM_END; method++) { if (0 == strcasecmp(s, RequestMethodStr[method])) return method; @@ -559,3 +586,35 @@ urlHostname(const char *url) } return host; } + +static void +urlExtMethodAdd(const char *mstr) +{ + method_t method = 0; + for (method++; method < METHOD_ENUM_END; method++) { + if (0 == strcmp(mstr, RequestMethodStr[method])) { + debug(23, 2) ("Extension method '%s' already exists\n", mstr); + return; + } + if (0 != strncmp("%EXT", RequestMethodStr[method], 4)) + continue; + /* Don't free statically allocated "%EXTnn" string */ + RequestMethodStr[method] = xstrdup(mstr); + debug(23, 1) ("Extension method '%s' added, enum=%d\n", mstr, (int) method); + return; + } + debug(23, 1) ("WARNING: Could not add new extension method '%s' due to lack of array space\n", mstr); +} + +void +urlExtMethodConfigure(void) +{ + wordlist *w = Config.ext_methods; + while (w) { + char *s; + for (s = w->key; *s; s++) + *s = xtoupper(*s); + urlExtMethodAdd(w->key); + w = w->next; + } +}