]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Rename http_hdr_cc_type to HttpHdrCcType and reference it by full qualifier.
authorFrancesco Chemolli <kinkie@squid-cache.org>
Wed, 5 Aug 2015 13:47:19 +0000 (15:47 +0200)
committerFrancesco Chemolli <kinkie@squid-cache.org>
Wed, 5 Aug 2015 13:47:19 +0000 (15:47 +0200)
Remove module cleanup functions for HttpHeader, HttpHdrCc, HttpHdrSc.
Remove useless includes.
Rename Http::any_registered_header to Http::any_HdrType_enum_value.
Remove useless assert()s in HttpHeaderEntry dtor and HttpHeader::parse.
Clarify documentation for Http::HeaderLookupTable

16 files changed:
src/HttpHdrCc.cc
src/HttpHdrCc.cci
src/HttpHdrCc.h
src/HttpHdrSc.cc
src/HttpHdrSc.h
src/HttpHdrScTarget.cc
src/HttpHdrScTarget.h
src/HttpHeader.cc
src/HttpHeader.h
src/HttpHeaderStat.h
src/HttpHeaderTools.cc
src/acl/RequestHeaderStrategy.h
src/http.cc
src/http/RegisteredHeaders.cc
src/http/RegisteredHeaders.h
src/main.cc

index 3ffd29a5baf916aae1cacfd26f3d30070d7078b9..610657ab0acbf6e54604566886ed7469bece0505 100644 (file)
 #include <vector>
 
 // invariant: row[j].id == j
-static LookupTable<http_hdr_cc_type>::Record CcAttrs[] = {
-    {"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 */
-    {nullptr, CC_ENUM_END}
+static LookupTable<HttpHdrCcType>::Record CcAttrs[] = {
+    {"public", HttpHdrCcType::CC_PUBLIC},
+    {"private", HttpHdrCcType::CC_PRIVATE},
+    {"no-cache", HttpHdrCcType::CC_NO_CACHE},
+    {"no-store", HttpHdrCcType::CC_NO_STORE},
+    {"no-transform", HttpHdrCcType::CC_NO_TRANSFORM},
+    {"must-revalidate", HttpHdrCcType::CC_MUST_REVALIDATE},
+    {"proxy-revalidate", HttpHdrCcType::CC_PROXY_REVALIDATE},
+    {"max-age", HttpHdrCcType::CC_MAX_AGE},
+    {"s-maxage", HttpHdrCcType::CC_S_MAXAGE},
+    {"max-stale", HttpHdrCcType::CC_MAX_STALE},
+    {"min-fresh", HttpHdrCcType::CC_MIN_FRESH},
+    {"only-if-cached", HttpHdrCcType::CC_ONLY_IF_CACHED},
+    {"stale-if-error", HttpHdrCcType::CC_STALE_IF_ERROR},
+    {"Other,", HttpHdrCcType::CC_OTHER}, /* ',' will protect from matches */
+    {nullptr, HttpHdrCcType::CC_ENUM_END}
 };
-LookupTable<http_hdr_cc_type> ccLookupTable(CC_OTHER,CcAttrs);
-std::vector<HttpHeaderFieldStat> ccHeaderStats(CC_ENUM_END);
+LookupTable<HttpHdrCcType> ccLookupTable(HttpHdrCcType::CC_OTHER,CcAttrs);
+std::vector<HttpHeaderFieldStat> ccHeaderStats(HttpHdrCcType::CC_ENUM_END);
 
 /// used to walk a table of http_header_cc_type structs
-http_hdr_cc_type &operator++ (http_hdr_cc_type &aHeader)
+HttpHdrCcType &operator++ (HttpHdrCcType &aHeader)
 {
     int tmp = (int)aHeader;
-    aHeader = (http_hdr_cc_type)(++tmp);
+    aHeader = (HttpHdrCcType)(++tmp);
     return aHeader;
 }
 
@@ -58,17 +58,11 @@ void
 httpHdrCcInitModule(void)
 {
     // check invariant on initialization table
-    for (int j = 0; CcAttrs[j].name != nullptr; ++j) {
-        assert (CcAttrs[j].id == j);
+    for (unsigned int j = 0; CcAttrs[j].name != nullptr; ++j) {
+        assert (static_cast<int>(CcAttrs[j].id) == j);
     }
 }
 
-/// Module cleanup hook.
-void
-httpHdrCcCleanModule(void)
-{
-}
-
 void
 HttpHdrCc::clear()
 {
@@ -97,11 +91,11 @@ HttpHdrCc::parse(const String & str)
         }
 
         /* find type */
-        const http_hdr_cc_type type = ccLookupTable.lookup(SBuf(item,nlen));
+        const HttpHdrCcType type = ccLookupTable.lookup(SBuf(item,nlen));
 
         // ignore known duplicate directives
         if (isSet(type)) {
-            if (type != CC_OTHER) {
+            if (type != HttpHdrCcType::CC_OTHER) {
                 debugs(65, 2, "hdr cc: ignoring duplicate cache-directive: near '" << item << "' in '" << str << "'");
                 ++ ccHeaderStats[type].repCount;
                 continue;
@@ -111,7 +105,7 @@ HttpHdrCc::parse(const String & str)
         /* special-case-parsing and attribute-setting */
         switch (type) {
 
-        case CC_MAX_AGE:
+        case HttpHdrCcType::CC_MAX_AGE:
             if (!p || !httpHeaderParseInt(p, &max_age) || max_age < 0) {
                 debugs(65, 2, "cc: invalid max-age specs near '" << item << "'");
                 clearMaxAge();
@@ -120,7 +114,7 @@ HttpHdrCc::parse(const String & str)
             }
             break;
 
-        case CC_S_MAXAGE:
+        case HttpHdrCcType::CC_S_MAXAGE:
             if (!p || !httpHeaderParseInt(p, &s_maxage) || s_maxage < 0) {
                 debugs(65, 2, "cc: invalid s-maxage specs near '" << item << "'");
                 clearSMaxAge();
@@ -129,7 +123,7 @@ HttpHdrCc::parse(const String & str)
             }
             break;
 
-        case CC_MAX_STALE:
+        case HttpHdrCcType::CC_MAX_STALE:
             if (!p || !httpHeaderParseInt(p, &max_stale) || max_stale < 0) {
                 debugs(65, 2, "cc: max-stale directive is valid without value");
                 maxStale(MAX_STALE_ANY);
@@ -138,7 +132,7 @@ HttpHdrCc::parse(const String & str)
             }
             break;
 
-        case CC_MIN_FRESH:
+        case HttpHdrCcType::CC_MIN_FRESH:
             if (!p || !httpHeaderParseInt(p, &min_fresh) || min_fresh < 0) {
                 debugs(65, 2, "cc: invalid min-fresh specs near '" << item << "'");
                 clearMinFresh();
@@ -147,7 +141,7 @@ HttpHdrCc::parse(const String & str)
             }
             break;
 
-        case CC_STALE_IF_ERROR:
+        case HttpHdrCcType::CC_STALE_IF_ERROR:
             if (!p || !httpHeaderParseInt(p, &stale_if_error) || stale_if_error < 0) {
                 debugs(65, 2, "cc: invalid stale-if-error specs near '" << item << "'");
                 clearStaleIfError();
@@ -156,7 +150,7 @@ HttpHdrCc::parse(const String & str)
             }
             break;
 
-        case CC_PRIVATE: {
+        case HttpHdrCcType::CC_PRIVATE: {
             String temp;
             if (!p)  {
                 // Value parameter is optional.
@@ -171,7 +165,7 @@ HttpHdrCc::parse(const String & str)
         }
         break;
 
-        case CC_NO_CACHE: {
+        case HttpHdrCcType::CC_NO_CACHE: {
             String temp;
             if (!p) {
                 // On Requests, missing value parameter is expected syntax.
@@ -189,26 +183,26 @@ HttpHdrCc::parse(const String & str)
         }
         break;
 
-        case CC_PUBLIC:
+        case HttpHdrCcType::CC_PUBLIC:
             Public(true);
             break;
-        case CC_NO_STORE:
+        case HttpHdrCcType::CC_NO_STORE:
             noStore(true);
             break;
-        case CC_NO_TRANSFORM:
+        case HttpHdrCcType::CC_NO_TRANSFORM:
             noTransform(true);
             break;
-        case CC_MUST_REVALIDATE:
+        case HttpHdrCcType::CC_MUST_REVALIDATE:
             mustRevalidate(true);
             break;
-        case CC_PROXY_REVALIDATE:
+        case HttpHdrCcType::CC_PROXY_REVALIDATE:
             proxyRevalidate(true);
             break;
-        case CC_ONLY_IF_CACHED:
+        case HttpHdrCcType::CC_ONLY_IF_CACHED:
             onlyIfCached(true);
             break;
 
-        case CC_OTHER:
+        case HttpHdrCcType::CC_OTHER:
             if (other.size())
                 other.append(", ");
 
@@ -231,31 +225,31 @@ HttpHdrCc::packInto(Packable * p) const
     if (mask==0)
         return;
 
-    http_hdr_cc_type flag;
+    HttpHdrCcType flag;
     int pcount = 0;
     assert(p);
 
-    for (flag = CC_PUBLIC; flag < CC_ENUM_END; ++flag) {
-        if (isSet(flag) && flag != CC_OTHER) {
+    for (flag = HttpHdrCcType::CC_PUBLIC; flag < HttpHdrCcType::CC_ENUM_END; ++flag) {
+        if (isSet(flag) && flag != HttpHdrCcType::CC_OTHER) {
 
             /* print option name for all options */
             p->appendf((pcount ? ", %s": "%s") , CcAttrs[flag].name);
 
             /* for all options having values, "=value" after the name */
             switch (flag) {
-            case CC_MAX_AGE:
+            case HttpHdrCcType::CC_MAX_AGE:
                 p->appendf("=%d", maxAge());
                 break;
-            case CC_S_MAXAGE:
+            case HttpHdrCcType::CC_S_MAXAGE:
                 p->appendf("=%d", sMaxAge());
                 break;
-            case CC_MAX_STALE:
+            case HttpHdrCcType::CC_MAX_STALE:
                 /* max-stale's value is optional.
                   If we didn't receive it, don't send it */
                 if (maxStale()!=MAX_STALE_ANY)
                     p->appendf("=%d", maxStale());
                 break;
-            case CC_MIN_FRESH:
+            case HttpHdrCcType::CC_MIN_FRESH:
                 p->appendf("=%d", minFresh());
                 break;
             default:
@@ -276,7 +270,7 @@ httpHdrCcUpdateStats(const HttpHdrCc * cc, StatHist * hist)
 {
     assert(cc);
 
-    for (http_hdr_cc_type c = CC_PUBLIC; c < CC_ENUM_END; ++c)
+    for (HttpHdrCcType c = HttpHdrCcType::CC_PUBLIC; c < HttpHdrCcType::CC_ENUM_END; ++c)
         if (cc->isSet(c))
             hist->count(c);
 }
@@ -286,7 +280,7 @@ httpHdrCcStatDumper(StoreEntry * sentry, int, double val, double, int count)
 {
     extern const HttpHeaderStat *dump_stat; /* argh! */
     const int id = static_cast<int>(val);
-    const int valid_id = id < CC_ENUM_END;
+    const bool valid_id = id < HttpHdrCcType::CC_ENUM_END;
     const char *name = valid_id ? CcAttrs[id].name : "INVALID";
 
     if (count || valid_id)
index e910985d94b1ebb1de9b2201032c1629acb771ea..630337435470b8b42342dbcdbb19387529a72c99 100644 (file)
 #include "defines.h"
 
 bool
-HttpHdrCc::isSet(http_hdr_cc_type id) const
+HttpHdrCc::isSet(HttpHdrCcType id) const
 {
-    assert(id>=CC_PUBLIC && id < CC_ENUM_END);
+    assert(id>=HttpHdrCcType::CC_PUBLIC && id < HttpHdrCcType::CC_ENUM_END);
     return EBIT_TEST(mask,id);
 }
 
 void
-HttpHdrCc::setMask(http_hdr_cc_type id, bool newval)
+HttpHdrCc::setMask(HttpHdrCcType id, bool newval)
 {
     if (newval)
         EBIT_SET(mask,id);
@@ -30,7 +30,7 @@ HttpHdrCc::setMask(http_hdr_cc_type id, bool newval)
 /// set a data member to a new value, and set the corresponding mask-bit.
 /// if setting is false, then the mask-bit is cleared.
 void
-HttpHdrCc::setValue(int32_t &value, int32_t new_value, http_hdr_cc_type hdr, bool setting)
+HttpHdrCc::setValue(int32_t &value, int32_t new_value, HttpHdrCcType hdr, bool setting)
 {
     if (setting) {
         if (new_value < 0) {
index 0a8dd4c20a683d1514365475ffc616e48080e6d6..d263adca5a6160e98ad539d7d4082d261ed7816f 100644 (file)
 #define SQUID_HTTPHDRCC_H
 
 #include "dlink.h"
-#include "enums.h"
 #include "mem/forward.h"
 #include "SquidString.h"
 
 class Packable;
 
-typedef enum {
+enum HttpHdrCcType : unsigned char {
     CC_PUBLIC = 0,
     CC_PRIVATE,
     CC_NO_CACHE,
@@ -32,7 +31,7 @@ typedef enum {
     CC_STALE_IF_ERROR,
     CC_OTHER,
     CC_ENUM_END /* also used to mean "invalid" */
-} http_hdr_cc_type;
+};
 
 /** Http Cache-Control header representation
  *
@@ -64,16 +63,16 @@ public:
     bool parse(const String & s);
 
     //manipulation for Cache-Control: public header
-    bool hasPublic() const {return isSet(CC_PUBLIC);}
-    bool Public() const {return isSet(CC_PUBLIC);}
-    void Public(bool v) {setMask(CC_PUBLIC,v);}
-    void clearPublic() {setMask(CC_PUBLIC,false);}
+    bool hasPublic() const {return isSet(HttpHdrCcType::CC_PUBLIC);}
+    bool Public() const {return isSet(HttpHdrCcType::CC_PUBLIC);}
+    void Public(bool v) {setMask(HttpHdrCcType::CC_PUBLIC,v);}
+    void clearPublic() {setMask(HttpHdrCcType::CC_PUBLIC,false);}
 
     //manipulation for Cache-Control: private header
-    bool hasPrivate() const {return isSet(CC_PRIVATE);}
+    bool hasPrivate() const {return isSet(HttpHdrCcType::CC_PRIVATE);}
     const String &Private() const {return private_;}
     void Private(const String &v) {
-        setMask(CC_PRIVATE,true);
+        setMask(HttpHdrCcType::CC_PRIVATE,true);
         if (!v.size())
             return;
         // uses append for multi-line headers
@@ -81,13 +80,13 @@ public:
             private_.append(",");
         private_.append(v);
     }
-    void clearPrivate() {setMask(CC_PRIVATE,false); private_.clean();}
+    void clearPrivate() {setMask(HttpHdrCcType::CC_PRIVATE,false); private_.clean();}
 
     //manipulation for Cache-Control: no-cache header
-    bool hasNoCache() const {return isSet(CC_NO_CACHE);}
+    bool hasNoCache() const {return isSet(HttpHdrCcType::CC_NO_CACHE);}
     const String &noCache() const {return no_cache;}
     void noCache(const String &v) {
-        setMask(CC_NO_CACHE,true);
+        setMask(HttpHdrCcType::CC_NO_CACHE,true);
         if (!v.size())
             return;
         // uses append for multi-line headers
@@ -95,73 +94,73 @@ public:
             no_cache.append(",");
         no_cache.append(v);
     }
-    void clearNoCache() {setMask(CC_NO_CACHE,false); no_cache.clean();}
+    void clearNoCache() {setMask(HttpHdrCcType::CC_NO_CACHE,false); no_cache.clean();}
 
     //manipulation for Cache-Control: no-store header
-    bool hasNoStore() const {return isSet(CC_NO_STORE);}
-    bool noStore() const {return isSet(CC_NO_STORE);}
-    void noStore(bool v) {setMask(CC_NO_STORE,v);}
-    void clearNoStore() {setMask(CC_NO_STORE,false);}
+    bool hasNoStore() const {return isSet(HttpHdrCcType::CC_NO_STORE);}
+    bool noStore() const {return isSet(HttpHdrCcType::CC_NO_STORE);}
+    void noStore(bool v) {setMask(HttpHdrCcType::CC_NO_STORE,v);}
+    void clearNoStore() {setMask(HttpHdrCcType::CC_NO_STORE,false);}
 
     //manipulation for Cache-Control: no-transform header
-    bool hasNoTransform() const {return isSet(CC_NO_TRANSFORM);}
-    bool noTransform() const {return isSet(CC_NO_TRANSFORM);}
-    void noTransform(bool v) {setMask(CC_NO_TRANSFORM,v);}
-    void clearNoTransform() {setMask(CC_NO_TRANSFORM,false);}
+    bool hasNoTransform() const {return isSet(HttpHdrCcType::CC_NO_TRANSFORM);}
+    bool noTransform() const {return isSet(HttpHdrCcType::CC_NO_TRANSFORM);}
+    void noTransform(bool v) {setMask(HttpHdrCcType::CC_NO_TRANSFORM,v);}
+    void clearNoTransform() {setMask(HttpHdrCcType::CC_NO_TRANSFORM,false);}
 
     //manipulation for Cache-Control: must-revalidate header
-    bool hasMustRevalidate() const {return isSet(CC_MUST_REVALIDATE);}
-    bool mustRevalidate() const {return isSet(CC_MUST_REVALIDATE);}
-    void mustRevalidate(bool v) {setMask(CC_MUST_REVALIDATE,v);}
-    void clearMustRevalidate() {setMask(CC_MUST_REVALIDATE,false);}
+    bool hasMustRevalidate() const {return isSet(HttpHdrCcType::CC_MUST_REVALIDATE);}
+    bool mustRevalidate() const {return isSet(HttpHdrCcType::CC_MUST_REVALIDATE);}
+    void mustRevalidate(bool v) {setMask(HttpHdrCcType::CC_MUST_REVALIDATE,v);}
+    void clearMustRevalidate() {setMask(HttpHdrCcType::CC_MUST_REVALIDATE,false);}
 
     //manipulation for Cache-Control: proxy-revalidate header
-    bool hasProxyRevalidate() const {return isSet(CC_PROXY_REVALIDATE);}
-    bool proxyRevalidate() const {return isSet(CC_PROXY_REVALIDATE);}
-    void proxyRevalidate(bool v) {setMask(CC_PROXY_REVALIDATE,v);}
-    void clearProxyRevalidate() {setMask(CC_PROXY_REVALIDATE,false);}
+    bool hasProxyRevalidate() const {return isSet(HttpHdrCcType::CC_PROXY_REVALIDATE);}
+    bool proxyRevalidate() const {return isSet(HttpHdrCcType::CC_PROXY_REVALIDATE);}
+    void proxyRevalidate(bool v) {setMask(HttpHdrCcType::CC_PROXY_REVALIDATE,v);}
+    void clearProxyRevalidate() {setMask(HttpHdrCcType::CC_PROXY_REVALIDATE,false);}
 
     //manipulation for Cache-Control: max-age header
-    bool hasMaxAge() const {return isSet(CC_MAX_AGE);}
+    bool hasMaxAge() const {return isSet(HttpHdrCcType::CC_MAX_AGE);}
     int32_t maxAge() const { return max_age;}
-    void maxAge(int32_t v) {setValue(max_age,v,CC_MAX_AGE); }
-    void clearMaxAge() {setValue(max_age,MAX_AGE_UNKNOWN,CC_MAX_AGE,false);}
+    void maxAge(int32_t v) {setValue(max_age,v,HttpHdrCcType::CC_MAX_AGE); }
+    void clearMaxAge() {setValue(max_age,MAX_AGE_UNKNOWN,HttpHdrCcType::CC_MAX_AGE,false);}
 
     //manipulation for Cache-Control: s-maxage header
-    bool hasSMaxAge() const {return isSet(CC_S_MAXAGE);}
+    bool hasSMaxAge() const {return isSet(HttpHdrCcType::CC_S_MAXAGE);}
     int32_t sMaxAge() const { return s_maxage;}
-    void sMaxAge(int32_t v) {setValue(s_maxage,v,CC_S_MAXAGE); }
-    void clearSMaxAge() {setValue(s_maxage,MAX_AGE_UNKNOWN,CC_S_MAXAGE,false);}
+    void sMaxAge(int32_t v) {setValue(s_maxage,v,HttpHdrCcType::CC_S_MAXAGE); }
+    void clearSMaxAge() {setValue(s_maxage,MAX_AGE_UNKNOWN,HttpHdrCcType::CC_S_MAXAGE,false);}
 
     //manipulation for Cache-Control: max-stale header
-    bool hasMaxStale() const {return isSet(CC_MAX_STALE);}
+    bool hasMaxStale() const {return isSet(HttpHdrCcType::CC_MAX_STALE);}
     int32_t maxStale() const { return max_stale;}
     // max-stale has a special value (MAX_STALE_ANY) which correspond to having
     // the directive without a numeric specification, and directs to consider the object
     // as always-expired.
-    void maxStale(int32_t v) {setValue(max_stale,v,CC_MAX_STALE);}
-    void clearMaxStale() {setValue(max_stale,MAX_STALE_UNKNOWN,CC_MAX_STALE,false);}
+    void maxStale(int32_t v) {setValue(max_stale,v,HttpHdrCcType::CC_MAX_STALE);}
+    void clearMaxStale() {setValue(max_stale,MAX_STALE_UNKNOWN,HttpHdrCcType::CC_MAX_STALE,false);}
 
     //manipulation for Cache-Control:min-fresh header
-    bool hasMinFresh() const {return isSet(CC_MIN_FRESH);}
+    bool hasMinFresh() const {return isSet(HttpHdrCcType::CC_MIN_FRESH);}
     int32_t minFresh() const { return min_fresh;}
-    void minFresh(int32_t v) {if (v < 0) return; setValue(min_fresh,v,CC_MIN_FRESH); }
-    void clearMinFresh() {setValue(min_fresh,MIN_FRESH_UNKNOWN,CC_MIN_FRESH,false);}
+    void minFresh(int32_t v) {if (v < 0) return; setValue(min_fresh,v,HttpHdrCcType::CC_MIN_FRESH); }
+    void clearMinFresh() {setValue(min_fresh,MIN_FRESH_UNKNOWN,HttpHdrCcType::CC_MIN_FRESH,false);}
 
     //manipulation for Cache-Control: only-if-cached header
-    bool hasOnlyIfCached() const {return isSet(CC_ONLY_IF_CACHED);}
-    bool onlyIfCached() const {return isSet(CC_ONLY_IF_CACHED);}
-    void onlyIfCached(bool v) {setMask(CC_ONLY_IF_CACHED,v);}
-    void clearOnlyIfCached() {setMask(CC_ONLY_IF_CACHED,false);}
+    bool hasOnlyIfCached() const {return isSet(HttpHdrCcType::CC_ONLY_IF_CACHED);}
+    bool onlyIfCached() const {return isSet(HttpHdrCcType::CC_ONLY_IF_CACHED);}
+    void onlyIfCached(bool v) {setMask(HttpHdrCcType::CC_ONLY_IF_CACHED,v);}
+    void clearOnlyIfCached() {setMask(HttpHdrCcType::CC_ONLY_IF_CACHED,false);}
 
     //manipulation for Cache-Control: stale-if-error header
-    bool hasStaleIfError() const {return isSet(CC_STALE_IF_ERROR);}
+    bool hasStaleIfError() const {return isSet(HttpHdrCcType::CC_STALE_IF_ERROR);}
     int32_t staleIfError() const { return stale_if_error;}
-    void staleIfError(int32_t v) {setValue(stale_if_error,v,CC_STALE_IF_ERROR); }
-    void clearStaleIfError() {setValue(stale_if_error,STALE_IF_ERROR_UNKNOWN,CC_STALE_IF_ERROR,false);}
+    void staleIfError(int32_t v) {setValue(stale_if_error,v,HttpHdrCcType::CC_STALE_IF_ERROR); }
+    void clearStaleIfError() {setValue(stale_if_error,STALE_IF_ERROR_UNKNOWN,HttpHdrCcType::CC_STALE_IF_ERROR,false);}
 
     /// check whether the attribute value supplied by id is set
-    _SQUID_INLINE_ bool isSet(http_hdr_cc_type id) const;
+    _SQUID_INLINE_ bool isSet(HttpHdrCcType id) const;
 
     void packInto(Packable * p) const;
 
@@ -181,8 +180,8 @@ private:
     String no_cache; ///< List of headers sent as value for CC:no-cache="...". May be empty/undefined if the value is missing.
 
     /// low-level part of the public set method, performs no checks
-    _SQUID_INLINE_ void setMask(http_hdr_cc_type id, bool newval=true);
-    _SQUID_INLINE_ void setValue(int32_t &value, int32_t new_value, http_hdr_cc_type hdr, bool setting=true);
+    _SQUID_INLINE_ void setMask(HttpHdrCcType id, bool newval=true);
+    _SQUID_INLINE_ void setValue(int32_t &value, int32_t new_value, HttpHdrCcType hdr, bool setting=true);
 
 public:
     /**comma-separated representation of the header values which were
@@ -195,7 +194,6 @@ class StatHist;
 class StoreEntry;
 
 void httpHdrCcInitModule(void);
-void httpHdrCcCleanModule(void);
 void httpHdrCcUpdateStats(const HttpHdrCc * cc, StatHist * hist);
 void httpHdrCcStatDumper(StoreEntry * sentry, int idx, double val, double size, int count);
 
index cd58471ee7738ac3a00cdade6a314eec578953f1..a0661a595bfe98f1242a0c0224dd0afbc570ced9 100644 (file)
@@ -10,8 +10,7 @@
 
 #include "squid.h"
 #include "base/LookupTable.h"
-#include "dlink.h"
-#include "HttpHdrSc.h"
+//#include "HttpHdrSc.h" // pulled in by HttpHdrScTarget.h
 #include "HttpHeader.h"
 #include "HttpHeaderFieldStat.h"
 #include "HttpHeaderStat.h"
@@ -54,11 +53,6 @@ httpHdrScInitModule(void)
         assert(i == ScAttrs[i].id);
 }
 
-void
-httpHdrScCleanModule(void)
-{
-}
-
 /* implementation */
 
 /* creates an sc object from a 0-terminating string */
index b310e55f094d3dd952dd58a9f9f0672ce79e2888..6075af953d4a93a5dc3c87c3faa7ddc77181b2b7 100644 (file)
 #define SQUID_HTTPHDRSURROGATECONTROL_H
 
 #include "dlink.h"
-#include "mem/AllocatorProxy.h"
+#include "mem/forward.h"
 #include "SquidString.h"
 
 class HttpHdrScTarget;
-class StatHist;
 class Packable;
+class StatHist;
 class StoreEntry;
 
 typedef enum {
@@ -54,7 +54,6 @@ private:
 /* Http Surrogate Control Header Field */
 void httpHdrScStatDumper(StoreEntry * sentry, int idx, double val, double size, int count);
 void httpHdrScInitModule (void);
-void httpHdrScCleanModule (void);
 HttpHdrSc *httpHdrScParseCreate(String const &);
 void httpHdrScSetMaxAge(HttpHdrSc *, char const *, int);
 
index dc9c0cf7c229cb641a15eaef6d393aca6c886c8a..5699a7b72ad158b1724cb56aaa0f9b8ebb760e04 100644 (file)
@@ -9,7 +9,6 @@
 /* DEBUG: section 90    HTTP Cache Control Header */
 
 #include "squid.h"
-#include "HttpHdrSc.h"
 #include "HttpHdrScTarget.h"
 #include "StatHist.h"
 
index 88a9c4488358604ac10d65d6e7f995a17dcee112..e814be78840cc169d0b461f6479c1d35bd1d1adf 100644 (file)
@@ -9,12 +9,8 @@
 #ifndef SQUID_HTTPHDRSURROGATECONTROLTARGET_H
 #define SQUID_HTTPHDRSURROGATECONTROLTARGET_H
 
-#include "defines.h"
-#include "dlink.h"
+#include "defines.h" //for bit mask operations
 #include "HttpHdrSc.h"
-#include "mem/forward.h"
-#include "SquidString.h"
-#include "typedefs.h"
 
 class Packable;
 class StatHist;
index 5bb87555d6d16c6c52760093358a113e738ffafe..4550675aabc03fa1c53ae6d318e0d73dffa4a110 100644 (file)
@@ -9,12 +9,12 @@
 /* DEBUG: section 55    HTTP Header */
 
 #include "squid.h"
-#include "base/LookupTable.h"
+//#include "base/LookupTable.h" // pulled by HttpHdrCc.h
 #include "base64.h"
 #include "globals.h"
 #include "HttpHdrCc.h"
 #include "HttpHdrContRange.h"
-#include "HttpHdrSc.h"
+#include "HttpHdrScTarget.h" // also includes HttpHdrSc.h
 #include "HttpHeader.h"
 #include "HttpHeaderFieldInfo.h"
 #include "HttpHeaderStat.h"
@@ -24,7 +24,7 @@
 #include "profiler/Profiler.h"
 #include "rfc1123.h"
 #include "SquidConfig.h"
-#include "SquidString.h"
+//#include "SquidString.h" // pulled by HttpHdrCc.h
 #include "StatHist.h"
 #include "Store.h"
 #include "StrList.h"
@@ -294,13 +294,6 @@ httpHeaderInitModule(void)
     httpHeaderRegisterWithCacheManager();
 }
 
-void
-httpHeaderCleanModule(void)
-{
-    httpHdrCcCleanModule();
-    httpHdrScCleanModule();
-}
-
 /*
  * HttpHeader Implementation
  */
@@ -369,11 +362,10 @@ HttpHeader::clean()
         HttpHeaderStats[owner].busyDestroyedCount += entries.size() > 0;
     } // if (owner <= hoReply)
 
-    for (std::vector<HttpHeaderEntry *>::iterator i = entries.begin(); i != entries.end(); ++i) {
-        HttpHeaderEntry *e = *i;
-        if (e == NULL)
+    for(HttpHeaderEntry *e : entries) {
+        if (e == nullptr)
             continue;
-        if (e->id >= Http::HdrType::ENUM_END) {
+        if (!Http::any_valid_header(e->id)) {
             debugs(55, DBG_CRITICAL, "BUG: invalid entry (" << e->id << "). Ignored.");
         } else {
             if (owner <= hoReply)
@@ -562,7 +554,7 @@ HttpHeader::parse(const char *header_start, size_t hdrLen)
             return reset();
         }
 
-        if (e->id == Http::HdrType::CONTENT_LENGTH && (e2 = findEntry(e->id)) != NULL) {
+        if (e->id == Http::HdrType::CONTENT_LENGTH && (e2 = findEntry(e->id)) != nullptr) {
             if (e->value != e2->value) {
                 int64_t l1, l2;
                 debugs(55, warnOnError, "WARNING: found two conflicting content-length headers in {" <<
@@ -837,7 +829,7 @@ void
 HttpHeader::addEntry(HttpHeaderEntry * e)
 {
     assert(e);
-    assert(any_registered_header(e->id));
+    assert(any_HdrType_enum_value(e->id));
     assert(e->name.size());
 
     debugs(55, 7, this << " adding entry: " << e->id << " at " << entries.size());
@@ -1445,7 +1437,7 @@ HttpHeader::getTimeOrTag(Http::HdrType id) const
 
 HttpHeaderEntry::HttpHeaderEntry(Http::HdrType anId, const char *aName, const char *aValue)
 {
-    assert(any_registered_header(anId));
+    assert(any_HdrType_enum_value(anId));
     id = anId;
 
     if (id != Http::HdrType::OTHER)
@@ -1455,7 +1447,7 @@ HttpHeaderEntry::HttpHeaderEntry(Http::HdrType anId, const char *aName, const ch
 
     value = aValue;
 
-    if (anId != Http::HdrType::BAD_HDR)
+    if (id != Http::HdrType::BAD_HDR)
         ++ headerStatsTable[id].aliveCount;
 
     debugs(55, 9, "created HttpHeaderEntry " << this << ": '" << name << " : " << value );
@@ -1463,14 +1455,14 @@ HttpHeaderEntry::HttpHeaderEntry(Http::HdrType anId, const char *aName, const ch
 
 HttpHeaderEntry::~HttpHeaderEntry()
 {
-    assert(any_valid_header(id));
     debugs(55, 9, "destroying entry " << this << ": '" << name << ": " << value << "'");
 
-    // Http::HdrType::BAD_HDR is filtered out by assert_any_valid_header
-    assert(headerStatsTable[id].aliveCount);
-    -- headerStatsTable[id].aliveCount;
+    if (id != Http::HdrType::BAD_HDR) {
+        assert(headerStatsTable[id].aliveCount);
+        -- headerStatsTable[id].aliveCount;
+        id = Http::HdrType::BAD_HDR; // it already is BAD_HDR, no sense in resetting it
+    }
 
-    id = Http::HdrType::BAD_HDR;
 }
 
 /* parses and inits header entry, returns true/false */
@@ -1522,8 +1514,6 @@ HttpHeaderEntry::parse(const char *field_start, const char *field_end)
     if (id == Http::HdrType::BAD_HDR)
         id = Http::HdrType::OTHER;
 
-    assert(any_valid_header(id));
-
     /* set field name */
     if (id == Http::HdrType::OTHER)
         name.limitInit(field_start, name_len);
@@ -1623,7 +1613,7 @@ void
 httpHeaderFieldStatDumper(StoreEntry * sentry, int, double val, double, int count)
 {
     const int id = static_cast<int>(val);
-    const bool valid_id = id < Http::HdrType::ENUM_END;
+    const bool valid_id = Http::any_valid_header(static_cast<Http::HdrType>(id));
     const char *name = valid_id ? Http::HeaderTable[id].name : "INVALID";
     int visible = count > 0;
     /* for entries with zero count, list only those that belong to current type of message */
index 21c7e9b95197ce34118f8887a0d2fbae09336175..2bd345d8a5d8b9691403b2e752a2dac5dcf8057c 100644 (file)
@@ -163,7 +163,6 @@ HttpHeader::chunked() const
 }
 
 void httpHeaderInitModule(void);
-void httpHeaderCleanModule(void);
 
 #endif /* SQUID_HTTPHEADER_H */
 
index 546ebd602a3c7c3d1d8e71f0924b507ac3050585..6610c7c9a42198d33a191d5cc3071c18bd098831 100644 (file)
@@ -28,7 +28,7 @@ public:
     {
         hdrUCountDistr.enumInit(32);    /* not a real enum */
         fieldTypeDistr.enumInit(Http::HdrType::ENUM_END);
-        ccTypeDistr.enumInit(CC_ENUM_END);
+        ccTypeDistr.enumInit(HttpHdrCcType::CC_ENUM_END);
         scTypeDistr.enumInit(SC_ENUM_END);
     }
 
@@ -44,7 +44,7 @@ public:
         assert(label);
         hdrUCountDistr.enumInit(32);    /* not a real enum */
         fieldTypeDistr.enumInit(Http::HdrType::ENUM_END);
-        ccTypeDistr.enumInit(CC_ENUM_END);
+        ccTypeDistr.enumInit(HttpHdrCcType::CC_ENUM_END);
         scTypeDistr.enumInit(SC_ENUM_END);
     }
 
index cfab7b876c50d9cfd1e564d046bfb746d96a7812..a8d6ac7dfa84731615c1008deef7a9a8be3cca9f 100644 (file)
@@ -454,7 +454,7 @@ const headerMangler *
 HeaderManglers::find(const HttpHeaderEntry &e) const
 {
     // a known header with a configured ACL list
-    if (e.id != Http::HdrType::OTHER && Http::any_registered_header(e.id) &&
+    if (e.id != Http::HdrType::OTHER && Http::any_HdrType_enum_value(e.id) &&
             known[e.id].access_list)
         return &known[e.id];
 
index b1fcd4170baaccbf4aa6937d138a9e7dae24d583..43b06825a99bdddedbd96bb54f7f5c16994ae2b0 100644 (file)
@@ -15,7 +15,6 @@
 #include "HttpRequest.h"
 
 template <Http::HdrType header>
-
 class ACLRequestHeaderStrategy : public ACLStrategy<char const *>
 {
 
index 57a6e03c169eebaf4fdcd5857a25df454d5c34c3..a73a971ed81f6e1a75021abe776fd501aa57b016 100644 (file)
@@ -1896,7 +1896,7 @@ HttpStateData::httpBuildRequestHeader(HttpRequest * request,
 #if 0 /* see bug 2330 */
         /* Set no-cache if determined needed but not found */
         if (request->flags.nocache)
-            EBIT_SET(cc->mask, CC_NO_CACHE);
+            EBIT_SET(cc->mask, HttpHdrCcType::CC_NO_CACHE);
 #endif
 
         /* Add max-age only without no-cache */
index 96fea1daa6a75fd4e8f0123f3c16e1451cfd7a88..4ba8cf2cfba4e5370c9b103d66bf70586555a116 100644 (file)
@@ -13,6 +13,7 @@
 
 namespace Http
 {
+
 /*
  * A table with major attributes for every known field.
  *
index 25f51c2b76424118f0f556a6d27a4d893d28a73c..8555f3f8ac03fe841c6d47b3a36a4f6e9a0e97c8 100644 (file)
@@ -150,11 +150,17 @@ public:
 /// header ID->namelookup table.
 extern const HeaderTableRecord HeaderTable[];
 
-/// for header name->id lookup, use HeaderLookupTable.lookup(hdr-as-sbuf);
+/** LookupTable for HTTP Header name -> Http::HdrType lookup.
+ *
+ * use as HeaderLookupTable.lookup(header-as-sbuf).
+ * It will return Http::HdrType::HDR_BAD if the header is unknown/not registered,
+ * including the case of Http::HdrType::OTHER, which will have to be handled
+ * by the caller.
+ */
 extern const LookupTable<Http::HdrType, HeaderTableRecord> HeaderLookupTable;
 
 inline bool
-any_registered_header (const Http::HdrType id)
+any_HdrType_enum_value (const Http::HdrType id)
 {
     return (id == Http::HdrType::BAD_HDR || (id >= Http::HdrType::ACCEPT && id < Http::HdrType::ENUM_END));
 }
@@ -165,7 +171,6 @@ any_valid_header (const Http::HdrType id)
     return (id >= Http::HdrType::ACCEPT && id < Http::HdrType::ENUM_END);
 }
 
-
 }; /* namespace Http */
 
 std::ostream &
index 9ca20c179654364826c7ee9cb6430451e92867c6..6cb50cb9912fdd5377b72838fe0aa195f267c9d2 100644 (file)
@@ -2010,7 +2010,6 @@ SquidShutdown()
     fqdncacheFreeMemory();
     asnFreeMemory();
     clientdbFreeMemory();
-    httpHeaderCleanModule();
     statFreeMemory();
     eventFreeMemory();
     mimeFreeMemory();