if (!p || !httpHeaderParseInt(p, &cc->min_fresh)) {
debugs(65, 2, "cc: invalid min-fresh specs near '" << item << "'");
- cc->min_fresh = -1;
- EBIT_CLR(cc->mask, type);
+ cc->setMinFresh(MIN_FRESH_UNSET);
}
break;
packerPrintf(p, "=%d", (int) cc->getMaxStale());
if (flag == CC_MIN_FRESH)
- packerPrintf(p, "=%d", (int) cc->min_fresh);
+ packerPrintf(p, "=%d", (int) cc->getMinFresh());
++pcount;
}
{
return stale_if_error;
}
+
+void
+HttpHdrCc::setMinFresh(int32_t min_fresh)
+{
+ if (min_fresh >= 0) {
+ EBIT_SET(mask, CC_MIN_FRESH);
+ this->min_fresh=min_fresh;
+ } else {
+ EBIT_CLR(mask, CC_MIN_FRESH);
+ this->min_fresh=STALE_IF_ERROR_UNSET;
+ }
+}
+
+int32_t
+HttpHdrCc::getMinFresh() const
+{
+ return min_fresh;
+}
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
static const int32_t STALE_IF_ERROR_UNSET=-1; //stale_if_error is unset
+ static const int32_t MIN_FRESH_UNSET=-1; //min_fresh is unset
explicit HttpHdrCc() :
mask(0), max_age(MAX_AGE_UNSET), s_maxage(S_MAXAGE_UNSET),
max_stale(MAX_STALE_UNSET), stale_if_error(STALE_IF_ERROR_UNSET),
- min_fresh(-1) {}
+ min_fresh(MIN_FRESH_UNSET) {}
void clear();
bool parse(const String & s);
void setStaleIfError(int32_t stale_if_error);
int32_t getStaleIfError() const;
+ void setMinFresh(int32_t min_fresh);
+ int32_t getMinFresh() const;
+
MEMPROXY_CLASS(HttpHdrCc);
int32_t mask;
int32_t s_maxage;
int32_t max_stale;
int32_t stale_if_error;
-public:
int32_t min_fresh;
+public:
String other;
};
if (request && !request->flags.ignore_cc) {
const HttpHdrCc *const cc = request->cache_control;
- if (cc && cc->min_fresh > 0) {
+ const int32_t minFresh=cc->getMinFresh();
+ if (cc && minFresh!=HttpHdrCc::MIN_FRESH_UNSET) {
debugs(22, 3, "\tage + min-fresh:\t" << age << " + " <<
- cc->min_fresh << " = " << age + cc->min_fresh);
+ minFresh << " = " << age + minFresh);
debugs(22, 3, "\tcheck_time + min-fresh:\t" << check_time << " + "
- << cc->min_fresh << " = " <<
- mkrfc1123(check_time + cc->min_fresh));
- age += cc->min_fresh;
- check_time += cc->min_fresh;
+ << minFresh << " = " <<
+ mkrfc1123(check_time + minFresh));
+ age += minFresh;
+ check_time += minFresh;
}
}