class StoreEntry;
-static inline
-bool
-any_registered_header (const Http::HdrType id)
-{
- return (id == Http::HdrType::BAD_HDR || (id >= Http::HdrType::ACCEPT && id < Http::HdrType::ENUM_END));
-}
-
-static inline
-bool
-any_valid_header (const Http::HdrType id)
-{
- return (id >= Http::HdrType::ACCEPT && id < Http::HdrType::ENUM_END);
-}
-
static void httpHeaderNoteParsedEntry(Http::HdrType id, String const &value, int error);
static void httpHeaderStatDump(const HttpHeaderStat * hs, StoreEntry * e);
/** store report about current header usage and other stats */
assert(8 * sizeof(HttpHeaderMask) >= Http::HdrType::ENUM_END);
// check invariant: for each index in headerTable, (int)headerTable[index] = index
- for (int i = 0; headerTable[i].name; ++i)
- assert(headerTable[i].id == i);
+ for (int i = 0; Http::HeaderTable[i].name; ++i)
+ assert(Http::HeaderTable[i].id == i);
/* create masks. XXX: migrate to std::vector<bool>? */
httpHeaderMaskInit(&ListHeadersMask, 0);
if (denied_mask && CBIT_TEST(*denied_mask, e->id))
continue;
- debugs(55, 7, "Updating header '" << headerTable[e->id].name << "' in cached entry");
+ debugs(55, 7, "Updating header '" << Http::HeaderTable[e->id].name << "' in cached entry");
addEntry(e->clone());
}
*/
/* temporary warning: remove it? (Is it useful for diagnostics ?) */
if (!s->size())
- debugs(55, 3, "empty list header: " << headerTable[id].name << "(" << id << ")");
+ debugs(55, 3, "empty list header: " << Http::HeaderTable[id].name << "(" << id << ")");
else
debugs(55, 6, this << ": joined for id " << id << ": " << s);
*/
/* temporary warning: remove it? (Is it useful for diagnostics ?) */
if (!s.size())
- debugs(55, 3, "empty list header: " << headerTable[id].name << "(" << id << ")");
+ debugs(55, 3, "empty list header: " << Http::HeaderTable[id].name << "(" << id << ")");
else
debugs(55, 6, this << ": joined for id " << id << ": " << s);
assert(name);
/* First try the quick path */
- id = HeaderLookupTable.lookup(SBuf(name));
+ id = Http::HeaderLookupTable.lookup(SBuf(name));
if (id != Http::HdrType::BAD_HDR) {
if (!has(id))
HttpHeader::putInt(Http::HdrType id, int number)
{
assert(any_valid_header(id));
- assert(headerTable[id].type == Http::HdrFieldType::ftInt); /* must be of an appropriate type */
+ assert(Http::HeaderTable[id].type == Http::HdrFieldType::ftInt); /* must be of an appropriate type */
assert(number >= 0);
addEntry(new HttpHeaderEntry(id, NULL, xitoa(number)));
}
HttpHeader::putInt64(Http::HdrType id, int64_t number)
{
assert(any_valid_header(id));
- assert(headerTable[id].type == Http::HdrFieldType::ftInt64); /* must be of an appropriate type */
+ assert(Http::HeaderTable[id].type == Http::HdrFieldType::ftInt64); /* must be of an appropriate type */
assert(number >= 0);
addEntry(new HttpHeaderEntry(id, NULL, xint64toa(number)));
}
HttpHeader::putTime(Http::HdrType id, time_t htime)
{
assert(any_valid_header(id));
- assert(headerTable[id].type == Http::HdrFieldType::ftDate_1123); /* must be of an appropriate type */
+ assert(Http::HeaderTable[id].type == Http::HdrFieldType::ftDate_1123); /* must be of an appropriate type */
assert(htime >= 0);
addEntry(new HttpHeaderEntry(id, NULL, mkrfc1123(htime)));
}
HttpHeader::insertTime(Http::HdrType id, time_t htime)
{
assert(any_valid_header(id));
- assert(headerTable[id].type == Http::HdrFieldType::ftDate_1123); /* must be of an appropriate type */
+ assert(Http::HeaderTable[id].type == Http::HdrFieldType::ftDate_1123); /* must be of an appropriate type */
assert(htime >= 0);
insertEntry(new HttpHeaderEntry(id, NULL, mkrfc1123(htime)));
}
HttpHeader::putStr(Http::HdrType id, const char *str)
{
assert(any_valid_header(id));
- assert(headerTable[id].type == Http::HdrFieldType::ftStr); /* must be of an appropriate type */
+ assert(Http::HeaderTable[id].type == Http::HdrFieldType::ftStr); /* must be of an appropriate type */
assert(str);
addEntry(new HttpHeaderEntry(id, NULL, str));
}
HttpHeader::getInt(Http::HdrType id) const
{
assert(any_valid_header(id));
- assert(headerTable[id].type == Http::HdrFieldType::ftInt); /* must be of an appropriate type */
+ assert(Http::HeaderTable[id].type == Http::HdrFieldType::ftInt); /* must be of an appropriate type */
HttpHeaderEntry *e;
if ((e = findEntry(id)))
HttpHeader::getInt64(Http::HdrType id) const
{
assert(any_valid_header(id));
- assert(headerTable[id].type == Http::HdrFieldType::ftInt64); /* must be of an appropriate type */
+ assert(Http::HeaderTable[id].type == Http::HdrFieldType::ftInt64); /* must be of an appropriate type */
HttpHeaderEntry *e;
if ((e = findEntry(id)))
HttpHeaderEntry *e;
time_t value = -1;
assert(any_valid_header(id));
- assert(headerTable[id].type == Http::HdrFieldType::ftDate_1123); /* must be of an appropriate type */
+ assert(Http::HeaderTable[id].type == Http::HdrFieldType::ftDate_1123); /* must be of an appropriate type */
if ((e = findEntry(id))) {
value = parse_rfc1123(e->value.termedBuf());
{
HttpHeaderEntry *e;
assert(any_valid_header(id));
- assert(headerTable[id].type == Http::HdrFieldType::ftStr); /* must be of an appropriate type */
+ assert(Http::HeaderTable[id].type == Http::HdrFieldType::ftStr); /* must be of an appropriate type */
if ((e = findEntry(id))) {
httpHeaderNoteParsedEntry(e->id, e->value, 0); /* no errors are possible */
{
HttpHeaderEntry *e;
assert(any_valid_header(id));
- assert(headerTable[id].type == Http::HdrFieldType::ftStr); /* must be of an appropriate type */
+ assert(Http::HeaderTable[id].type == Http::HdrFieldType::ftStr); /* must be of an appropriate type */
if ((e = findLastEntry(id))) {
httpHeaderNoteParsedEntry(e->id, e->value, 0); /* no errors are possible */
{
ETag etag = {NULL, -1};
HttpHeaderEntry *e;
- assert(headerTable[id].type == Http::HdrFieldType::ftETag); /* must be of an appropriate type */
+ assert(Http::HeaderTable[id].type == Http::HdrFieldType::ftETag); /* must be of an appropriate type */
if ((e = findEntry(id)))
etagParseInit(&etag, e->value.termedBuf());
{
TimeOrTag tot;
HttpHeaderEntry *e;
- assert(headerTable[id].type == Http::HdrFieldType::ftDate_1123_or_ETag); /* must be of an appropriate type */
+ assert(Http::HeaderTable[id].type == Http::HdrFieldType::ftDate_1123_or_ETag); /* must be of an appropriate type */
memset(&tot, 0, sizeof(tot));
if ((e = findEntry(id))) {
id = anId;
if (id != Http::HdrType::OTHER)
- name = headerTable[id].name;
+ name = Http::HeaderTable[id].name;
else
name = aName;
debugs(55, 9, "destroying entry " << this << ": '" << name << ": " << value << "'");
// Http::HdrType::BAD_HDR is filtered out by assert_any_valid_header
- assert(headerStatsTable[id].aliveCount); // is this really needed?
+ assert(headerStatsTable[id].aliveCount);
-- headerStatsTable[id].aliveCount;
id = Http::HdrType::BAD_HDR;
debugs(55, 9, "parsing HttpHeaderEntry: near '" << getStringPrefix(field_start, field_end-field_start) << "'");
/* is it a "known" field? */
- Http::HdrType id = HeaderLookupTable.lookup(SBuf(field_start,name_len));
- debugs(55, 9, "got hdr id hdr: " << id);
+ Http::HdrType id = Http::HeaderLookupTable.lookup(SBuf(field_start,name_len));
+ debugs(55, 9, "got hdr-id=" << id);
String name;
if (id == Http::HdrType::OTHER)
name.limitInit(field_start, name_len);
else
- name = headerTable[id].name;
+ name = Http::HeaderTable[id].name;
/* trim field value */
while (value_start < field_end && xisspace(*value_start))
int
HttpHeaderEntry::getInt() const
{
- assert(any_valid_header(id));
int val = -1;
int ok = httpHeaderParseInt(value.termedBuf(), &val);
httpHeaderNoteParsedEntry(id, value, !ok);
int64_t
HttpHeaderEntry::getInt64() const
{
- assert(any_valid_header(id));
int64_t val = -1;
int ok = httpHeaderParseOffset(value.termedBuf(), &val);
httpHeaderNoteParsedEntry(id, value, !ok);
if (error) {
if (id != Http::HdrType::BAD_HDR)
++ headerStatsTable[id].errCount;
- debugs(55, 2, "cannot parse hdr field: '" << headerTable[id].name << ": " << context << "'");
+ debugs(55, 2, "cannot parse hdr field: '" << Http::HeaderTable[id].name << ": " << context << "'");
}
}
void
httpHeaderFieldStatDumper(StoreEntry * sentry, int, double val, double, int count)
{
- const int id = (int) val;
- const int valid_id = id < Http::HdrType::ENUM_END;
- const char *name = valid_id ? headerTable[id].name : "INVALID";
+ const int id = static_cast<int>(val);
+ const bool valid_id = id < Http::HdrType::ENUM_END;
+ 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 */
"id", "name", "#alive", "%err", "%repeat");
// scan heaaderTable and output
- for (int j = 0; headerTable[j].name != nullptr; ++j) {
+ for (int j = 0; Http::HeaderTable[j].name != nullptr; ++j) {
auto stats = headerStatsTable[j];
storeAppendPrintf(e, "%2d\t %-25s\t %5d\t %6.3f\t %6.3f\n",
- headerTable[j].id, headerTable[j].name, stats.aliveCount,
+ Http::HeaderTable[j].id,
+ Http::HeaderTable[j].name,
+ stats.aliveCount,
xpercent(stats.errCount, stats.parsCount),
xpercent(stats.repCount, stats.seenCount));
}