#include <map>
/* a row in the table used for parsing cache control header and statistics */
-typedef struct {
+class HttpHeaderCcFields
+{
+public:
+ HttpHeaderCcFields() : name(NULL), id(CC_BADHDR), stat() {}
+ HttpHeaderCcFields(const char *aName, http_hdr_cc_type aTypeId) : name(aName), id(aTypeId) {}
+ // nothing to do as name is a pointer to global static string
+ ~HttpHeaderCcFields() {}
+
const char *name;
http_hdr_cc_type id;
HttpHeaderFieldStat stat;
-} HttpHeaderCcFields;
+
+private:
+ HttpHeaderCcFields(const HttpHeaderCcFields &); // not implemented
+ HttpHeaderCcFields &operator =(const HttpHeaderCcFields &); // not implemented
+};
/* order must match that of enum http_hdr_cc_type. The constraint is verified at initialization time */
static HttpHeaderCcFields CcAttrs[CC_ENUM_END] = {
};
/* header accounting */
+// NP: keep in sync with enum http_hdr_owner_type
static HttpHeaderStat HttpHeaderStats[] = {
- {"all"},
+ {/*hoNone*/ "all", NULL},
#if USE_HTCP
- {"HTCP reply"},
+ {/*hoHtcpReply*/ "HTCP reply", &ReplyHeadersMask},
#endif
- {"request"},
- {"reply"}
+ {/*hoRequest*/ "request", &RequestHeadersMask},
+ {/*hoReply*/ "reply", &ReplyHeadersMask}
+#if USE_OPENSSL
+ /* hoErrorDetail */
+#endif
+ /* hoEnd */
};
static int HttpHeaderStatCount = countof(HttpHeaderStats);
static void httpHeaderNoteParsedEntry(http_hdr_type id, String const &value, int error);
-static void httpHeaderStatInit(HttpHeaderStat * hs, const char *label);
static void httpHeaderStatDump(const HttpHeaderStat * hs, StoreEntry * e);
/** store report about current header usage and other stats */
void
httpHeaderInitModule(void)
{
- int i;
/* check that we have enough space for masks */
assert(8 * sizeof(HttpHeaderMask) >= HDR_ENUM_END);
/* all headers must be described */
httpHeaderMaskInit(&HopByHopHeadersMask, 0);
httpHeaderCalcMask(&HopByHopHeadersMask, HopByHopHeadersArr, countof(HopByHopHeadersArr));
- /* init header stats */
+ /* header stats initialized by class constructor */
assert(HttpHeaderStatCount == hoReply + 1);
- for (i = 0; i < HttpHeaderStatCount; ++i)
- httpHeaderStatInit(HttpHeaderStats + i, HttpHeaderStats[i].label);
-
- HttpHeaderStats[hoRequest].owner_mask = &RequestHeadersMask;
-
- HttpHeaderStats[hoReply].owner_mask = &ReplyHeadersMask;
-
-#if USE_HTCP
- HttpHeaderStats[hoHtcpReply].owner_mask = &ReplyHeadersMask;
-#endif
/* init dependent modules */
httpHdrCcInitModule();
httpHdrScCleanModule();
}
-static void
-httpHeaderStatInit(HttpHeaderStat * hs, const char *label)
-{
- assert(hs);
- assert(label);
- memset(hs, 0, sizeof(HttpHeaderStat));
- hs->label = label;
- hs->hdrUCountDistr.enumInit(32); /* not a real enum */
- hs->fieldTypeDistr.enumInit(HDR_ENUM_END);
- hs->ccTypeDistr.enumInit(CC_ENUM_END);
- hs->scTypeDistr.enumInit(SC_ENUM_END);
-}
-
/*
* HttpHeader Implementation
*/
hoEnd
} http_hdr_owner_type;
-// currently a POD
class HttpHeaderFieldAttrs
{
public:
+ HttpHeaderFieldAttrs() : name(NULL), id(HDR_BAD_HDR), type(ftInvalid) {}
+ HttpHeaderFieldAttrs(const char *aName, http_hdr_type anId, field_type aType = ftInvalid) : name(aName), id(anId), type(aType) {}
+#if __cplusplus >= 201103L
+ HttpHeaderFieldAttrs(const HttpHeaderFieldAttrs &) = default;
+ HttpHeaderFieldAttrs(HttpHeaderFieldAttrs &&) = default;
+#endif
+ // nothing to do as name is a pointer to global const string
+ ~HttpHeaderFieldAttrs() {}
+
const char *name;
http_hdr_type id;
field_type type;
#include "StatHist.h"
-/// per header statistics
+/// HTTP per header statistics
class HttpHeaderStat
{
public:
+ HttpHeaderStat() :
+ label(NULL),
+ owner_mask(NULL),
+ parsedCount(0),
+ ccParsedCount(0),
+ scParsedCount(0),
+ destroyedCount(0),
+ busyDestroyedCount(0)
+ {
+ hdrUCountDistr.enumInit(32); /* not a real enum */
+ fieldTypeDistr.enumInit(HDR_ENUM_END);
+ ccTypeDistr.enumInit(CC_ENUM_END);
+ scTypeDistr.enumInit(SC_ENUM_END);
+ }
+
+ HttpHeaderStat(const char *aLabel, HttpHeaderMask *aMask) :
+ label(aLabel),
+ owner_mask(aMask),
+ parsedCount(0),
+ ccParsedCount(0),
+ scParsedCount(0),
+ destroyedCount(0),
+ busyDestroyedCount(0)
+ {
+ assert(label);
+ hdrUCountDistr.enumInit(32); /* not a real enum */
+ fieldTypeDistr.enumInit(HDR_ENUM_END);
+ ccTypeDistr.enumInit(CC_ENUM_END);
+ scTypeDistr.enumInit(SC_ENUM_END);
+ }
+
+ // nothing to destruct as label is a pointer to global const string
+ // and owner_mask is a pointer to global static array
+ ~HttpHeaderStat() {}
+
const char *label;
HttpHeaderMask *owner_mask;
class TokenTableEntry
{
public:
+ TokenTableEntry() : configTag(NULL), tokenType(LFT_NONE), options(0) {}
+ TokenTableEntry(const char *aTag, const ByteCode_t &aType) : configTag(aTag), tokenType(aType), options(0) {}
+ // nothing to destruct configTag is pointer to global const string
+ ~TokenTableEntry() {}
+
/// the config file ASCII representation for this token
/// just the base tag bytes, excluding any option syntax bytes
const char *configTag;
/// 32-bit mask? of options affecting the output display of this token
uint32_t options;
+
+private:
+ TokenTableEntry(const TokenTableEntry&); // not implemented
+ TokenTableEntry &operator =(const TokenTableEntry&); // not implemented
};
} // namespace Format