http_hdr_cc_type type;
int ilen;
int nlen;
- HttpHdrCc *cc=this; //TODO: remove after review
/* iterate through comma separated list */
type=i->second;
// ignore known duplicate directives
- if (EBIT_TEST(cc->mask, type)) {
+ if (isSet(type)) {
if (type != CC_OTHER) {
debugs(65, 2, "hdr cc: ignoring duplicate cache-directive: near '" << item << "' in '" << str << "'");
++CcAttrs[type].stat.repCount;
continue;
}
} else {
- EBIT_SET(cc->mask, type);
+ set(type);
}
/* post-processing special cases */
int32_t ma;
if (!p || !httpHeaderParseInt(p, &ma)) {
debugs(65, 2, "cc: invalid max-age specs near '" << item << "'");
- cc->setMaxAge(MAX_AGE_UNSET);
+ setMaxAge(MAX_AGE_UNSET);
} else {
- cc->setMaxAge(ma);
+ setMaxAge(ma);
}
break;
case CC_S_MAXAGE:
- if (!p || !httpHeaderParseInt(p, &cc->s_maxage)) {
+ if (!p || !httpHeaderParseInt(p, &s_maxage)) {
debugs(65, 2, "cc: invalid s-maxage specs near '" << item << "'");
- cc->setSMaxAge(S_MAXAGE_UNSET);
+ setSMaxAge(S_MAXAGE_UNSET);
}
break;
case CC_MAX_STALE:
- if (!p || !httpHeaderParseInt(p, &cc->max_stale)) {
+ if (!p || !httpHeaderParseInt(p, &max_stale)) {
debugs(65, 2, "cc: max-stale directive is valid without value");
- cc->setMaxStale(MAX_STALE_ALWAYS);
+ setMaxStale(MAX_STALE_ALWAYS);
}
break;
case CC_MIN_FRESH:
- if (!p || !httpHeaderParseInt(p, &cc->min_fresh)) {
+ if (!p || !httpHeaderParseInt(p, &min_fresh)) {
debugs(65, 2, "cc: invalid min-fresh specs near '" << item << "'");
- cc->setMinFresh(MIN_FRESH_UNSET);
+ setMinFresh(MIN_FRESH_UNSET);
}
break;
case CC_STALE_IF_ERROR:
- if (!p || !httpHeaderParseInt(p, &cc->stale_if_error)) {
+ if (!p || !httpHeaderParseInt(p, &stale_if_error)) {
debugs(65, 2, "cc: invalid stale-if-error specs near '" << item << "'");
- cc->setStaleIfError(STALE_IF_ERROR_UNSET);
+ setStaleIfError(STALE_IF_ERROR_UNSET);
}
break;
case CC_OTHER:
- if (cc->other.size())
- cc->other.append(", ");
+ if (other.size())
+ other.append(", ");
- cc->other.append(item, ilen);
+ other.append(item, ilen);
break;
}
}
- return (cc->mask != 0);
+ return (mask != 0);
}
void
assert(cc && p);
for (flag = CC_PUBLIC; flag < CC_ENUM_END; ++flag) {
- if (EBIT_TEST(cc->mask, flag) && flag != CC_OTHER) {
+ if (cc->isSet(flag) && flag != CC_OTHER) {
/* print option name */
packerPrintf(p, (pcount ? ", %s": "%s") , CcAttrs[flag].name);
assert(cc);
for (c = CC_PUBLIC; c < CC_ENUM_END; ++c)
- if (EBIT_TEST(cc->mask, c))
+ if (cc->isSet(c))
statHistCount(hist, c);
}
{
if (max_age_ >= 0) {
- EBIT_SET(mask, CC_MAX_AGE);
+ set(CC_MAX_AGE);
max_age = max_age_;
} else {
- EBIT_CLR(mask, CC_MAX_AGE);
+ set(CC_MAX_AGE,false);
max_age=MAX_AGE_UNSET;
}
}
HttpHdrCc::setSMaxAge(int32_t s_maxage)
{
if (s_maxage >= 0) {
- EBIT_SET(mask, CC_S_MAXAGE);
+ set(CC_S_MAXAGE);
this->s_maxage=s_maxage;
} else {
- EBIT_CLR(mask, CC_S_MAXAGE);
+ set(CC_S_MAXAGE,false);
this->s_maxage=S_MAXAGE_UNSET;
}
}
HttpHdrCc::setMaxStale(int32_t max_stale)
{
if (max_stale>=0 || max_stale==MAX_STALE_ALWAYS) {
- EBIT_SET(mask,CC_MAX_STALE);
+ set(CC_MAX_STALE);
this->max_stale=max_stale;
} else {
- EBIT_CLR(mask, CC_MAX_STALE);
+ set(CC_MAX_STALE,false);
this->max_stale=MAX_STALE_UNSET;
}
}
HttpHdrCc::setStaleIfError(int32_t stale_if_error)
{
if (stale_if_error >= 0) {
- EBIT_SET(mask, CC_STALE_IF_ERROR);
+ set(CC_STALE_IF_ERROR);
this->stale_if_error=stale_if_error;
} else {
- EBIT_CLR(mask, CC_STALE_IF_ERROR);
+ set(CC_STALE_IF_ERROR,false);
this->stale_if_error=STALE_IF_ERROR_UNSET;
}
}
HttpHdrCc::setMinFresh(int32_t min_fresh)
{
if (min_fresh >= 0) {
- EBIT_SET(mask, CC_MIN_FRESH);
+ set(CC_MIN_FRESH);
this->min_fresh=min_fresh;
} else {
- EBIT_CLR(mask, CC_MIN_FRESH);
+ set(CC_MIN_FRESH,false);
this->min_fresh=MIN_FRESH_UNSET;
}
}
{
return min_fresh;
}
+
+bool
+HttpHdrCc::isSet(http_hdr_cc_type id) const
+{
+ assert(id>=CC_PUBLIC && id < CC_ENUM_END);
+ return EBIT_TEST(mask,id);
+}
+
+void
+HttpHdrCc::set(http_hdr_cc_type id, bool newval)
+{
+ assert(id>=CC_PUBLIC && id < CC_ENUM_END);
+ if (newval)
+ EBIT_SET(mask,id);
+ else
+ EBIT_CLR(mask,id);
+}
/// parse a header-string and fill in appropriate values.
bool parse(const String & s);
+ /// set an attribute value or clear it (by supplying false as the second argument)
+ _SQUID_INLINE_ void set(http_hdr_cc_type id, bool newval=true);
+ /// check whether the attribute value supplied by id is set
+ _SQUID_INLINE_ bool isSet(http_hdr_cc_type id) const;
+
/// max-age setter. Clear by setting to MAX_AGE_UNSET
_SQUID_INLINE_ void setMaxAge(int32_t max_age);
_SQUID_INLINE_ int32_t getMaxAge() const;
{
assert(request);
return request->cache_control &&
- EBIT_TEST(request->cache_control->mask, CC_ONLY_IF_CACHED);
+ request->cache_control->isSet(CC_ONLY_IF_CACHED);
}
/*
}
if (request->cache_control)
- if (EBIT_TEST(request->cache_control->mask, CC_NO_CACHE))
+ if (request->cache_control->isSet(CC_NO_CACHE))
no_cache++;
/*
{
HttpReply const *rep = finalReply();
HttpHeader const *hdr = &rep->header;
- const int cc_mask = (rep->cache_control) ? rep->cache_control->mask : 0;
const char *v;
#if USE_HTTP_VIOLATIONS
// RFC 2616: do not cache replies to responses with no-store CC directive
if (request && request->cache_control &&
- EBIT_TEST(request->cache_control->mask, CC_NO_STORE) &&
+ request->cache_control->isSet(CC_NO_STORE) &&
!REFRESH_OVERRIDE(ignore_no_store))
return 0;
if (!ignoreCacheControl) {
- if (EBIT_TEST(cc_mask, CC_PRIVATE)) {
+ const HttpHdrCc* cc=request->cache_control;
+ if (cc->isSet(CC_PRIVATE)) {
if (!REFRESH_OVERRIDE(ignore_private))
return 0;
}
- if (EBIT_TEST(cc_mask, CC_NO_CACHE)) {
+ if (cc->isSet(CC_NO_CACHE)) {
if (!REFRESH_OVERRIDE(ignore_no_cache))
return 0;
}
- if (EBIT_TEST(cc_mask, CC_NO_STORE)) {
+ if (cc->isSet(CC_NO_STORE)) {
if (!REFRESH_OVERRIDE(ignore_no_store))
return 0;
}
* RFC 2068, sec 14.9.4
*/
- if (!EBIT_TEST(cc_mask, CC_PUBLIC)) {
+ if (!request->cache_control->isSet(CC_PUBLIC)) {
if (!REFRESH_OVERRIDE(ignore_auth))
return 0;
}
no_cache:
if (!ignoreCacheControl && rep->cache_control) {
- if (EBIT_TEST(rep->cache_control->mask, CC_PROXY_REVALIDATE) ||
- EBIT_TEST(rep->cache_control->mask, CC_MUST_REVALIDATE) ||
+ if (rep->cache_control->isSet(CC_PROXY_REVALIDATE) ||
+ rep->cache_control->isSet(CC_MUST_REVALIDATE) ||
rep->cache_control->getSMaxAge() != HttpHdrCc::S_MAXAGE_UNSET
)
EBIT_SET(entry->flags, ENTRY_REVALIDATE);
#endif
/* Add max-age only without no-cache */
- if (cc->getMaxAge()==HttpHdrCc::MAX_AGE_UNSET && !EBIT_TEST(cc->mask, CC_NO_CACHE)) {
+ if (cc->getMaxAge()==HttpHdrCc::MAX_AGE_UNSET && !cc->isSet(CC_NO_CACHE)) {
const char *url =
entry ? entry->url() : urlCanonical(request);
cc->setMaxAge(getMaxAge(url));
/* Enforce sibling relations */
if (flags.only_if_cached)
- EBIT_SET(cc->mask, CC_ONLY_IF_CACHED);
+ cc->set(CC_ONLY_IF_CACHED);
hdr_out->putCc(cc);