Unbreak header parsing; it was broken by the case-sensitivity fixes.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 16 Apr 2018 19:06:25 +0000 (21:06 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 16 Apr 2018 19:06:25 +0000 (21:06 +0200)
parse.h

diff --git a/parse.h b/parse.h
index a2e3580..70b3b5a 100644 (file)
--- a/parse.h
+++ b/parse.h
@@ -21,14 +21,15 @@ static inline char ascii_tolower(const char ch)
 }
 
 // Case-insensitive header comparison and hashing.
-struct HTTPLess {
+struct HTTPEqual {
        bool operator() (const std::string &a, const std::string &b) const
        {
-               return std::lexicographical_compare(
-                       begin(a), end(a), begin(b), end(b),
-                       [](char a, char b) {
-                               return ascii_tolower(a) < ascii_tolower(b);
-                       });
+               return a.size() == b.size() &&
+                       std::equal(
+                               begin(a), end(a), begin(b),
+                               [](char a, char b) {
+                                       return ascii_tolower(a) == ascii_tolower(b);
+                               });
        }
 };
 struct HTTPHash {
@@ -39,7 +40,7 @@ struct HTTPHash {
                return std::hash<std::string>() (s_low);
        }
 };
-using HTTPHeaderMultimap = std::unordered_multimap<std::string, std::string, HTTPHash, HTTPLess>;
+using HTTPHeaderMultimap = std::unordered_multimap<std::string, std::string, HTTPHash, HTTPEqual>;
 
 // Split a line on whitespace, e.g. "foo  bar baz" -> {"foo", "bar", "baz"}.
 std::vector<std::string> split_tokens(const std::string &line);