From: wessels <> Date: Fri, 21 Aug 1998 10:03:44 +0000 (+0000) Subject: put http-violating code inside HTTP_VIOLATIONS X-Git-Tag: SQUID_3_0_PRE1~2822 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9f60cfdf80c1decb9081afeca93f4b791dc95f0b;p=thirdparty%2Fsquid.git put http-violating code inside HTTP_VIOLATIONS --- diff --git a/src/cache_cf.cc b/src/cache_cf.cc index ff4213320a..75566c4979 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -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; diff --git a/src/cf.data.pre b/src/cf.data.pre index ee475fe563..c2ebaac285 100644 --- a/src/cf.data.pre +++ b/src/cf.data.pre @@ -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 diff --git a/src/client_side.cc b/src/client_side.cc index 8b5e4e1ee8..f088aec341 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -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); diff --git a/src/globals.h b/src/globals.h index f2d62ad96e..ffb87de9ae 100644 --- a/src/globals.h +++ b/src/globals.h @@ -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; diff --git a/src/refresh.cc b/src/refresh.cc index dc1d1eeb80..92e7625705 100644 --- a/src/refresh.cc +++ b/src/refresh.cc @@ -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); diff --git a/src/structs.h b/src/structs.h index fa3641fe95..8c8584db4a 100644 --- a/src/structs.h +++ b/src/structs.h @@ -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; };