]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
C++-refactored httpHdrCcSetMaxAge and httpHdrCcSetSMaxAge
authorFrancesco Chemolli <kinkie@squid-cache.org>
Mon, 12 Sep 2011 19:05:57 +0000 (21:05 +0200)
committerFrancesco Chemolli <kinkie@squid-cache.org>
Mon, 12 Sep 2011 19:05:57 +0000 (21:05 +0200)
src/HttpHeaderCacheControl.cc
src/HttpHeaderCacheControl.h
src/http.cc
src/mime.cc
src/protos.h

index f55662a3e0d075828d18dd5b689d7d6972a7774e..91b85a58762f6bc2b07d834af6e3042dceb981cf 100644 (file)
@@ -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
index b09eb29f40a50b371fe607a5d7aea875220f6c6a..24a93095a6d60043d1d45524206a440b3191183f 100644 (file)
@@ -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);
 
index adb50265c5587d2102a81abb3d23e4df73f74f9a..8746f5a8a8f86da7dcfa03de6ebd111d751dbbc4 100644 (file)
@@ -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));
 
         }
 
index aaf5827a18e1d21e0899d3a390ab64e10a0c59ef..0fd978dd80bc212bdbabcef3aa00f533c703f1c6 100644 (file)
@@ -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);
 
index fedbee83549501c38d820051a266950bd0131fd4..88c2de639d4b8355ca497568ffa6dbac7d5164ba 100644 (file)
@@ -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);