]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Shuffle HeaderLookupTable to RegisteredHeaders.{h,cc}
authorFrancesco Chemolli <kinkie@squid-cache.org>
Tue, 4 Aug 2015 14:58:58 +0000 (16:58 +0200)
committerFrancesco Chemolli <kinkie@squid-cache.org>
Tue, 4 Aug 2015 14:58:58 +0000 (16:58 +0200)
src/HttpHeader.cc
src/HttpHeader.h
src/HttpHeaderTools.cc
src/acl/HttpHeaderData.cc
src/base/LookupTable.h
src/cache_cf.cc
src/external_acl.cc
src/http/RegisteredHeaders.cc
src/http/RegisteredHeaders.h

index ca07b609c3d41a99928e7479ecdfbdc8571cb76f..790f488346b76dd72890b00fc3cc355900be754e 100644 (file)
@@ -60,8 +60,6 @@
  * local constants and vars
  */
 
-const LookupTable<http_hdr_type, HeaderTableRecord> headerLookupTable(HDR_BAD_HDR, headerTable);
-
 // statistics counters for headers. clients must not allow HDR_BAD_HDR to be counted
 std::vector<HttpHeaderFieldStat> headerStatsTable(HDR_ENUM_END);
 
@@ -998,7 +996,7 @@ HttpHeader::getByNameIfPresent(const char *name, String &result) const
     assert(name);
 
     /* First try the quick path */
-    id = headerLookupTable.lookup(SBuf(name));
+    id = HeaderLookupTable.lookup(SBuf(name));
 
     if (id != HDR_BAD_HDR) {
         if (!has(id))
@@ -1528,7 +1526,7 @@ HttpHeaderEntry::parse(const char *field_start, const char *field_end)
     debugs(55, 9, "parsing HttpHeaderEntry: near '" <<  getStringPrefix(field_start, field_end-field_start) << "'");
 
     /* is it a "known" field? */
-    http_hdr_type id = headerLookupTable.lookup(SBuf(field_start,name_len));
+    http_hdr_type id = HeaderLookupTable.lookup(SBuf(field_start,name_len));
     debugs(55, 9, "got hdr id hdr: " << id);
 
     String name;
index cafc130bda3f5cf86d87add05558020699941954..453539d2da720221be2a33c8e4f27beb568a20fb 100644 (file)
@@ -165,8 +165,5 @@ HttpHeader::chunked() const
 void httpHeaderInitModule(void);
 void httpHeaderCleanModule(void);
 
-// for header string->id lookup, use headerLookupTable.lookup(hdr-as-sbuf);
-extern const LookupTable<http_hdr_type, HeaderTableRecord> headerLookupTable;
-
 #endif /* SQUID_HTTPHEADER_H */
 
index 789445fe056d70a80f18651936a3521ffe0ccb04..d67dd1911ef0d21d7b2d1a1744b86f03c2f768d1 100644 (file)
@@ -417,7 +417,7 @@ HeaderManglers::dumpReplacement(StoreEntry * entry, const char *name) const
 headerMangler *
 HeaderManglers::track(const char *name)
 {
-    int id = headerLookupTable.lookup(SBuf(name));
+    int id = HeaderLookupTable.lookup(SBuf(name));
 
     if (id == HDR_BAD_HDR) { // special keyword or a custom header
         if (strcmp(name, "All") == 0)
index 8c010aa2428be5521934282902216f50eb6b0f4e..f1a1f5301030f649b566491f09e0c9178dcefae1 100644 (file)
@@ -76,7 +76,7 @@ ACLHTTPHeaderData::parse()
     char* t = ConfigParser::strtokFile();
     assert (t != NULL);
     hdrName = t;
-    hdrId = headerLookupTable.lookup(SBuf(hdrName));
+    hdrId = HeaderLookupTable.lookup(SBuf(hdrName));
     regex_rule->parse();
 }
 
index 265d44e0d057a6558ce908738cfac4ee87900e30..4803644be028c7879c6c40c210e60a0133140afd 100644 (file)
@@ -46,11 +46,13 @@ struct LookupTableRecord
  *
  */
 
-struct SBufCaseInsensitiveLess : public std::binary_function<SBuf, SBuf, bool> {
+class SBufCaseInsensitiveLess : public std::binary_function<SBuf, SBuf, bool> {
+public:
     bool operator() (const SBuf &x, const SBuf &y) const {
         return x.caseCmp(y) < 0;
     }
 };
+
 template<typename EnumType, typename RecordType = LookupTableRecord<EnumType> >
 class LookupTable
 {
index 8a9c3625b4398f743e31e162310457687b86adcc..164ae9800663598e3deaa167ee8b46d003ba33f4 100644 (file)
@@ -4608,7 +4608,7 @@ static void parse_HeaderWithAclList(HeaderWithAclList **headers)
     }
     HeaderWithAcl hwa;
     hwa.fieldName = fn;
-    hwa.fieldId = headerLookupTable.lookup(SBuf(fn));
+    hwa.fieldId = HeaderLookupTable.lookup(SBuf(fn));
     if (hwa.fieldId == HDR_BAD_HDR)
         hwa.fieldId = HDR_OTHER;
 
index 4a5265c8989c1083429258282b8ea0fe3bd99dba..966ceef7cddf391e66e70d9344cff2076da237b7 100644 (file)
@@ -244,7 +244,7 @@ parse_header_token(external_acl_format::Pointer format, char *header, const Form
     }
 
     format->header = xstrdup(header);
-    format->header_id = headerLookupTable.lookup(SBuf(header));
+    format->header_id = HeaderLookupTable.lookup(SBuf(header));
 }
 
 void
index aba759af2329aa808ac3e5ae2f8d8ccf94e4af75..718ab6036e1491799f196f9f7f236b03d97c5f1d 100644 (file)
@@ -110,3 +110,4 @@ const HeaderTableRecord headerTable[] = {
     {nullptr, HDR_BAD_HDR, field_type::ftInvalid}    /* end of table */
 };
 
+const LookupTable<http_hdr_type, HeaderTableRecord> HeaderLookupTable(HDR_BAD_HDR, headerTable);
index 3a0baf0060abde988d971ff9964b4c26a7a82dfb..335d53b3895ce83c664cb4500c8cb6e4dba87802 100644 (file)
@@ -9,6 +9,8 @@
 #ifndef SQUID_HTTP_REGISTEREDHEADERS_H
 #define SQUID_HTTP_REGISTEREDHEADERS_H
 
+#include "base/LookupTable.h"
+
 /// 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 {
@@ -142,8 +144,11 @@ public:
     field_type type;
 };
 
-/// header name->http_hdr_type lookup table.
+/// header ID->namelookup table.
 extern const HeaderTableRecord headerTable[];
 
+/// for header name->id lookup, use HeaderLookupTable.lookup(hdr-as-sbuf);
+extern const LookupTable<http_hdr_type, HeaderTableRecord> HeaderLookupTable;
+
 #endif /* SQUID_HTTP_REGISTEREDHEADERS_H */