Skip to content
This repository was archived by the owner on Jun 12, 2018. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions server_http.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 socket_type>
class Server;

Expand Down Expand Up @@ -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<socket_type>;
friend class Server<socket_type>;

public:
std::string method, path, http_version;

Expand Down Expand Up @@ -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 &regex_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 &regex_str) : REGEX_NS::regex(regex_str), str(regex_str) {}
bool operator<(const regex_orderable &rhs) const {
return str<rhs.str;
}
Expand Down