--------------------- PatchSet 4785 Date: 2002/08/26 13:20:36 Author: rbcollins Branch: esi Tag: (none) Log: Surrogate-Control parsing Members: src/ESI.c:1.1.2.29->1.1.2.30 src/HttpHdrSc.c:1.1->1.1.2.1 src/HttpHdrScTarget.c:1.1->1.1.2.1 src/HttpHeader.c:1.15.2.2->1.15.2.3 src/HttpHeaderTools.c:1.7->1.7.36.1 src/HttpReply.c:1.10->1.10.32.1 src/Makefile.am:1.23.2.3->1.23.2.4 src/enums.h:1.37.2.4->1.37.2.5 src/mem.c:1.20.2.1->1.20.2.2 src/protos.h:1.59.2.10->1.59.2.11 src/structs.h:1.61.2.8->1.61.2.9 src/typedefs.h:1.27.2.3->1.27.2.4 Index: squid/src/ESI.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/ESI.c,v retrieving revision 1.1.2.29 retrieving revision 1.1.2.30 diff -u -r1.1.2.29 -r1.1.2.30 --- squid/src/ESI.c 25 Aug 2002 11:20:36 -0000 1.1.2.29 +++ squid/src/ESI.c 26 Aug 2002 13:20:36 -0000 1.1.2.30 @@ -1,6 +1,6 @@ /* - * $Id: ESI.c,v 1.1.2.29 2002/08/25 11:20:36 rbcollins Exp $ + * $Id: ESI.c,v 1.1.2.30 2002/08/26 13:20:36 rbcollins Exp $ * * DEBUG: section 86 ESI processing * AUTHOR: Robert Collins @@ -2869,7 +2869,7 @@ esiEnableProcessing (HttpReply *rep) { if (httpHeaderHas(&rep->header, HDR_SURROGATE_CONTROL)) - return 1; + return 0; return 0; } --- /dev/null Wed Feb 14 01:02:27 2007 +++ squid/src/HttpHdrSc.c Wed Feb 14 01:02:40 2007 @@ -0,0 +1,321 @@ + +/* + * $Id: HttpHdrSc.c,v 1.1.2.1 2002/08/26 13:20:36 rbcollins Exp $ + * + * DEBUG: section 89 HTTP Cache Control Header + * AUTHOR: Alex Rousskov + * Robert Collins (Surrogate-Control is derived from + * Cache-Control). + * + * SQUID Web Proxy Cache http://www.squid-cache.org/ + * ---------------------------------------------------------- + * + * Squid is the result of efforts by numerous individuals from + * the Internet community; see the CONTRIBUTORS file for full + * details. Many organizations have provided support for Squid's + * development; see the SPONSORS file for full details. Squid is + * Copyrighted (C) 2001 by the Regents of the University of + * California; see the COPYRIGHT file for full details. Squid + * incorporates software developed and/or copyrighted by other + * sources; see the CREDITS file for full details. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. + * + */ + +#include "squid.h" + +/* this table is used for parsing surrogate control header */ +static const HttpHeaderFieldAttrs ScAttrs[SC_ENUM_END] = +{ + {"no-store", SC_NO_STORE}, + {"no-store-remote", SC_NO_STORE_REMOTE}, + {"max-age", SC_MAX_AGE}, + {"content", SC_CONTENT}, + {"Other,", SC_OTHER} /* ',' will protect from matches */ +}; +HttpHeaderFieldInfo *ScFieldsInfo = NULL; + +/* local prototypes */ +static int httpHdrScParseInit(HttpHdrSc * sc, const String * str); + +/* module initialization */ + +void +httpHdrScInitModule(void) +{ + ScFieldsInfo = httpHeaderBuildFieldsInfo(ScAttrs, SC_ENUM_END); +} + +void +httpHdrScCleanModule(void) +{ + httpHeaderDestroyFieldsInfo(ScFieldsInfo, SC_ENUM_END); + ScFieldsInfo = NULL; +} + +/* implementation */ + +HttpHdrSc * +httpHdrScCreate(void) +{ + HttpHdrSc *sc = memAllocate(MEM_HTTP_HDR_SC); + return sc; +} + +/* creates an sc object from a 0-terminating string */ +HttpHdrSc * +httpHdrScParseCreate(const String * str) +{ + HttpHdrSc *sc = httpHdrScCreate(); + if (!httpHdrScParseInit(sc, str)) { + httpHdrScDestroy(sc); + sc = NULL; + } + return sc; +} + +/* parses a 0-terminating string and inits sc */ +static int +httpHdrScParseInit(HttpHdrSc * sc, const String * str) +{ + const char *item; + const char *p; /* '=' parameter */ + const char *pos = NULL; + const char *target = NULL; /* ;foo */ + const char *temp = NULL; /* temp buffer */ + int type; + int ilen; + int initiallen; + HttpHdrScTarget *sct; + assert(sc && str); + + /* iterate through comma separated list */ + while (strListGetItem(str, ',', &item, &ilen, &pos)) { + initiallen = ilen; + /* decrease ilen to still match the token for '=' statements */ + if ((p = strchr(item, '=')) && (p - item < ilen)) + ilen = p++ - item; + /* decrease ilen to still match the token for ';' qualified non '=' statments */ + else if ((p = strchr(item, ';')) && (p - item < ilen)) + ilen = p++ - item; + /* find type */ + type = httpHeaderIdByName(item, ilen, + ScFieldsInfo, SC_ENUM_END); + if (type < 0) { + debug(89, 2) ("hdr sc: unknown control-directive: near '%s' in '%s'\n", item, strBuf(*str)); + type = SC_OTHER; + } + /* Is this a targeted directive? */ + /* TODO sometime: implement a strnrchr that looks at a substring */ + temp = xstrndup (item, initiallen + 1); + if (!((target = strrchr (temp, ';')) && !strchr (target, '"') && *(target + 1) != '\0')) + target = NULL; + else + ++target; + sct = httpHdrScFindTarget (sc, target); + if (!sct) { + sct = httpHdrScTargetCreate (target); + dlinkAdd(sct, &sct->node, &sc->targets); + } + safe_free (temp); + if (EBIT_TEST(sct->mask, type)) { + if (type != SC_OTHER) + debug(89, 2) ("hdr sc: ignoring duplicate control-directive: near '%s' in '%s'\n", item, strBuf(*str)); + ScFieldsInfo[type].stat.repCount++; + continue; + } + /* update mask */ + EBIT_SET(sct->mask, type); + /* post-processing special cases */ + switch (type) { + case SC_MAX_AGE: + if (!p || !httpHeaderParseInt(p, &sct->max_age)) { + debug(89, 2) ("sc: invalid max-age specs near '%s'\n", item); + sct->max_age = -1; + EBIT_CLR(sct->mask, type); + } + if ((p = strchr (p, '+'))) + if (!httpHeaderParseInt(++p, &sct->max_stale)) { + debug(89, 2) ("sc: invalid max-stale specs near '%s'\n", item); + sct->max_stale = 0; + /* leave the max-age alone */ + } + break; + case SC_CONTENT: + if (!p || !httpHeaderParseQuotedString(p, &sct->content)) { + debug (89, 2) ("sc: invalid content= quoted string near '%s'\n",item); + stringClean (&sct->content); + EBIT_CLR(sct->mask, type); + } + default: + break; + } + } + return sc->targets.head != NULL; +} + +void +httpHdrScDestroy(HttpHdrSc * sc) +{ + assert(sc); + if (sc->targets.head) { + dlink_node *sct = sc->targets.head; + while (sct) { + HttpHdrScTarget *t = sct->data; + sct = sct->next; + dlinkDelete (&t->node, &sc->targets); + httpHdrScTargetDestroy (t); + } + } + memFree(sc, MEM_HTTP_HDR_SC); +} + +HttpHdrSc * +httpHdrScDup(const HttpHdrSc * sc) +{ + HttpHdrSc *dup; + dlink_node *node; + assert(sc); + node = sc->targets.head; + dup = httpHdrScCreate(); + while (node) { + HttpHdrScTarget *dupsct; + dupsct = httpHdrScTargetDup (node->data); + dlinkAddTail (dupsct, &dupsct->node, &dup->targets); + node = node->next; + } + return dup; +} + +void +httpHdrScTargetPackInto(const HttpHdrScTarget * sc, Packer * p) +{ + http_hdr_sc_type flag; + int pcount = 0; + assert(sc && p); + for (flag = 0; flag < SC_ENUM_END; flag++) { + if (EBIT_TEST(sc->mask, flag) && flag != SC_OTHER) { + + /* print option name */ + packerPrintf(p, (pcount ? ", %s" : "%s"), strBuf(ScFieldsInfo[flag].name)); + + /* handle options with values */ + if (flag == SC_MAX_AGE) + packerPrintf(p, "=%d", (int) sc->max_age); + + if (flag == SC_CONTENT) + packerPrintf(p, "=\"%s\"", strBuf(sc->content)); + + pcount++; + } + } + + if (strLen (sc->target)) + packerPrintf (p, ";%s", strBuf (sc->target)); +} + +void +httpHdrScPackInto(const HttpHdrSc * sc, Packer * p) +{ + dlink_node *node; + assert(sc && p); + node = sc->targets.head; + while (node) { + httpHdrScTargetPackInto(node->data, p); + node = node->next; + } +} + +void +httpHdrScJoinWith(HttpHdrSc * sc, const HttpHdrSc * new_sc) +{ + assert(sc && new_sc); +#if 0 + /* RC TODO: check that both have the same target */ + if (sc->max_age < 0) + sc->max_age = new_sc->max_age; + /* RC TODO: copy unique missing stringlist entries */ + cc->mask |= new_cc->mask; +#endif +} + +/* negative max_age will clean old max_Age setting */ +void +httpHdrScSetMaxAge(HttpHdrSc * sc, char const *target, int max_age) +{ + HttpHdrScTarget *sct; + assert(sc); + sct = httpHdrScFindTarget (sc, target); + if (!sct) { + sct = httpHdrScTargetCreate (target); + dlinkAddTail (sct, &sct->node, &sc->targets); + } + httpHdrScTargetSetMaxAge(sct, max_age); +} + +void +httpHdrScUpdateStats(const HttpHdrSc * sc, StatHist * hist) +{ + dlink_node *sct; + assert(sc); + sct = sc->targets.head; + while (sct) { + httpHdrScTargetUpdateStats(sct->data, hist); + sct = sct->next; + } +} + +void +httpHdrScTargetStatDumper(StoreEntry * sentry, int idx, double val, double size, int count) +{ + extern const HttpHeaderStat *dump_stat; /* argh! */ + const int id = (int) val; + const int valid_id = id >= 0 && id < SC_ENUM_END; + const char *name = valid_id ? strBuf(ScFieldsInfo[id].name) : "INVALID"; + if (count || valid_id) + storeAppendPrintf(sentry, "%2d\t %-20s\t %5d\t %6.2f\n", + id, name, count, xdiv(count, dump_stat->scParsedCount)); +} + +void +httpHdrScStatDumper(StoreEntry * sentry, int idx, double val, double size, int count) +{ + extern const HttpHeaderStat *dump_stat; /* argh! */ + const int id = (int) val; + const int valid_id = id >= 0 && id < SC_ENUM_END; + const char *name = valid_id ? strBuf(ScFieldsInfo[id].name) : "INVALID"; + if (count || valid_id) + storeAppendPrintf(sentry, "%2d\t %-20s\t %5d\t %6.2f\n", + id, name, count, xdiv(count, dump_stat->scParsedCount)); +} + +HttpHdrScTarget * +httpHdrScFindTarget (HttpHdrSc *sc, const char *target) +{ + dlink_node *node; + assert (sc); + node = sc->targets.head; + while (node) { + HttpHdrScTarget *sct = node->data; + if (target && strBuf (sct->target) && !strcmp (target, strBuf (sct->target))) + return sct; + else if (!target && !strBuf(sct->target)) + return sct; + node = node->next; + } + return NULL; +} + --- /dev/null Wed Feb 14 01:02:27 2007 +++ squid/src/HttpHdrScTarget.c Wed Feb 14 01:02:40 2007 @@ -0,0 +1,108 @@ + +/* + * $Id: HttpHdrScTarget.c,v 1.1.2.1 2002/08/26 13:20:36 rbcollins Exp $ + * + * DEBUG: section 89 HTTP Cache Control Header + * AUTHOR: Alex Rousskov + * Robert Collins (Surrogate-Control is derived from + * Cache-Control). + * + * SQUID Web Proxy Cache http://www.squid-cache.org/ + * ---------------------------------------------------------- + * + * Squid is the result of efforts by numerous individuals from + * the Internet community; see the CONTRIBUTORS file for full + * details. Many organizations have provided support for Squid's + * development; see the SPONSORS file for full details. Squid is + * Copyrighted (C) 2001 by the Regents of the University of + * California; see the COPYRIGHT file for full details. Squid + * incorporates software developed and/or copyrighted by other + * sources; see the CREDITS file for full details. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. + * + */ + +#include "squid.h" + +/* local prototypes */ + +/* module initialization */ + +/* implementation */ + +HttpHdrScTarget * +httpHdrScTargetCreate(char const *target) +{ + HttpHdrScTarget *sc = memAllocate(MEM_HTTP_HDR_SCTARGET); + sc->max_age = -1; + /* max_stale is specified as 0 if not specified in the header */ + stringInit (&sc->target, target); + return sc; +} + +void +httpHdrScTargetDestroy(HttpHdrScTarget * sc) +{ + assert(sc); + stringClean (&sc->target); + stringClean (&sc->content); + memFree(sc, MEM_HTTP_HDR_SCTARGET); +} + +HttpHdrScTarget * +httpHdrScTargetDup(const HttpHdrScTarget * sc) +{ + HttpHdrScTarget *dup; + assert(sc); + dup = httpHdrScTargetCreate(strBuf (sc->target)); + dup->mask = sc->mask; + dup->max_age = sc->max_age; + dup->content = stringDup (&sc->content); + return dup; +} + +void +httpHdrScTargetJoinWith(HttpHdrScTarget * sc, const HttpHdrScTarget * new_sc) +{ + assert(sc && new_sc); + /* RC TODO: check that both have the same target */ + if (sc->max_age < 0) + sc->max_age = new_sc->max_age; + /* RC TODO: copy unique missing content stringlist entries */ + sc->mask |= new_sc->mask; +} + +/* negative max_age will clean old max_Age setting */ +void +httpHdrScTargetSetMaxAge(HttpHdrScTarget * sc, int max_age) +{ + assert(sc); + sc->max_age = max_age; + if (max_age >= 0) + EBIT_SET(sc->mask, SC_MAX_AGE); + else + EBIT_CLR(sc->mask, SC_MAX_AGE); +} + +void +httpHdrScTargetUpdateStats(const HttpHdrScTarget * sc, StatHist * hist) +{ + http_hdr_sc_type c; + assert(sc); + for (c = 0; c < SC_ENUM_END; c++) + if (EBIT_TEST(sc->mask, c)) + statHistCount(hist, c); +} Index: squid/src/HttpHeader.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/HttpHeader.c,v retrieving revision 1.15.2.2 retrieving revision 1.15.2.3 diff -u -r1.15.2.2 -r1.15.2.3 --- squid/src/HttpHeader.c 11 Aug 2002 09:51:14 -0000 1.15.2.2 +++ squid/src/HttpHeader.c 26 Aug 2002 13:20:36 -0000 1.15.2.3 @@ -1,6 +1,6 @@ /* - * $Id: HttpHeader.c,v 1.15.2.2 2002/08/11 09:51:14 rbcollins Exp $ + * $Id: HttpHeader.c,v 1.15.2.3 2002/08/26 13:20:36 rbcollins Exp $ * * DEBUG: section 55 HTTP Header * AUTHOR: Alex Rousskov @@ -130,7 +130,7 @@ {"X-Accelerator-Vary", HDR_X_ACCELERATOR_VARY, ftStr}, #endif {"Surrogate-Capability", HDR_SURROGATE_CAPABILITY, ftStr}, - {"Surrogate-Control", HDR_SURROGATE_CONTROL, ftStr}, + {"Surrogate-Control", HDR_SURROGATE_CONTROL, ftPSc}, {"Other:", HDR_OTHER, ftStr} /* ':' will not allow matches */ }; static HttpHeaderFieldInfo *Headers = NULL; @@ -174,9 +174,9 @@ { HDR_CACHE_CONTROL, HDR_CONNECTION, HDR_DATE, HDR_PRAGMA, HDR_TRANSFER_ENCODING, - HDR_UPGRADE, + HDR_UPGRADE, /* HDR_TRAILER, */ - HDR_VIA + HDR_VIA, }; /* entity-headers */ @@ -280,6 +280,7 @@ #endif /* init dependent modules */ httpHdrCcInitModule(); + httpHdrScInitModule(); /* register with cache manager */ cachemgrRegister("http_headers", "HTTP Header Statistics", httpHeaderStoreReport, 0, 1); @@ -291,6 +292,7 @@ httpHeaderDestroyFieldsInfo(Headers, HDR_ENUM_END); Headers = NULL; httpHdrCcCleanModule(); + httpHdrScCleanModule(); } static void @@ -303,6 +305,7 @@ statHistEnumInit(&hs->hdrUCountDistr, 32); /* not a real enum */ statHistEnumInit(&hs->fieldTypeDistr, HDR_ENUM_END); statHistEnumInit(&hs->ccTypeDistr, CC_ENUM_END); + statHistEnumInit(&hs->scTypeDistr, SC_ENUM_END); } /* @@ -824,6 +827,25 @@ memBufClean(&mb); } +void +httpHeaderPutSc(HttpHeader *hdr, const HttpHdrSc *sc) +{ + MemBuf mb; + Packer p; + assert(hdr && sc); + /* remove old directives if any */ + httpHeaderDelById(hdr, HDR_RANGE); + /* pack into mb */ + memBufDefInit(&mb); + packerToMemInit(&p, &mb); + httpHdrScPackInto(sc, &p); + /* put */ + httpHeaderAddEntry(hdr, httpHeaderEntryCreate(HDR_SURROGATE_CONTROL, NULL, mb.buf)); + /* cleanup */ + packerClean(&p); + memBufClean(&mb); +} + /* add extension header (these fields are not parsed/analyzed/joined, etc.) */ void httpHeaderPutExt(HttpHeader * hdr, const char *name, const char *value) @@ -924,6 +946,23 @@ return r; } +HttpHdrSc * +httpHeaderGetSc(const HttpHeader *hdr) +{ + HttpHdrSc *sc; + String s; + if (!CBIT_TEST(hdr->mask, HDR_SURROGATE_CONTROL)) + return NULL; + s = httpHeaderGetList(hdr, HDR_SURROGATE_CONTROL); + sc = httpHdrScParseCreate(&s); + HttpHeaderStats[hdr->owner].ccParsedCount++; + if (sc) + httpHdrScUpdateStats(sc, &HttpHeaderStats[hdr->owner].scTypeDistr); + httpHeaderNoteParsedEntry(HDR_SURROGATE_CONTROL, s, !sc); + stringClean(&s); + return sc; +} + HttpHdrContRange * httpHeaderGetContRange(const HttpHeader * hdr) { @@ -1162,6 +1201,10 @@ storeAppendPrintf(e, "%2s\t %-20s\t %5s\t %6s\n", "id", "name", "count", "#/cc_field"); statHistDump(&hs->ccTypeDistr, e, httpHdrCcStatDumper); + storeAppendPrintf(e, "\nSurrogate-control directives distribution\n"); + storeAppendPrintf(e, "%2s\t %-20s\t %5s\t %6s\n", + "id", "name", "count", "#/sc_field"); + statHistDump(&hs->scTypeDistr, e, httpHdrScStatDumper); storeAppendPrintf(e, "\nNumber of fields per header distribution\n"); storeAppendPrintf(e, "%2s\t %-5s\t %5s\t %6s\n", "id", "#flds", "count", "%total"); Index: squid/src/HttpHeaderTools.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/HttpHeaderTools.c,v retrieving revision 1.7 retrieving revision 1.7.36.1 diff -u -r1.7 -r1.7.36.1 --- squid/src/HttpHeaderTools.c 6 Sep 2001 21:19:46 -0000 1.7 +++ squid/src/HttpHeaderTools.c 26 Aug 2002 13:20:36 -0000 1.7.36.1 @@ -1,6 +1,6 @@ /* - * $Id: HttpHeaderTools.c,v 1.7 2001/09/06 21:19:46 squidadm Exp $ + * $Id: HttpHeaderTools.c,v 1.7.36.1 2002/08/26 13:20:36 rbcollins Exp $ * * DEBUG: section 66 HTTP Header Tools * AUTHOR: Alex Rousskov @@ -310,6 +310,35 @@ } +/* Parses a quoted-string field (RFC 2616 section 2.2), complains if + * something went wrong, returns non-zero on success. + * start should point at the first ". + * RC TODO: This is too looose. We should honour the BNF and exclude CTL's + */ +int +httpHeaderParseQuotedString (const char *start, String *val) +{ + const char *end, *pos; + stringClean (val); + *val = StringNull; + assert (*start == '"'); + pos = start + 1; + while (1) { + if (!(end = index (pos,'"'))) { + debug (66, 2) ("failed to parse a quoted-string header field near '%s'\n", start); + return 0; + } + /* check for quoted-chars */ + if (*(end - 1) != '\\') { + /* done */ + stringAppend(val, start + 1, end-start-1); + return 1; + } + /* try for the end again */ + pos = end + 1; + } +} + /* * parses a given string then packs compiled headers and compares the result * with the original, reports discrepancies Index: squid/src/HttpReply.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/HttpReply.c,v retrieving revision 1.10 retrieving revision 1.10.32.1 diff -u -r1.10 -r1.10.32.1 --- squid/src/HttpReply.c 24 Oct 2001 09:42:11 -0000 1.10 +++ squid/src/HttpReply.c 26 Aug 2002 13:20:36 -0000 1.10.32.1 @@ -1,6 +1,6 @@ /* - * $Id: HttpReply.c,v 1.10 2001/10/24 09:42:11 squidadm Exp $ + * $Id: HttpReply.c,v 1.10.32.1 2002/08/26 13:20:36 rbcollins Exp $ * * DEBUG: section 58 HTTP Reply (Response) * AUTHOR: Alex Rousskov @@ -351,6 +351,7 @@ else rep->content_type = StringNull; rep->cache_control = httpHeaderGetCc(hdr); + rep->surrogate_control = httpHeaderGetSc(hdr); rep->content_range = httpHeaderGetContRange(hdr); rep->keep_alive = httpMsgIsPersistent(rep->sline.version, &rep->header); /* be sure to set expires after date and cache-control */ @@ -364,6 +365,8 @@ stringClean(&rep->content_type); if (rep->cache_control) httpHdrCcDestroy(rep->cache_control); + if (rep->surrogate_control) + httpHdrScDestroy(rep->surrogate_control); if (rep->content_range) httpHdrContRangeDestroy(rep->content_range); } Index: squid/src/Makefile.am =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Makefile.am,v retrieving revision 1.23.2.3 retrieving revision 1.23.2.4 diff -u -r1.23.2.3 -r1.23.2.4 --- squid/src/Makefile.am 20 Aug 2002 12:01:43 -0000 1.23.2.3 +++ squid/src/Makefile.am 26 Aug 2002 13:20:37 -0000 1.23.2.4 @@ -153,6 +153,8 @@ HttpStatusLine.c \ HttpHdrCc.c \ HttpHdrRange.c \ + HttpHdrSc.c \ + HttpHdrScTarget.c \ HttpHdrContRange.c \ HttpHeader.c \ HttpHeaderTools.c \ Index: squid/src/enums.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/enums.h,v retrieving revision 1.37.2.4 retrieving revision 1.37.2.5 diff -u -r1.37.2.4 -r1.37.2.5 --- squid/src/enums.h 25 Aug 2002 08:59:04 -0000 1.37.2.4 +++ squid/src/enums.h 26 Aug 2002 13:20:37 -0000 1.37.2.5 @@ -1,6 +1,6 @@ /* - * $Id: enums.h,v 1.37.2.4 2002/08/25 08:59:04 rbcollins Exp $ + * $Id: enums.h,v 1.37.2.5 2002/08/26 13:20:37 rbcollins Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -269,6 +269,15 @@ CC_ENUM_END } http_hdr_cc_type; +typedef enum { + SC_NO_STORE, + SC_NO_STORE_REMOTE, + SC_MAX_AGE, + SC_CONTENT, + SC_OTHER, + SC_ENUM_END +} http_hdr_sc_type; + /* possible types for http header fields */ typedef enum { ftInvalid = HDR_ENUM_END, /* to catch nasty errors with hdr_id<->fld_type clashes */ @@ -279,6 +288,7 @@ ftPCc, ftPContRange, ftPRange, + ftPSc, ftDate_1123_or_ETag } field_type; @@ -615,6 +625,8 @@ MEM_HTTP_HDR_ENTRY, MEM_HTTP_HDR_RANGE, MEM_HTTP_HDR_RANGE_SPEC, + MEM_HTTP_HDR_SC, + MEM_HTTP_HDR_SCTARGET, MEM_HTTP_REPLY, MEM_INTLIST, MEM_IPCACHE_ENTRY, Index: squid/src/mem.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/mem.c,v retrieving revision 1.20.2.1 retrieving revision 1.20.2.2 diff -u -r1.20.2.1 -r1.20.2.2 --- squid/src/mem.c 18 Aug 2002 11:09:23 -0000 1.20.2.1 +++ squid/src/mem.c 26 Aug 2002 13:20:37 -0000 1.20.2.2 @@ -1,6 +1,6 @@ /* - * $Id: mem.c,v 1.20.2.1 2002/08/18 11:09:23 rbcollins Exp $ + * $Id: mem.c,v 1.20.2.2 2002/08/26 13:20:37 rbcollins Exp $ * * DEBUG: section 13 High Level Memory Pool Management * AUTHOR: Harvest Derived @@ -370,6 +370,8 @@ memDataInit(MEM_HTTP_HDR_CC, "HttpHdrCc", sizeof(HttpHdrCc), 0); memDataInit(MEM_HTTP_HDR_RANGE_SPEC, "HttpHdrRangeSpec", sizeof(HttpHdrRangeSpec), 0); memDataInit(MEM_HTTP_HDR_RANGE, "HttpHdrRange", sizeof(HttpHdrRange), 0); + memDataInit(MEM_HTTP_HDR_SC, "HttpHdrSc", sizeof(HttpHdrSc), 0); + memDataInit(MEM_HTTP_HDR_SCTARGET, "HttpHdrScTarget", sizeof(HttpHdrScTarget), 0); memDataInit(MEM_HTTP_HDR_CONTENT_RANGE, "HttpHdrContRange", sizeof(HttpHdrContRange), 0); memDataInit(MEM_INTLIST, "intlist", sizeof(intlist), 0); memDataInit(MEM_MEMOBJECT, "MemObject", sizeof(MemObject), Index: squid/src/protos.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/protos.h,v retrieving revision 1.59.2.10 retrieving revision 1.59.2.11 diff -u -r1.59.2.10 -r1.59.2.11 --- squid/src/protos.h 25 Aug 2002 08:59:04 -0000 1.59.2.10 +++ squid/src/protos.h 26 Aug 2002 13:20:37 -0000 1.59.2.11 @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.59.2.10 2002/08/25 08:59:04 rbcollins Exp $ + * $Id: protos.h,v 1.59.2.11 2002/08/26 13:20:37 rbcollins Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -403,6 +403,30 @@ extern ssize_t httpHdrRangeLowestOffset(const HttpHdrRange * range, ssize_t); extern int httpHdrRangeOffsetLimit(HttpHdrRange *); +/* Http Surrogate Control Header Field */ +extern void httpHdrScStatDumper(StoreEntry * sentry, int idx, double val, double size, int count); +extern void httpHdrScInitModule (void); +extern void httpHdrScCleanModule (void); +extern HttpHdrSc *httpHdrScCreate(void); +extern HttpHdrSc *httpHdrScParseCreate(String const *); +extern void httpHdrScDestroy(HttpHdrSc * sc); +extern HttpHdrSc *httpHdrScDup(const HttpHdrSc * sc); +extern void httpHdrScPackInto(const HttpHdrSc * sc, Packer * p); +extern void httpHdrScJoinWith(HttpHdrSc *, const HttpHdrSc *); +extern void httpHdrScSetMaxAge(HttpHdrSc *, char const *, int); +extern void httpHdrScUpdateStats(const HttpHdrSc *, StatHist *); +extern HttpHdrScTarget * httpHdrScFindTarget (HttpHdrSc *sc, const char *target); + +/* Http Surrogate control header field 'targets' */ +extern HttpHdrScTarget * httpHdrScTargetCreate (const char *); +extern void httpHdrScTargetDestroy(HttpHdrScTarget *); +extern HttpHdrScTarget *httpHdrScTargetDup(const HttpHdrScTarget *); +extern void httpHdrScTargetPackInto(const HttpHdrScTarget *, Packer *); +extern void httpHdrScTargetSetMaxAge(HttpHdrScTarget *, int); +extern void httpHdrScTargetUpdateStats(const HttpHdrScTarget *, StatHist *); +extern void httpHdrScTargetJoinWith(HttpHdrScTarget *, const HttpHdrScTarget *); +extern void httpHdrScTargetStatDumper(StoreEntry * sentry, int idx, double val, double size, int count); + /* Http Content Range Header Field */ extern HttpHdrContRange *httpHdrContRangeCreate(void); @@ -432,6 +456,7 @@ extern const char *getStringPrefix(const char *str, const char *end); extern int httpHeaderParseInt(const char *start, int *val); extern int httpHeaderParseSize(const char *start, ssize_t * sz); +extern int httpHeaderParseQuotedString (const char *start, String *val); extern int httpHeaderReset(HttpHeader * hdr); #if STDC_HEADERS extern void @@ -462,6 +487,7 @@ extern void httpHeaderPutCc(HttpHeader * hdr, const HttpHdrCc * cc); extern void httpHeaderPutContRange(HttpHeader * hdr, const HttpHdrContRange * cr); extern void httpHeaderPutRange(HttpHeader * hdr, const HttpHdrRange * range); +extern void httpHeaderPutSc(HttpHeader *hdr, const HttpHdrSc *sc); extern void httpHeaderPutExt(HttpHeader * hdr, const char *name, const char *value); extern int httpHeaderGetInt(const HttpHeader * hdr, http_hdr_type id); extern time_t httpHeaderGetTime(const HttpHeader * hdr, http_hdr_type id); @@ -469,6 +495,7 @@ extern HttpHdrCc *httpHeaderGetCc(const HttpHeader * hdr); extern ETag httpHeaderGetETag(const HttpHeader * hdr, http_hdr_type id); extern HttpHdrRange *httpHeaderGetRange(const HttpHeader * hdr); +extern HttpHdrSc *httpHeaderGetSc(const HttpHeader *hdr); extern HttpHdrContRange *httpHeaderGetContRange(const HttpHeader * hdr); extern const char *httpHeaderGetStr(const HttpHeader * hdr, http_hdr_type id); extern const char *httpHeaderGetLastStr(const HttpHeader * hdr, http_hdr_type id); Index: squid/src/structs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/structs.h,v retrieving revision 1.61.2.8 retrieving revision 1.61.2.9 diff -u -r1.61.2.8 -r1.61.2.9 --- squid/src/structs.h 25 Aug 2002 08:59:04 -0000 1.61.2.8 +++ squid/src/structs.h 26 Aug 2002 13:20:37 -0000 1.61.2.9 @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.61.2.8 2002/08/25 08:59:04 rbcollins Exp $ + * $Id: structs.h,v 1.61.2.9 2002/08/26 13:20:37 rbcollins Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -939,6 +939,21 @@ int len; /* length when packed, not counting terminating '\0' */ }; +/* http surogate control header field */ +struct _HttpHdrScTarget { + dlink_node node; + int mask; + int max_age; + int max_stale; + String content; + String target; +}; + +struct _HttpHdrSc { + dlink_list targets; +}; + +/* Sync changes here with HttpReply.c */ struct _HttpReply { /* unsupported, writable, may disappear/change in the future */ int hdr_sz; /* sums _stored_ status-line, headers, and */ @@ -950,6 +965,7 @@ time_t expires; String content_type; HttpHdrCc *cache_control; + HttpHdrSc *surrogate_control; HttpHdrContRange *content_range; short int keep_alive; @@ -1882,9 +1898,11 @@ StatHist hdrUCountDistr; StatHist fieldTypeDistr; StatHist ccTypeDistr; + StatHist scTypeDistr; int parsedCount; int ccParsedCount; + int scParsedCount; int destroyedCount; int busyDestroyedCount; }; Index: squid/src/typedefs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/typedefs.h,v retrieving revision 1.27.2.3 retrieving revision 1.27.2.4 diff -u -r1.27.2.3 -r1.27.2.4 --- squid/src/typedefs.h 15 Aug 2002 09:17:15 -0000 1.27.2.3 +++ squid/src/typedefs.h 26 Aug 2002 13:20:38 -0000 1.27.2.4 @@ -1,6 +1,6 @@ /* - * $Id: typedefs.h,v 1.27.2.3 2002/08/15 09:17:15 rbcollins Exp $ + * $Id: typedefs.h,v 1.27.2.4 2002/08/26 13:20:38 rbcollins Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -97,6 +97,8 @@ typedef struct _HttpHdrRangeSpec HttpHdrRangeSpec; typedef struct _HttpHdrRange HttpHdrRange; typedef struct _HttpHdrRangeIter HttpHdrRangeIter; +typedef struct _HttpHdrSc HttpHdrSc; +typedef struct _HttpHdrScTarget HttpHdrScTarget; typedef struct _HttpHdrContRange HttpHdrContRange; typedef struct _TimeOrTag TimeOrTag; typedef struct _HttpHeaderEntry HttpHeaderEntry;