From: Francesco Chemolli Date: Thu, 30 Jul 2015 15:01:46 +0000 (+0200) Subject: Add todo list, re-add HDR_OTHER, implement parallel lookup, shuffle HDR_BAD_HDR at... X-Git-Tag: merge-candidate-3-v1~19 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fadc02c95761c87bfc8ae5eb7fb72ed25822d1be;p=thirdparty%2Fsquid.git Add todo list, re-add HDR_OTHER, implement parallel lookup, shuffle HDR_BAD_HDR at end of enum list --- diff --git a/src/HttpHeader.cc b/src/HttpHeader.cc index f36412d8d1..d587ccdb0b 100644 --- a/src/HttpHeader.cc +++ b/src/HttpHeader.cc @@ -159,6 +159,17 @@ static const HttpHeaderFieldAttrs HeadersAttrs[] = { HttpHeaderFieldAttrs("Other:", HDR_OTHER, ftStr) /* ':' will not allow matches */ }; +/* TODO: + * DONE 1. shift HDR_BAD_HDR to end of enum + * 2. shift headers data array to http/RegistredHeaders.cc + * 3. creatign LookupTable object from teh enum and array + * (with HDR_BAD_HDR as invalid value) + * 4. replacing httpHeaderIdByName() uses with the lookup table + * 5. merge HDR_BAD_HDR and HDR_ENUM_END into one thing + * 6. replacing httpHeaderNameById with direct array lookups + * 7. being looking at the other arrays removal + */ + struct HeaderTableRecord { const char *name; http_hdr_type id; @@ -257,12 +268,13 @@ static const HeaderTableRecord headerTable[] = { {"FTP-Pre", HDR_FTP_PRE, ftStr}, {"FTP-Status", HDR_FTP_STATUS, ftInt}, {"FTP-Reason", HDR_FTP_REASON, ftStr}, - {nullptr, HDR_OTHER} /* ':' will not allow matches */ + {"Other:", HDR_OTHER, ftStr}, /* ':' will not allow matches */ + {nullptr, HDR_BAD_HDR} /* ':' will not allow matches */ }; static HttpHeaderFieldInfo *Headers = NULL; -LookupTable headerLookupTable(HDR_OTHER, headerTable); -std::vector headerStatsTable(HDR_OTHER); +LookupTable headerLookupTable(HDR_BAD_HDR, headerTable); +std::vector headerStatsTable(HDR_OTHER+1); http_hdr_type &operator++ (http_hdr_type &aHeader) { @@ -1732,6 +1744,9 @@ HttpHeaderEntry::parse(const char *field_start, const char *field_end) /* is it a "known" field? */ http_hdr_type id = httpHeaderIdByName(field_start, name_len, Headers, HDR_ENUM_END); + http_hdr_type id2 = headerLookupTable.lookup(SBuf(field_start,name_len)); + debugs(55, 9, "got hdr id hdr: " << id << ", new hdr: " << id2); + assert(id == id2); String name; diff --git a/src/http/RegisteredHeaders.h b/src/http/RegisteredHeaders.h index 67f4cc5e94..63a6812ed1 100644 --- a/src/http/RegisteredHeaders.h +++ b/src/http/RegisteredHeaders.h @@ -12,7 +12,6 @@ /// recognized or "known" header fields; and the RFC which defines them (or not) /// http://www.iana.org/assignments/message-headers/message-headers.xhtml typedef enum { - HDR_BAD_HDR = -1, HDR_ACCEPT = 0, /**< RFC 7231 */ HDR_ACCEPT_CHARSET, /**< RFC 7231 */ HDR_ACCEPT_ENCODING, /**< RFC 7231 */ @@ -116,7 +115,8 @@ typedef enum { HDR_FTP_STATUS, /**< Internal header for FTP reply status */ HDR_FTP_REASON, /**< Internal header for FTP reply reason */ HDR_OTHER, /**< internal tag value for "unknown" headers */ - HDR_ENUM_END + HDR_ENUM_END, + HDR_BAD_HDR = -1 } http_hdr_type; #endif /* SQUID_HTTP_REGISTEREDHEADERS_H */