From 226fd63fab4b5b605c62049c6a9d765de8d6c4db Mon Sep 17 00:00:00 2001 From: Vegard Storheil Eriksen Date: Sun, 2 Jan 2011 21:22:57 +0100 Subject: Add PathList, fix path_p. --- http_connection.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'http_connection.cpp') 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::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 urlchar_p = (qi::char_ - '%') | ('%' >> qi::uint_parser()); - qi::rule()> path_p = '/' >> +(urlchar_p - '/' - '?' - ' ') % '/'; + qi::rule path_p = *(+qi::lit('/') >> +(urlchar_p - '/' - '?' - ' ')) >> *qi::lit('/'); qi::rule()> pair_p = +(urlchar_p - '=') >> '=' >> +(urlchar_p - '&' - ' '); qi::rule()> 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(); +} -- cgit v1.2.3