class StoreEntry;
-/// check that ID is any registered header (except for HDR_ENUM_END, but
-/// including HDR_BAD_HDR
static inline
-void assert_any_registered_header(const http_hdr_type id)
+bool
+any_registered_header (const http_hdr_type id)
{
- assert (id == HDR_BAD_HDR || (id >= HDR_ACCEPT && id < HDR_ENUM_END));
+ return (id == HDR_BAD_HDR || (id >= HDR_ACCEPT && id < HDR_ENUM_END));
}
-/// check that id is a valid header (any registered except for HDR_ENUM_END
-/// and HDR_BAD_HDR
static inline
-void assert_any_valid_header(const http_hdr_type id)
+bool
+any_valid_header (const http_hdr_type id)
{
- assert(id >= HDR_ACCEPT && id < HDR_ENUM_END);
+ return (id >= HDR_ACCEPT && id < HDR_ENUM_END);
}
static void httpHeaderNoteParsedEntry(http_hdr_type id, String const &value, int error);
HttpHeaderEntry *e = *i;
if (e == NULL)
continue;
- if (e->id < 0 || e->id >= HDR_ENUM_END) {
+ if (e->id >= HDR_ENUM_END) {
debugs(55, DBG_CRITICAL, "BUG: invalid entry (" << e->id << "). Ignored.");
} else {
if (owner <= hoReply)
{
HttpHeaderPos pos = HttpHeaderInitPos;
HttpHeaderEntry *e;
- assert_any_valid_header(id);
+ assert(any_valid_header(id));
assert(!CBIT_TEST(ListHeadersMask, id));
/* check mask first */
HttpHeaderPos pos = HttpHeaderInitPos;
HttpHeaderEntry *e;
HttpHeaderEntry *result = NULL;
- assert_any_valid_header(id);
+ assert(any_valid_header(id));
assert(!CBIT_TEST(ListHeadersMask, id));
/* check mask first */
HttpHeaderPos pos = HttpHeaderInitPos;
HttpHeaderEntry *e;
debugs(55, 8, this << " del-by-id " << id);
- assert_any_valid_header(id);
+ assert(any_valid_header(id));
assert(id != HDR_OTHER); /* does not make sense */
if (!CBIT_TEST(mask, id))
HttpHeader::addEntry(HttpHeaderEntry * e)
{
assert(e);
- assert_any_registered_header(e->id);
+ assert(any_registered_header(e->id));
assert(e->name.size());
debugs(55, 7, this << " adding entry: " << e->id << " at " << entries.size());
HttpHeader::insertEntry(HttpHeaderEntry * e)
{
assert(e);
- assert_any_valid_header(e->id);
+ assert(any_valid_header(e->id));
debugs(55, 7, this << " adding entry: " << e->id << " at " << entries.size());
int ilen;
int mlen = strlen(member);
- assert_any_valid_header(id);
+ assert(any_valid_header(id));
header = getStrOrList(id);
String result;
int
HttpHeader::has(http_hdr_type id) const
{
- assert_any_valid_header(id);
+ assert(any_valid_header(id));
assert(id != HDR_OTHER);
debugs(55, 9, this << " lookup for " << id);
return CBIT_TEST(mask, id);
void
HttpHeader::putInt(http_hdr_type id, int number)
{
- assert_any_valid_header(id);
+ assert(any_valid_header(id));
assert(headerTable[id].type == field_type::ftInt); /* must be of an appropriate type */
assert(number >= 0);
addEntry(new HttpHeaderEntry(id, NULL, xitoa(number)));
void
HttpHeader::putInt64(http_hdr_type id, int64_t number)
{
- assert_any_valid_header(id);
+ assert(any_valid_header(id));
assert(headerTable[id].type == field_type::ftInt64); /* must be of an appropriate type */
assert(number >= 0);
addEntry(new HttpHeaderEntry(id, NULL, xint64toa(number)));
void
HttpHeader::putTime(http_hdr_type id, time_t htime)
{
- assert_any_valid_header(id);
+ assert(any_valid_header(id));
assert(headerTable[id].type == field_type::ftDate_1123); /* must be of an appropriate type */
assert(htime >= 0);
addEntry(new HttpHeaderEntry(id, NULL, mkrfc1123(htime)));
void
HttpHeader::insertTime(http_hdr_type id, time_t htime)
{
- assert_any_valid_header(id);
+ assert(any_valid_header(id));
assert(headerTable[id].type == field_type::ftDate_1123); /* must be of an appropriate type */
assert(htime >= 0);
insertEntry(new HttpHeaderEntry(id, NULL, mkrfc1123(htime)));
void
HttpHeader::putStr(http_hdr_type id, const char *str)
{
- assert_any_valid_header(id);
+ assert(any_valid_header(id));
assert(headerTable[id].type == field_type::ftStr); /* must be of an appropriate type */
assert(str);
addEntry(new HttpHeaderEntry(id, NULL, str));
int
HttpHeader::getInt(http_hdr_type id) const
{
- assert_any_valid_header(id);
+ assert(any_valid_header(id));
assert(headerTable[id].type == field_type::ftInt); /* must be of an appropriate type */
HttpHeaderEntry *e;
int64_t
HttpHeader::getInt64(http_hdr_type id) const
{
- assert_any_valid_header(id);
+ assert(any_valid_header(id));
assert(headerTable[id].type == field_type::ftInt64); /* must be of an appropriate type */
HttpHeaderEntry *e;
{
HttpHeaderEntry *e;
time_t value = -1;
- assert_any_valid_header(id);
+ assert(any_valid_header(id));
assert(headerTable[id].type == field_type::ftDate_1123); /* must be of an appropriate type */
if ((e = findEntry(id))) {
HttpHeader::getStr(http_hdr_type id) const
{
HttpHeaderEntry *e;
- assert_any_valid_header(id);
+ assert(any_valid_header(id));
assert(headerTable[id].type == field_type::ftStr); /* must be of an appropriate type */
if ((e = findEntry(id))) {
HttpHeader::getLastStr(http_hdr_type id) const
{
HttpHeaderEntry *e;
- assert_any_valid_header(id);
+ assert(any_valid_header(id));
assert(headerTable[id].type == field_type::ftStr); /* must be of an appropriate type */
if ((e = findLastEntry(id))) {
HttpHeaderEntry::HttpHeaderEntry(http_hdr_type anId, const char *aName, const char *aValue)
{
- assert_any_registered_header(anId);
+ assert(any_registered_header(anId));
id = anId;
if (id != HDR_OTHER)
HttpHeaderEntry::~HttpHeaderEntry()
{
- assert_any_valid_header(id);
+ assert(any_valid_header(id));
debugs(55, 9, "destroying entry " << this << ": '" << name << ": " << value << "'");
// HDR_BAD_HDR is filtered out by assert_any_valid_header
String value;
- if (id < 0)
+ if (id == HDR_BAD_HDR)
id = HDR_OTHER;
- assert_any_registered_header(id);
+ assert(any_valid_header(id));
/* set field name */
if (id == HDR_OTHER)
int
HttpHeaderEntry::getInt() const
{
- assert_any_valid_header(id);
+ 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);
+ assert(any_valid_header(id));
int64_t val = -1;
int ok = httpHeaderParseOffset(value.termedBuf(), &val);
httpHeaderNoteParsedEntry(id, value, !ok);
httpHeaderFieldStatDumper(StoreEntry * sentry, int, double val, double, int count)
{
const int id = (int) val;
- const int valid_id = id >= 0 && id < HDR_ENUM_END;
+ const int valid_id = id < HDR_ENUM_END;
const char *name = valid_id ? headerTable[id].name : "INVALID";
int visible = count > 0;
/* for entries with zero count, list only those that belong to current type of message */
int ilen;
int mlen = strlen(member);
- assert_any_valid_header(id);
+ assert(any_valid_header(id));
String header (getStrOrList(id));