diff --git a/server_http.hpp b/server_http.hpp index c65543df..010d5764 100644 --- a/server_http.hpp +++ b/server_http.hpp @@ -53,6 +53,26 @@ class case_insensitive_hash { #endif namespace SimpleWeb { + class RequestBase { + public: + //Based on http://www.boost.org/doc/libs/1_60_0/doc/html/unordered/hash_equality.html + class iequal_to { + public: + bool operator()(const std::string &key1, const std::string &key2) const { + return boost::algorithm::iequals(key1, key2); + } + }; + class ihash { + public: + size_t operator()(const std::string &key) const { + std::size_t seed=0; + for(auto &c: key) + boost::hash_combine(seed, std::tolower(c)); + return seed; + } + }; + }; + template class Server; @@ -92,9 +112,10 @@ namespace SimpleWeb { Content(boost::asio::streambuf &streambuf): std::istream(&streambuf), streambuf(streambuf) {} }; - class Request { + class Request: public RequestBase { friend class ServerBase; friend class Server; + public: std::string method, path, http_version; @@ -145,8 +166,8 @@ namespace SimpleWeb { class regex_orderable : public REGEX_NS::regex { std::string str; public: - regex_orderable(const char *regex_cstr) : std::regex(regex_cstr), str(regex_cstr) {} - regex_orderable(const std::string ®ex_str) : std::regex(regex_str), str(regex_str) {} + regex_orderable(const char *regex_cstr) : REGEX_NS::regex(regex_cstr), str(regex_cstr) {} + regex_orderable(const std::string ®ex_str) : REGEX_NS::regex(regex_str), str(regex_str) {} bool operator<(const regex_orderable &rhs) const { return str