3 #include <boost/algorithm/string.hpp> 4 #include <boost/foreach.hpp> 5 #include <boost/regex.hpp> 10 static boost::regex
uri_regex(
"(.*?)(?:\\?(.*?))?");
17 path.assign(match[1].first, match[1].second);
20 query.assign(match[2].first, match[2].second);
22 std::vector<std::string> pair_strings;
23 boost::split(pair_strings,
query, boost::is_any_of(
"&"));
24 BOOST_FOREACH (
const std::string& pair_string, pair_strings)
26 std::vector<std::string> pair_data;
27 const auto eq_index = pair_string.find_first_of(
'=');
28 if (eq_index == std::string::npos)
30 if (pair_string.size() > 0)
38 pair_string.substr(eq_index + 1);
52 typedef std::vector<async_web_server_cpp::HttpHeader> HeaderList;
53 for (HeaderList::const_iterator itr =
headers.begin(); itr !=
headers.end();
56 if (itr->name.compare(name) == 0)
63 const std::string& default_value)
const 65 typedef std::vector<async_web_server_cpp::HttpHeader> HeaderList;
66 for (HeaderList::const_iterator itr =
headers.begin(); itr !=
headers.end();
69 if (itr->name.compare(name) == 0)
77 std::map<std::string, std::string>::const_iterator itr =
83 const std::string& name,
const std::string& default_value)
const 85 std::map<std::string, std::string>::const_iterator itr =
std::map< std::string, std::string > query_params
std::string get_header_value_or_default(const std::string &name, const std::string &default_value) const
std::vector< HttpHeader > headers
static boost::regex uri_regex("(.*?)(?:\(.*?))?")
bool has_header(const std::string &name) const
std::string get_query_param_value_or_default(const std::string &name, const std::string &default_value) const
bool has_query_param(const std::string &name) const