void
httpHdrCcUpdateStats(const HttpHdrCc * cc, StatHist * hist)
{
- http_hdr_cc_type c;
assert(cc);
- for (c = CC_PUBLIC; c < CC_ENUM_END; ++c)
+ for (http_hdr_cc_type c = CC_PUBLIC; c < CC_ENUM_END; ++c)
if (cc->isSet(c))
hist->count(c);
}
httpHdrCcStatDumper(StoreEntry * sentry, int, double val, double, int count)
{
extern const HttpHeaderStat *dump_stat; /* argh! */
- const int id = (int) val;
- const int valid_id = id >= 0 && id < CC_ENUM_END;
+ const int id = static_cast<int>(val);
+ const int valid_id = id < CC_ENUM_END;
const char *name = valid_id ? CcAttrs[id].name : "INVALID";
if (count || valid_id)
*/
-LookupTable<http_hdr_type, HeaderTableRecord> headerLookupTable(HDR_BAD_HDR, headerTable);
+const LookupTable<http_hdr_type, HeaderTableRecord> headerLookupTable(HDR_BAD_HDR, headerTable);
std::vector<HttpHeaderFieldStat> headerStatsTable(HDR_OTHER+1);
/*
for (int i = 0; headerTable[i].name; ++i)
assert(headerTable[i].id == i);
- // use headerLookupTable in place of Headers
-
- /* create masks */
+ /* create masks. XXX: migrate to std::vector<bool>? */
httpHeaderMaskInit(&ListHeadersMask, 0);
httpHeaderCalcMask(&ListHeadersMask, ListHeadersArr, countof(ListHeadersArr));
assert(name);
/* First try the quick path */
- id = httpHeaderIdByNameDef(SBuf(name));
+ id = headerLookupTable.lookup(SBuf(name));
- if (id != -1) {
+ if (id != HDR_BAD_HDR) {
if (!has(id))
return false;
result = getStrOrList(id);
storeAppendPrintf(e, "Hdr Fields Parsed: %d\n", HeaderEntryParsedCount);
}
-http_hdr_type
-httpHeaderIdByNameDef(const SBuf &name)
-{
- return headerLookupTable.lookup(name);
-}
-
-http_hdr_type
-httpHeaderIdByNameDef(const char *name, int name_len)
-{
- return headerLookupTable.lookup(SBuf(name,name_len));
-}
-
int
HttpHeader::hasListMember(http_hdr_type id, const char *member, const char separator) const
{
#ifndef SQUID_HTTPHEADER_H
#define SQUID_HTTPHEADER_H
+#include "base/LookupTable.h"
#include "http/RegisteredHeaders.h"
/* because we pass a spec by value */
#include "HttpHeaderMask.h"
class HttpHdrRange;
class HttpHdrSc;
class Packable;
-class StoreEntry;
class SBuf;
/** Possible owners of http header */
void httpHeaderInitModule(void);
void httpHeaderCleanModule(void);
+// for header string->id lookup, use headerLookupTable.lookup(hdr-as-sbuf);
+extern const LookupTable<http_hdr_type, HeaderTableRecord> headerLookupTable;
+
#endif /* SQUID_HTTPHEADER_H */
headerMangler *
HeaderManglers::track(const char *name)
{
- int id = httpHeaderIdByNameDef(SBuf(name));
+ int id = headerLookupTable.lookup(SBuf(name));
if (id == HDR_BAD_HDR) { // special keyword or a custom header
if (strcmp(name, "All") == 0)
class HeaderWithAcl;
class HttpHeader;
-class HttpHeaderFieldInfo;
class HttpRequest;
class StoreEntry;
class String;
int httpHeaderParseOffset(const char *start, int64_t * off);
-http_hdr_type httpHeaderIdByNameDef(const SBuf &name);
-http_hdr_type httpHeaderIdByNameDef(const char *name, int name_len);
int httpHeaderHasConnDir(const HttpHeader * hdr, const char *directive);
int httpHeaderParseInt(const char *start, int *val);
void httpHeaderPutStrf(HttpHeader * hdr, http_hdr_type id, const char *fmt,...) PRINTF_FORMAT_ARG3;
char* t = ConfigParser::strtokFile();
assert (t != NULL);
hdrName = t;
- hdrId = httpHeaderIdByNameDef(SBuf(hdrName));
+ hdrId = headerLookupTable.lookup(SBuf(hdrName));
regex_rule->parse();
}
}
HeaderWithAcl hwa;
hwa.fieldName = fn;
- hwa.fieldId = httpHeaderIdByNameDef(SBuf(fn));
+ hwa.fieldId = headerLookupTable.lookup(SBuf(fn));
if (hwa.fieldId == HDR_BAD_HDR)
hwa.fieldId = HDR_OTHER;
} peer_t;
typedef enum {
- CC_BADHDR = -1,
CC_PUBLIC = 0,
CC_PRIVATE,
CC_NO_CACHE,
CC_ONLY_IF_CACHED,
CC_STALE_IF_ERROR,
CC_OTHER,
- CC_ENUM_END
+ CC_ENUM_END /* also used to mean "invalid" */
} http_hdr_cc_type;
typedef enum {
SC_MAX_AGE,
SC_CONTENT,
SC_OTHER,
- SC_ENUM_END
+ SC_ENUM_END /* also used to mean "invalid" */
} http_hdr_sc_type;
typedef enum _mem_status_t {
}
format->header = xstrdup(header);
- format->header_id = httpHeaderIdByNameDef(SBuf(header));
+ format->header_id = headerLookupTable.lookup(SBuf(header));
}
void