]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
put http-violating code inside HTTP_VIOLATIONS
authorwessels <>
Fri, 21 Aug 1998 10:03:44 +0000 (10:03 +0000)
committerwessels <>
Fri, 21 Aug 1998 10:03:44 +0000 (10:03 +0000)
src/cache_cf.cc
src/cf.data.pre
src/client_side.cc
src/globals.h
src/refresh.cc
src/structs.h

index ff4213320a405cb2f1ddd4d79eb3b5e463bf0161..75566c4979d5610fc094fed39a9f1d4c61d9abac 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: cache_cf.cc,v 1.300 1998/08/20 22:45:44 wessels Exp $
+ * $Id: cache_cf.cc,v 1.301 1998/08/21 04:03:44 wessels Exp $
  *
  * DEBUG: section 3     Configuration File Parsing
  * AUTHOR: Harvest Derived
@@ -210,7 +210,6 @@ static void
 configDoConfigure(void)
 {
     LOCAL_ARRAY(char, buf, BUFSIZ);
-    const refresh_t *R;
     memset(&Config2, '\0', sizeof(SquidConfig2));
     /* init memory as early as possible */
     memConfigure();
@@ -306,6 +305,9 @@ configDoConfigure(void)
        requirePathnameExists("authenticate_program", Config.Program.authenticate->key);
     requirePathnameExists("Icon Directory", Config.icons.directory);
     requirePathnameExists("Error Directory", Config.errorDirectory);
+#if HTTP_VIOLATIONS
+    {
+    const refresh_t *R;
     for (R = Config.Refresh; R; R = R->next) {
        if (!R->flags.override_expire)
            continue;
@@ -318,6 +320,8 @@ configDoConfigure(void)
        debug(22, 1) ("WARNING: use of 'override-lastmod' in 'refresh_pattern' violates HTTP\n");
        break;
     }
+    }
+#endif
 }
 
 /* Parse a time specification from the config file.  Store the
@@ -1115,17 +1119,24 @@ static void
 dump_refreshpattern(StoreEntry * entry, const char *name, refresh_t * head)
 {
     while (head != NULL) {
-       storeAppendPrintf(entry, "%s%s %s %d %d%% %d%s%s%s%s\n",
+       storeAppendPrintf(entry, "%s%s %s %d %d%% %d\n",
            name,
            head->flags.icase ? " -i" : null_string,
            head->pattern,
            (int) head->min / 60,
            (int) (100.0 * head->pct + 0.5),
-           (int) head->max / 60,
-           head->flags.override_expire ? " override-expire" : null_string,
-           head->flags.override_lastmod ? " override-lastmod" : null_string,
-           head->flags.reload_into_ims ? " reload-into-ims" : null_string,
-           head->flags.ignore_reload ? " ignore-reload" : null_string);
+           (int) head->max / 60);
+#if HTTP_VIOLATIONS
+       if (head->flags.override_expire)
+           storeAppendPrintf(entry, " override-expire");
+       if (head->flags.override_lastmod)
+           storeAppendPrintf(entry, " override-lastmod");
+       if (head->flags.reload_into_ims)
+           storeAppendPrintf(entry, " reload-into-ims");
+       if (head->flags.ignore_reload)
+           storeAppendPrintf(entry, " ignore-reload");
+#endif
+       storeAppendPrintf(entry, "\n");
        head = head->next;
     }
 }
@@ -1138,10 +1149,12 @@ parse_refreshpattern(refresh_t ** head)
     time_t min = 0;
     double pct = 0.0;
     time_t max = 0;
+#if HTTP_VIOLATIONS
     int override_expire = 0;
     int override_lastmod = 0;
     int reload_into_ims = 0;
     int ignore_reload = 0;
+#endif
     int i;
     refresh_t *t;
     regex_t comp;
@@ -1167,6 +1180,7 @@ parse_refreshpattern(refresh_t ** head)
     max = (time_t) (i * 60);   /* convert minutes to seconds */
     /* Options */
     while ((token = strtok(NULL, w_space)) != NULL) {
+#if HTTP_VIOLATIONS
        if (!strcmp(token, "override-expire"))
            override_expire = 1;
        else if (!strcmp(token, "override-expire"))
@@ -1180,6 +1194,7 @@ parse_refreshpattern(refresh_t ** head)
            refresh_nocache_hack = 1;
            /* tell client_side.c that this is used */
        } else
+#endif
            debug(22, 0) ("redreshAddToList: Unknown option '%s': %s\n",
                pattern, token);
     }
@@ -1202,6 +1217,7 @@ parse_refreshpattern(refresh_t ** head)
     t->max = max;
     if (flags & REG_ICASE)
        t->flags.icase = 1;
+#if HTTP_VIOLATIONS
     if (override_expire)
        t->flags.override_expire = 1;
     if (override_lastmod)
@@ -1210,6 +1226,7 @@ parse_refreshpattern(refresh_t ** head)
        t->flags.reload_into_ims = 1;
     if (ignore_reload)
        t->flags.ignore_reload = 1;
+#endif
     t->next = NULL;
     while (*head)
        head = &(*head)->next;
index ee475fe563521de34c7d00bf90efd4da84be1b86..c2ebaac2853e17fd4895cee5df16453f167d887e 100644 (file)
@@ -1,6 +1,6 @@
 
 #
-# $Id: cf.data.pre,v 1.99 1998/08/20 22:45:45 wessels Exp $
+# $Id: cf.data.pre,v 1.100 1998/08/21 04:03:45 wessels Exp $
 #
 #
 # SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
@@ -2041,6 +2041,7 @@ buffered_logs off
 DOC_END
 
 NAME: reload_into_ims
+IFDEF: HTTP_VIOLATIONS
 COMMENT: on|off
 TYPE: onoff
 DEFAULT: off
index 8b5e4e1ee881d87488474cf93a887dfa802854ec..f088aec34130036cfd3375625978d7bf01173714 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client_side.cc,v 1.385 1998/08/21 03:15:15 wessels Exp $
+ * $Id: client_side.cc,v 1.386 1998/08/21 04:03:46 wessels Exp $
  *
  * DEBUG: section 33    Client-side Routines
  * AUTHOR: Duane Wessels
@@ -680,11 +680,13 @@ clientInterpretRequestHeaders(clientHttpRequest * http)
     if (httpHeaderHas(req_hdr, HDR_PRAGMA)) {
        String s = httpHeaderGetList(req_hdr, HDR_PRAGMA);
        if (strListIsMember(&s, "no-cache", ',')) {
+#if HTTP_VIOLATIONS
            if (Config.onoff.reload_into_ims)
                request->flags.nocache_hack = 1;
            else if (refresh_nocache_hack)
                request->flags.nocache_hack = 1;
            else
+#endif
                request->flags.nocache = 1;
        }
        stringClean(&s);
@@ -1600,10 +1602,12 @@ clientProcessRequest2(clientHttpRequest * http)
        /* Special entries are always hits, no matter what the client says */
        http->entry = e;
        return LOG_TCP_HIT;
+#if HTTP_VIOLATIONS
     } else if (r->flags.nocache_hack) {
        http->entry = NULL;
        ipcacheReleaseInvalid(r->host);
        return LOG_TCP_CLIENT_REFRESH_MISS;
+#endif
     } else if (r->flags.nocache) {
        http->entry = NULL;
        ipcacheReleaseInvalid(r->host);
index f2d62ad96e78bd6efe2cf6b4c7621ed96ae38099..ffb87de9aecdd646e7857021e7f2a0202109b83f 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: globals.h,v 1.65 1998/08/21 03:15:17 wessels Exp $
+ * $Id: globals.h,v 1.66 1998/08/21 04:03:47 wessels Exp $
  *
  *
  * SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
@@ -138,5 +138,7 @@ extern icpUdpData *IcpQueueHead;    /* NULL */
 #if DELAY_POOLS
 extern time_t delay_pools_last_update; /* 0 */
 #endif
+#if HTTP_VIOLATIONS
 extern int refresh_nocache_hack;       /* 0 */
+#endif
 extern request_flags null_request_flags;
index dc1d1eeb80e19d33110c8c0ea992c70eeb0d9474..92e76257051d66d35234691f3e016c6fb2a3a148 100644 (file)
@@ -1,7 +1,7 @@
 
 
 /*
- * $Id: refresh.cc,v 1.33 1998/08/21 03:15:23 wessels Exp $
+ * $Id: refresh.cc,v 1.34 1998/08/21 04:03:48 wessels Exp $
  *
  * DEBUG: section 22    Refresh Calculation
  * AUTHOR: Harvest Derived
@@ -101,10 +101,12 @@ refreshCheck(const StoreEntry * entry, request_t * request, time_t delta)
     time_t min = REFRESH_DEFAULT_MIN;
     double pct = REFRESH_DEFAULT_PCT;
     time_t max = REFRESH_DEFAULT_MAX;
+#if HTTP_VIOLATIONS
     int override_expire = 0;
     int override_lastmod = 0;
     int reload_into_ims = 0;
     int ignore_reload = 0;
+#endif
     const char *pattern = ".";
     time_t age;
     double factor;
@@ -125,19 +127,24 @@ refreshCheck(const StoreEntry * entry, request_t * request, time_t delta)
        pct = R->pct;
        max = R->max;
        pattern = R->pattern;
+#if HTTP_VIOLATIONS
        override_expire = R->flags.override_expire;
        override_lastmod = R->flags.override_lastmod;
        reload_into_ims = R->flags.reload_into_ims;
        ignore_reload = R->flags.ignore_reload;
+#endif
     }
+#if HTTP_VIOLATIONS
     if (!reload_into_ims)
        reload_into_ims = Config.onoff.reload_into_ims;
+#endif
     debug(22, 3) ("refreshCheck: Matched '%s %d %d%% %d'\n",
        pattern, (int) min, (int) (100.0 * pct), (int) max);
     age = check_time - entry->timestamp;
     debug(22, 3) ("refreshCheck: age = %d\n", (int) age);
     debug(22, 3) ("\tcheck_time:\t%s\n", mkrfc1123(check_time));
     debug(22, 3) ("\tentry->timestamp:\t%s\n", mkrfc1123(entry->timestamp));
+#if HTTP_VIOLATIONS
     if (request->flags.nocache_hack) {
        if (ignore_reload) {
            /* The clients no-cache header is ignored */
@@ -153,6 +160,7 @@ refreshCheck(const StoreEntry * entry, request_t * request, time_t delta)
            return 1;
        }
     }
+#endif
     if (request->max_age > -1) {
        if (age > request->max_age) {
            debug(22, 3) ("refreshCheck: YES: age > client-max-age\n");
@@ -160,10 +168,12 @@ refreshCheck(const StoreEntry * entry, request_t * request, time_t delta)
            return 1;
        }
     }
+#if HTTP_VIOLATIONS
     if (override_expire && age <= min) {
        debug(22, 3) ("refreshCheck: NO: age < min && override_expire\n");
        return 0;
     }
+#endif
     if (entry->expires > -1) {
        if (entry->expires <= check_time) {
            debug(22, 3) ("refreshCheck: YES: expires <= curtime\n");
@@ -180,10 +190,12 @@ refreshCheck(const StoreEntry * entry, request_t * request, time_t delta)
        refreshCounts.conf_max_age_stale++;
        return 1;
     }
+#if HTTP_VIOLATIONS
     if (override_lastmod && age <= min) {
        debug(22, 3) ("refreshCheck: NO: age < min && override_lastmod\n");
        return 0;
     }
+#endif
     if (entry->lastmod > -1 && entry->timestamp > entry->lastmod) {
        factor = (double) age / (double) (entry->timestamp - entry->lastmod);
        debug(22, 3) ("refreshCheck: factor = %f\n", factor);
index fa3641fe9587ea7c6fb257389510d3039dbfbebd..8c8584db4ac5a9161e44255d1f8404becdb2c8fd 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: structs.h,v 1.208 1998/08/21 03:15:26 wessels Exp $
+ * $Id: structs.h,v 1.209 1998/08/21 04:03:49 wessels Exp $
  *
  *
  * SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
@@ -363,7 +363,9 @@ struct _SquidConfig {
        int mem_pools;
        int test_reachability;
        int half_closed_clients;
+#if HTTP_VIOLATIONS
        int reload_into_ims;
+#endif
     } onoff;
     acl *aclList;
     struct {
@@ -1197,7 +1199,9 @@ struct _request_flags {
     int refresh:1;
     int used_proxy_auth:1;
     int redirected:1;
+#if HTTP_VIOLATIONS
     int nocache_hack:1;                /* for changing/ignoring no-cache requests */
+#endif
 };
 
 struct _request_t {
@@ -1244,10 +1248,12 @@ struct _refresh_t {
     refresh_t *next;
     struct {
        unsigned int icase:1;
+#if HTTP_VIOLATIONS
        unsigned int override_expire:1;
        unsigned int override_lastmod:1;
        unsigned int reload_into_ims:1;
        unsigned int ignore_reload:1;
+#endif
     } flags;
 };