From: Alex Rousskov Date: Sun, 19 May 2013 03:19:50 +0000 (-0600) Subject: Use case-insensitive comparison for HTTP header names in *_header_access X-Git-Tag: SQUID_3_3_5~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c54e12ba863fcdd84d506aba59b8410f842d7bb2;p=thirdparty%2Fsquid.git Use case-insensitive comparison for HTTP header names in *_header_access --- diff --git a/src/HttpHeaderTools.h b/src/HttpHeaderTools.h index bdaf6f7da6..01b1b710d0 100644 --- a/src/HttpHeaderTools.h +++ b/src/HttpHeaderTools.h @@ -5,6 +5,9 @@ #include "HttpHeader.h" #include "typedefs.h" +#if HAVE_FUNCTIONAL +#include +#endif #if HAVE_LIST #include #endif @@ -14,6 +17,9 @@ #if HAVE_STRING #include #endif +#if HAVE_STRINGS_H +#include +#endif class acl_access; class ACLList; @@ -56,8 +62,18 @@ public: void dumpReplacement(StoreEntry *entry, const char *optionName) const; private: + /// Case-insensitive std::string "less than" comparison functor. + /// Fast version recommended by Meyers' "Effective STL" for ASCII c-strings. + class NoCaseLessThan: public std::binary_function + { + public: + bool operator()(const std::string &lhs, const std::string &rhs) const { + return strcasecmp(lhs.c_str(), rhs.c_str()) < 0; + } + }; + /// a name:mangler map; optimize: use unordered map or some such - typedef std::map ManglersByName; + typedef std::map ManglersByName; /// one mangler for each known header headerMangler known[HDR_ENUM_END];