if (!p || !httpHeaderParseInt(p, &cc->max_stale)) {
debugs(65, 2, "cc: max-stale directive is valid without value");
- cc->max_stale = -1;
+ cc->setMaxStale(MAX_STALE_ALWAYS);
}
break;
if (flag == 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);
+ if (flag == CC_MAX_STALE && cc->getMaxStale() >= 0)
+ packerPrintf(p, "=%d", (int) cc->getMaxStale());
if (flag == CC_MIN_FRESH)
packerPrintf(p, "=%d", (int) cc->min_fresh);
EBIT_SET(mask, CC_S_MAXAGE);
this->s_maxage=s_maxage;
} else {
- this->s_maxage=S_MAXAGE_UNSET;
EBIT_CLR(mask, CC_S_MAXAGE);
+ this->s_maxage=S_MAXAGE_UNSET;
}
}
{
return s_maxage;
}
+
+void HttpHdrCc::setMaxStale(int32_t max_stale)
+{
+ if (max_stale>=0 || max_stale==MAX_STALE_ALWAYS) {
+ EBIT_SET(mask,CC_MAX_STALE);
+ this->max_stale=max_stale;
+ } else {
+ EBIT_CLR(mask, CC_MAX_STALE);
+ this->max_stale=MAX_STALE_UNSET;
+ }
+}
+int32_t HttpHdrCc::getMaxStale() const
+{
+ return max_stale;
+}
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
+ static const int32_t S_MAXAGE_UNSET=-1; //s-maxage is unset
+ static const int32_t MAX_STALE_UNSET=-1; //max-stale is unset
+ static const int32_t MAX_STALE_ALWAYS=-2; //max-stale is set to no value
explicit HttpHdrCc() :
mask(0), max_age(MAX_AGE_UNSET), s_maxage(S_MAXAGE_UNSET),
- max_stale(-1), stale_if_error(0),
+ max_stale(MAX_STALE_UNSET), stale_if_error(0),
min_fresh(-1) {}
void clear();
void setSMaxAge(int32_t s_maxage);
int32_t getSMaxAge() const;
+ void setMaxStale(int32_t max_stale);
+ int32_t getMaxStale() const;
MEMPROXY_CLASS(HttpHdrCc);
private:
int32_t max_age;
int32_t s_maxage;
-public:
int32_t max_stale;
+public:
int32_t stale_if_error;
int32_t min_fresh;
String other;
}
}
- if (EBIT_TEST(cc->mask, CC_MAX_STALE) && staleness > -1) {
- if (cc->max_stale < 0) {
+ if (cc->getMaxStale()>=0 && staleness > -1) {
+ if (cc->getMaxStale()==HttpHdrCc::MAX_STALE_ALWAYS) {
/* max-stale directive without a value */
debugs(22, 3, "refreshCheck: NO: max-stale wildcard");
return FRESH_REQUEST_MAX_STALE_ALL;
- } else if (staleness < cc->max_stale) {
+ } else if (staleness < cc->getMaxStale()) {
debugs(22, 3, "refreshCheck: NO: staleness < max-stale");
return FRESH_REQUEST_MAX_STALE_VALUE;
}