#include "util.h"
#include <algorithm>
+#include <array>
/* XXX: the whole set of API managing the entries vector should be rethought
* after the parse4r-ng effort is complete.
/* header accounting */
// NP: keep in sync with enum http_hdr_owner_type
-static HttpHeaderStat HttpHeaderStats[] = {
+static std::array<HttpHeaderStat, hoEnd> HttpHeaderStats = {
HttpHeaderStat(/*hoNone*/ "all", NULL),
#if USE_HTCP
HttpHeaderStat(/*hoHtcpReply*/ "HTCP reply", &ReplyHeadersMask),
HttpHeaderStat(/*hoRequest*/ "request", &RequestHeadersMask),
HttpHeaderStat(/*hoReply*/ "reply", &ReplyHeadersMask)
#if USE_OPENSSL
- /* hoErrorDetail */
+ , HttpHeaderStat(/*hoErrorDetail*/ "error detail templates", nullptr)
#endif
/* hoEnd */
};
-static int HttpHeaderStatCount = countof(HttpHeaderStats);
static int HeaderEntryParsedCount = 0;
CBIT_SET(ReplyHeadersMask,h);
}
- /* header stats initialized by class constructor */
- assert(HttpHeaderStatCount == hoReply + 1);
+ assert(HttpHeaderStats[0].label && "httpHeaderInitModule() called via main()");
+ assert(HttpHeaderStats[hoEnd-1].label && "HttpHeaderStats created with all elements");
/* init dependent modules */
httpHdrCcInitModule();
assert(hs);
assert(e);
+ if (!hs->owner_mask)
+ return; // these HttpHeaderStat objects were not meant to be dumped here
+
dump_stat = hs;
storeAppendPrintf(e, "\nHeader Stats: %s\n", hs->label);
storeAppendPrintf(e, "\nField type distribution\n");
void
httpHeaderStoreReport(StoreEntry * e)
{
- int i;
assert(e);
HttpHeaderStats[0].parsedCount =
HttpHeaderStats[0].busyDestroyedCount =
HttpHeaderStats[hoRequest].busyDestroyedCount + HttpHeaderStats[hoReply].busyDestroyedCount;
- for (i = 1; i < HttpHeaderStatCount; ++i) {
- httpHeaderStatDump(HttpHeaderStats + i, e);
- }
+ for (const auto &stats: HttpHeaderStats)
+ httpHeaderStatDump(&stats, e);
/* field stats for all messages */
storeAppendPrintf(e, "\nHttp Fields Stats (replies and requests)\n");