diff options
Diffstat (limited to 'http_connection.cpp')
-rw-r--r-- | http_connection.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/http_connection.cpp b/http_connection.cpp index 0e9571c..d940b2f 100644 --- a/http_connection.cpp +++ b/http_connection.cpp @@ -22,7 +22,7 @@ void HTTP::Connection::handle_read(const boost::system::error_code& error, size_ } std::cout << "Path: " << std::endl; - for(std::vector<std::string>::iterator it = path.begin(); it != path.end(); it++) { + for(PathList::iterator it = path.begin(); it != path.end(); it++) { std::cout << " " << *it << std::endl; } @@ -55,7 +55,7 @@ bool HTTP::Connection::parse_request(boost::asio::streambuf& buf) { qi::rule<Iterator, char()> urlchar_p = (qi::char_ - '%') | ('%' >> qi::uint_parser<char, 16, 2, 2>()); - qi::rule<Iterator, std::vector<std::string>()> path_p = '/' >> +(urlchar_p - '/' - '?' - ' ') % '/'; + qi::rule<Iterator, PathList()> path_p = *(+qi::lit('/') >> +(urlchar_p - '/' - '?' - ' ')) >> *qi::lit('/'); qi::rule<Iterator, std::pair<std::string, std::string>()> pair_p = +(urlchar_p - '=') >> '=' >> +(urlchar_p - '&' - ' '); qi::rule<Iterator, std::map<std::string, std::string>()> args_p = '?' >> pair_p >> *('&' >> pair_p); @@ -78,3 +78,14 @@ void HTTP::Connection::read_request(Handler callback) { boost::asio::async_read_until(socket, buf, "\r\n\r\n", boost::bind(&Connection::handle_read, shared_from_this(), boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred, callback)); } + +std::string HTTP::Connection::pop_path_base() { + if(!path.size()) { + return ""; + } + + base_path.push_back(path.front()); + path.pop_front(); + + return base_path.back(); +} |