]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
DW:
authorwessels <>
Mon, 26 Jun 2000 04:41:21 +0000 (04:41 +0000)
committerwessels <>
Mon, 26 Jun 2000 04:41:21 +0000 (04:41 +0000)
 - 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.

src/cache_cf.cc
src/cf.data.pre
src/enums.h
src/protos.h
src/structs.h
src/url.cc

index 21e05acd6f1f644a716dfc8e6b7d21165b9e1c2a..c9a328c171c445568e52ec9b3a61a584fd18ece3 100644 (file)
@@ -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
index 3488e763ec535ce34d174094944b788402706be7..1a395f72617e9de37e6a5337085e996ef35e4f85 100644 (file)
@@ -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
 
index 301abb32e6820e884e0052ee627fe36101ca8092..e8f01958a09ebbe3681548e579b5ef6d3580120f 100644 (file)
@@ -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;
index 5235c335eaef6609135b7ae8cbc2c5965db2eb80..8d0ef363e451266c7213b981517336a3be40cc03 100644 (file)
@@ -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);
index 81b66f1ab67f3877be646a169a5b60e05a6967fe..a401f96bedab48cb37a18a51a19d8d524883ae85 100644 (file)
@@ -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 {
index c5c0cc13ed4af09fc6fccf686eae54b903f5e579..809184f9300c0fb240fc0305c4f7a70a2a351274 100644 (file)
@@ -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;
+    }
+}