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
#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;
}
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()
{
}
/* 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;
/* 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();
}
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();
}
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);
}
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();
}
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();
}
break;
- case CC_PRIVATE: {
+ case HttpHdrCcType::CC_PRIVATE: {
String temp;
if (!p) {
// Value parameter is optional.
}
break;
- case CC_NO_CACHE: {
+ case HttpHdrCcType::CC_NO_CACHE: {
String temp;
if (!p) {
// On Requests, missing value parameter is expected syntax.
}
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(", ");
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:
{
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);
}
{
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)
#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);
/// 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) {
#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,
CC_STALE_IF_ERROR,
CC_OTHER,
CC_ENUM_END /* also used to mean "invalid" */
-} http_hdr_cc_type;
+};
/** Http Cache-Control header representation
*
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
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
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;
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
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);
#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"
assert(i == ScAttrs[i].id);
}
-void
-httpHdrScCleanModule(void)
-{
-}
-
/* implementation */
/* creates an sc object from a 0-terminating string */
#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 {
/* 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);
/* DEBUG: section 90 HTTP Cache Control Header */
#include "squid.h"
-#include "HttpHdrSc.h"
#include "HttpHdrScTarget.h"
#include "StatHist.h"
#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;
/* 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"
#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"
httpHeaderRegisterWithCacheManager();
}
-void
-httpHeaderCleanModule(void)
-{
- httpHdrCcCleanModule();
- httpHdrScCleanModule();
-}
-
/*
* HttpHeader Implementation
*/
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)
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 {" <<
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());
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)
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 );
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 */
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);
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 */
}
void httpHeaderInitModule(void);
-void httpHeaderCleanModule(void);
#endif /* SQUID_HTTPHEADER_H */
{
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);
}
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);
}
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];
#include "HttpRequest.h"
template <Http::HdrType header>
-
class ACLRequestHeaderStrategy : public ACLStrategy<char const *>
{
#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 */
namespace Http
{
+
/*
* A table with major attributes for every known field.
*
/// 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));
}
return (id >= Http::HdrType::ACCEPT && id < Http::HdrType::ENUM_END);
}
-
}; /* namespace Http */
std::ostream &
fqdncacheFreeMemory();
asnFreeMemory();
clientdbFreeMemory();
- httpHeaderCleanModule();
statFreeMemory();
eventFreeMemory();
mimeFreeMemory();