/*
- * $Id: HttpHdrCc.cc,v 1.18 1999/10/04 05:04:53 wessels Exp $
+ * $Id: HttpHdrCc.cc,v 1.19 1999/12/30 17:36:16 wessels Exp $
*
* DEBUG: section 65 HTTP Cache Control Header
* AUTHOR: Alex Rousskov
{"proxy-revalidate", CC_PROXY_REVALIDATE},
{"only-if-cached", CC_ONLY_IF_CACHED},
{"max-age", CC_MAX_AGE},
+ {"s-maxage", CC_S_MAXAGE},
{"Other,", CC_OTHER} /* ',' will protect from matches */
};
HttpHeaderFieldInfo *CcFieldsInfo = NULL;
httpHdrCcCreate(void)
{
HttpHdrCc *cc = memAllocate(MEM_HTTP_HDR_CC);
- cc->max_age = -1;
+ cc->max_age = cc->s_maxage = -1;
return cc;
}
EBIT_CLR(cc->mask, type);
}
break;
+ case CC_S_MAXAGE:
+ if (!p || !httpHeaderParseInt(p, &cc->s_maxage)) {
+ debug(65, 2) ("cc: invalid s-maxage specs near '%s'\n", item);
+ cc->s_maxage = -1;
+ EBIT_CLR(cc->mask, type);
+ }
+ break;
default:
/* note that we ignore most of '=' specs */
break;
dup = httpHdrCcCreate();
dup->mask = cc->mask;
dup->max_age = cc->max_age;
+ dup->s_maxage = cc->s_maxage;
return dup;
}
if (flag == CC_MAX_AGE)
packerPrintf(p, "=%d", (int) cc->max_age);
+ if (flag == CC_S_MAXAGE)
+ packerPrintf(p, "=%d", (int) cc->s_maxage);
+
pcount++;
}
}
assert(cc && new_cc);
if (cc->max_age < 0)
cc->max_age = new_cc->max_age;
+ if (cc->s_maxage < 0)
+ cc->s_maxage = new_cc->s_maxage;
cc->mask |= new_cc->mask;
}
EBIT_CLR(cc->mask, CC_MAX_AGE);
}
+/* negative s_maxage will clean old s-maxage setting */
+void
+httpHdrCcSetSMaxAge(HttpHdrCc * cc, int s_maxage)
+{
+ assert(cc);
+ cc->s_maxage = s_maxage;
+ if (s_maxage >= 0)
+ EBIT_SET(cc->mask, CC_S_MAXAGE);
+ else
+ EBIT_CLR(cc->mask, CC_S_MAXAGE);
+}
+
void
httpHdrCcUpdateStats(const HttpHdrCc * cc, StatHist * hist)
{