/* order must match that of enum http_hdr_cc_type. The constraint is verified at initialization time */
static HttpHeaderCcFields CcAttrs[CC_ENUM_END] = {
- {"public", CC_PUBLIC},
- {"private", CC_PRIVATE},
- {"no-cache", CC_NO_CACHE},
- {"no-store", CC_NO_STORE},
- {"no-transform", CC_NO_TRANSFORM},
- {"must-revalidate", CC_MUST_REVALIDATE},
- {"proxy-revalidate", CC_PROXY_REVALIDATE},
- {"max-age", CC_MAX_AGE},
- {"s-maxage", CC_S_MAXAGE},
- {"max-stale", CC_MAX_STALE},
- {"min-fresh", CC_MIN_FRESH},
- {"only-if-cached", CC_ONLY_IF_CACHED},
- {"stale-if-error", CC_STALE_IF_ERROR},
- {"Other,", CC_OTHER} /* ',' will protect from matches */
+ {"public", CC_PUBLIC},
+ {"private", CC_PRIVATE},
+ {"no-cache", CC_NO_CACHE},
+ {"no-store", CC_NO_STORE},
+ {"no-transform", CC_NO_TRANSFORM},
+ {"must-revalidate", CC_MUST_REVALIDATE},
+ {"proxy-revalidate", CC_PROXY_REVALIDATE},
+ {"max-age", CC_MAX_AGE},
+ {"s-maxage", CC_S_MAXAGE},
+ {"max-stale", CC_MAX_STALE},
+ {"min-fresh", CC_MIN_FRESH},
+ {"only-if-cached", CC_ONLY_IF_CACHED},
+ {"stale-if-error", CC_STALE_IF_ERROR},
+ {"Other,", CC_OTHER} /* ',' will protect from matches */
};
/// Map an header name to its type, to expedite parsing
httpHdrCcInitModule(void)
{
/* build lookup and accounting structures */
- for (int32_t i = 0;i < CC_ENUM_END; ++i) {
+ for (int32_t i = 0; i < CC_ENUM_END; ++i) {
const HttpHeaderCcFields &f=CcAttrs[i];
assert(i == f.id); /* verify assumption: the id is the key into the array */
const StringArea k(f.name,strlen(f.name));
}
break;
- case CC_PUBLIC: Public(true); break;
- case CC_PRIVATE: Private(true); break;
- case CC_NO_CACHE: noCache(true); break;
- case CC_NO_STORE: noStore(true); break;
- case CC_NO_TRANSFORM: noTransform(true); break;
- case CC_MUST_REVALIDATE: mustRevalidate(true); break;
- case CC_PROXY_REVALIDATE: proxyRevalidate(true); break;
- case CC_ONLY_IF_CACHED: onlyIfCached(true); break;
+ case CC_PUBLIC:
+ Public(true);
+ break;
+ case CC_PRIVATE:
+ Private(true);
+ break;
+ case CC_NO_CACHE:
+ noCache(true);
+ break;
+ case CC_NO_STORE:
+ noStore(true);
+ break;
+ case CC_NO_TRANSFORM:
+ noTransform(true);
+ break;
+ case CC_MUST_REVALIDATE:
+ mustRevalidate(true);
+ break;
+ case CC_PROXY_REVALIDATE:
+ proxyRevalidate(true);
+ break;
+ case CC_ONLY_IF_CACHED:
+ onlyIfCached(true);
+ break;
case CC_OTHER:
if (other.size())
{
public:
- static const int32_t MAX_AGE_UNKNOWN=-1; //max-age is unset
- static const int32_t S_MAXAGE_UNKNOWN=-1; //s-maxage is unset
- static const int32_t MAX_STALE_UNKNOWN=-1; //max-stale is unset
- ///used to mark a valueless Cache-Control: max-stale directive, which instructs
- /// us to treat responses of any age as fresh
- static const int32_t MAX_STALE_ANY=0x7fffffff;
- static const int32_t STALE_IF_ERROR_UNKNOWN=-1; //stale_if_error is unset
- static const int32_t MIN_FRESH_UNKNOWN=-1; //min_fresh is unset
+ static const int32_t MAX_AGE_UNKNOWN=-1; //max-age is unset
+ static const int32_t S_MAXAGE_UNKNOWN=-1; //s-maxage is unset
+ static const int32_t MAX_STALE_UNKNOWN=-1; //max-stale is unset
+ ///used to mark a valueless Cache-Control: max-stale directive, which instructs
+ /// us to treat responses of any age as fresh
+ static const int32_t MAX_STALE_ANY=0x7fffffff;
+ static const int32_t STALE_IF_ERROR_UNKNOWN=-1; //stale_if_error is unset
+ static const int32_t MIN_FRESH_UNKNOWN=-1; //min_fresh is unset
HttpHdrCc() :
mask(0), max_age(MAX_AGE_UNKNOWN), s_maxage(S_MAXAGE_UNKNOWN),
* Not meant for stand-alone storage. Validity of the
* pointed-to string is responsibility of the caller.
*/
-class StringArea {
- public:
+class StringArea
+{
+public:
/// build a StringArea by explicitly assigning pointed-to area and and length
StringArea(const char * ptr, size_t len): theStart(ptr), theLen(len) {}
bool operator==(const StringArea &s) const { return theLen==s.theLen && memcmp(theStart,s.theStart,theLen)==0; }
bool operator!=(const StringArea &s) const { return !operator==(s); }
bool operator< ( const StringArea &s) const {
- return (theLen < s.theLen || (theLen == s.theLen && memcmp(theStart,s.theStart,theLen) < 0)) ; }
+ return (theLen < s.theLen || (theLen == s.theLen && memcmp(theStart,s.theStart,theLen) < 0)) ;
+ }
- private:
+private:
/// pointed to the externally-managed memory area
const char *theStart;
/// length of the string
if (cc && cc->hasMinFresh()) {
const int32_t minFresh=cc->minFresh();
debugs(22, 3, "\tage + min-fresh:\t" << age << " + " <<
- minFresh << " = " << age + minFresh);
+ minFresh << " = " << age + minFresh);
debugs(22, 3, "\tcheck_time + min-fresh:\t" << check_time << " + "
<< minFresh << " = " <<
mkrfc1123(check_time + minFresh));
// stale-if-error requires any failure be passed thru when its period is over.
if (request && entry->mem_obj && entry->mem_obj->getReply() && entry->mem_obj->getReply()->cache_control &&
- entry->mem_obj->getReply()->cache_control->hasStaleIfError() &&
+ entry->mem_obj->getReply()->cache_control->hasStaleIfError() &&
entry->mem_obj->getReply()->cache_control->staleIfError() < staleness) {
debugs(22, 3, "refreshCheck: stale-if-error period expired.");