From: Francesco Chemolli Date: Mon, 12 Sep 2011 19:05:57 +0000 (+0200) Subject: C++-refactored httpHdrCcSetMaxAge and httpHdrCcSetSMaxAge X-Git-Tag: BumpSslServerFirst.take01~126^2~29 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=05680ba92b5435d189ff2e78217bd22d19652306;p=thirdparty%2Fsquid.git C++-refactored httpHdrCcSetMaxAge and httpHdrCcSetSMaxAge --- diff --git a/src/HttpHeaderCacheControl.cc b/src/HttpHeaderCacheControl.cc index f55662a3e0..91b85a5876 100644 --- a/src/HttpHeaderCacheControl.cc +++ b/src/HttpHeaderCacheControl.cc @@ -244,30 +244,26 @@ httpHdrCcPackInto(const HttpHdrCc * cc, Packer * p) SQUIDSTRINGPRINT(cc->other)); } -/* negative max_age will clean old max_Age setting */ void -httpHdrCcSetMaxAge(HttpHdrCc * cc, int max_age) +HttpHdrCc::setMaxAge(int max_age_) { - assert(cc); - cc->max_age = max_age; + max_age = max_age_; - if (max_age >= 0) - EBIT_SET(cc->mask, CC_MAX_AGE); + if (max_age_ >= 0) + EBIT_SET(mask, CC_MAX_AGE); else - EBIT_CLR(cc->mask, CC_MAX_AGE); + EBIT_CLR(mask, CC_MAX_AGE); } -/* negative s_maxage will clean old s-maxage setting */ void -httpHdrCcSetSMaxAge(HttpHdrCc * cc, int s_maxage) +HttpHdrCc::setSMaxAge(int s_maxage_) { - assert(cc); - cc->s_maxage = s_maxage; + s_maxage = s_maxage_; - if (s_maxage >= 0) - EBIT_SET(cc->mask, CC_S_MAXAGE); + if (s_maxage_ >= 0) + EBIT_SET(mask, CC_S_MAXAGE); else - EBIT_CLR(cc->mask, CC_S_MAXAGE); + EBIT_CLR(mask, CC_S_MAXAGE); } void diff --git a/src/HttpHeaderCacheControl.h b/src/HttpHeaderCacheControl.h index b09eb29f40..24a93095a6 100644 --- a/src/HttpHeaderCacheControl.h +++ b/src/HttpHeaderCacheControl.h @@ -58,6 +58,17 @@ public: min_fresh(min_fresh_) {} /// (re)initialize by parsing the supplied Cache-control header string bool parseInit(const String &s); + /** set the max_age value + * + * \param max_age the new max age. Values <0 clear it. + */ + void setMaxAge(int32_t max_age); + + /** set the s-maxage + * + * \param s_maxage the new max age. Values <0 clear it. + */ + void setSMaxAge(int32_t s_maxage); MEMPROXY_CLASS(HttpHdrCc); diff --git a/src/http.cc b/src/http.cc index adb50265c5..8746f5a8a8 100644 --- a/src/http.cc +++ b/src/http.cc @@ -1770,7 +1770,7 @@ HttpStateData::httpBuildRequestHeader(HttpRequest * request, if (!EBIT_TEST(cc->mask, CC_MAX_AGE) && !EBIT_TEST(cc->mask, CC_NO_CACHE)) { const char *url = entry ? entry->url() : urlCanonical(request); - httpHdrCcSetMaxAge(cc, getMaxAge(url)); + cc->setMaxAge(getMaxAge(url)); } diff --git a/src/mime.cc b/src/mime.cc index aaf5827a18..0fd978dd80 100644 --- a/src/mime.cc +++ b/src/mime.cc @@ -464,7 +464,7 @@ MimeIcon::created (StoreEntry *newEntry) reply->cache_control = new HttpHdrCc(); - httpHdrCcSetMaxAge(reply->cache_control, 86400); + reply->cache_control->setMaxAge(86400); reply->header.putCc(reply->cache_control); diff --git a/src/protos.h b/src/protos.h index fedbee8354..88c2de639d 100644 --- a/src/protos.h +++ b/src/protos.h @@ -239,8 +239,6 @@ SQUIDCEXTERN void httpHdrCcInitModule(void); SQUIDCEXTERN void httpHdrCcCleanModule(void); SQUIDCEXTERN HttpHdrCc *httpHdrCcDup(const HttpHdrCc * cc); SQUIDCEXTERN void httpHdrCcPackInto(const HttpHdrCc * cc, Packer * p); -SQUIDCEXTERN void httpHdrCcSetMaxAge(HttpHdrCc * cc, int max_age); -SQUIDCEXTERN void httpHdrCcSetSMaxAge(HttpHdrCc * cc, int s_maxage); SQUIDCEXTERN void httpHdrCcUpdateStats(const HttpHdrCc * cc, StatHist * hist); void httpHdrCcStatDumper(StoreEntry * sentry, int idx, double val, double size, int count);