if (!p || !httpHeaderParseInt(p, &cc->s_maxage)) {
debugs(65, 2, "cc: invalid s-maxage specs near '" << item << "'");
- cc->s_maxage = -1;
- EBIT_CLR(cc->mask, type);
+ cc->setSMaxAge(S_MAXAGE_UNSET);
}
break;
packerPrintf(p, "=%d", (int) cc->getMaxAge());
if (flag == CC_S_MAXAGE)
- packerPrintf(p, "=%d", (int) cc->s_maxage);
+ packerPrintf(p, "=%d", (int) cc->getSMaxAge());
if (flag == CC_MAX_STALE && cc->max_stale >= 0)
packerPrintf(p, "=%d", (int) cc->max_stale);
SQUIDSTRINGPRINT(cc->other));
}
-void
-HttpHdrCc::setMaxAge(int max_age_)
-{
-
- if (max_age_ >= 0) {
- EBIT_SET(mask, CC_MAX_AGE);
- max_age = max_age_;
- } else {
- EBIT_CLR(mask, CC_MAX_AGE);
- max_age=MAX_AGE_UNSET;
- }
-}
-
void
httpHdrCcUpdateStats(const HttpHdrCc * cc, StatHist * hist)
{
id, name, count, xdiv(count, dump_stat->ccParsedCount));
}
+void
+HttpHdrCc::setMaxAge(int max_age_)
+{
+
+ if (max_age_ >= 0) {
+ EBIT_SET(mask, CC_MAX_AGE);
+ max_age = max_age_;
+ } else {
+ EBIT_CLR(mask, CC_MAX_AGE);
+ max_age=MAX_AGE_UNSET;
+ }
+}
+
int32_t HttpHdrCc::getMaxAge() const
{
return max_age;
}
+void HttpHdrCc::setSMaxAge(int32_t s_maxage)
+{
+ if (s_maxage >= 0) {
+ EBIT_SET(mask, CC_S_MAXAGE);
+ this->s_maxage=s_maxage;
+ } else {
+ this->s_maxage=S_MAXAGE_UNSET;
+ EBIT_CLR(mask, CC_S_MAXAGE);
+ }
+}
+int32_t HttpHdrCc::getSMaxAge() const
+{
+ return s_maxage;
+}
public:
static const int32_t MAX_AGE_UNSET=-1; //max-age is unset
+ static const int32_t S_MAXAGE_UNSET=-1; //max-age is unset
explicit HttpHdrCc() :
- mask(0), max_age(MAX_AGE_UNSET), s_maxage(-1),
+ mask(0), max_age(MAX_AGE_UNSET), s_maxage(S_MAXAGE_UNSET),
max_stale(-1), stale_if_error(0),
min_fresh(-1) {}
void setMaxAge(int32_t max_age);
int32_t getMaxAge() const;
+ void setSMaxAge(int32_t s_maxage);
+ int32_t getSMaxAge() const;
+
+
MEMPROXY_CLASS(HttpHdrCc);
int32_t mask;
private:
int32_t max_age;
-public:
int32_t s_maxage;
+public:
int32_t max_stale;
int32_t stale_if_error;
int32_t min_fresh;
if (cache_control) {
if (date >= 0) {
- if (cache_control->s_maxage >= 0)
- return date + cache_control->s_maxage;
+ if (cache_control->getSMaxAge() != HttpHdrCc::S_MAXAGE_UNSET)
+ return date + cache_control->getSMaxAge();
if (cache_control->getMaxAge() >= 0)
return date + cache_control->getMaxAge();
* header, but no Date for reference?
*/
- if (cache_control->s_maxage >= 0)
+ if (cache_control->getSMaxAge()!=HttpHdrCc::S_MAXAGE_UNSET)
return squid_curtime;
if (cache_control->getMaxAge() >= 0)
if (!ignoreCacheControl && rep->cache_control) {
if (EBIT_TEST(rep->cache_control->mask, CC_PROXY_REVALIDATE) ||
EBIT_TEST(rep->cache_control->mask, CC_MUST_REVALIDATE) ||
- EBIT_TEST(rep->cache_control->mask, CC_S_MAXAGE))
+ rep->cache_control->getSMaxAge() != HttpHdrCc::S_MAXAGE_UNSET
+ )
EBIT_SET(entry->flags, ENTRY_REVALIDATE);
}
#endif
/* Add max-age only without no-cache */
- if (!EBIT_TEST(cc->mask, CC_MAX_AGE) && !EBIT_TEST(cc->mask, CC_NO_CACHE)) {
+ if (cc->getMaxAge()==HttpHdrCc::MAX_AGE_UNSET && !EBIT_TEST(cc->mask, CC_NO_CACHE)) {
const char *url =
entry ? entry->url() : urlCanonical(request);
cc->setMaxAge(getMaxAge(url));