]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Add todo list, re-add HDR_OTHER, implement parallel lookup, shuffle HDR_BAD_HDR at...
authorFrancesco Chemolli <kinkie@squid-cache.org>
Thu, 30 Jul 2015 15:01:46 +0000 (17:01 +0200)
committerFrancesco Chemolli <kinkie@squid-cache.org>
Thu, 30 Jul 2015 15:01:46 +0000 (17:01 +0200)
src/HttpHeader.cc
src/http/RegisteredHeaders.h

index f36412d8d1b2dd06273f243cdcfa6535f2ab55e6..d587ccdb0b54e6bfff38f070169f9c35eba63a2b 100644 (file)
@@ -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<http_hdr_type, HeaderTableRecord> headerLookupTable(HDR_OTHER, headerTable);
-std::vector<HttpHeaderFieldStat> headerStatsTable(HDR_OTHER);
+LookupTable<http_hdr_type, HeaderTableRecord> headerLookupTable(HDR_BAD_HDR, headerTable);
+std::vector<HttpHeaderFieldStat> 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;
 
index 67f4cc5e94baa678811b40fa4a06a87afbb4bfef..63a6812ed15290cdd34c6c57a52c26982e972094 100644 (file)
@@ -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 */