summaryrefslogtreecommitdiff
path: root/http_connection.cpp
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2011-01-02 21:22:57 +0100
committerVegard Storheil Eriksen <zyp@jvnv.net>2011-01-02 21:45:46 +0100
commit226fd63fab4b5b605c62049c6a9d765de8d6c4db (patch)
tree541e78e6e47117dccecdb1b56b5c666132305849 /http_connection.cpp
parentf78248234b3f284b77a35b3249ccfb526d18c871 (diff)
Add PathList, fix path_p.
Diffstat (limited to 'http_connection.cpp')
-rw-r--r--http_connection.cpp15
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();
+}