summaryrefslogtreecommitdiff
path: root/http_connection.cpp
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2010-12-31 00:09:06 +0100
committerVegard Storheil Eriksen <zyp@jvnv.net>2010-12-31 00:09:06 +0100
commit9a5138ce981697e243fa0de2bc2668eaa80efb76 (patch)
tree9c177496360871ecb4751ef894762d43b31a5897 /http_connection.cpp
parentf1d6b1400f5192ef97f84ab4fd7ce83a60168dba (diff)
Hacked stuff to work again.
Diffstat (limited to 'http_connection.cpp')
-rw-r--r--http_connection.cpp39
1 files changed, 20 insertions, 19 deletions
diff --git a/http_connection.cpp b/http_connection.cpp
index fb45aac..e682037 100644
--- a/http_connection.cpp
+++ b/http_connection.cpp
@@ -15,10 +15,28 @@ HTTP::Connection::Connection(boost::asio::io_service& io_service) : socket(io_se
void HTTP::Connection::handle_write(const boost::system::error_code& error, size_t bytes_transferred) {
}
+void HTTP::Connection::foo_handler(HTTP::Connection::p connection) {
+ std::cout << "Handling!" << std::endl;
+
+ HTTPResponse res(connection->socket);
+
+ MusicListing::p ml = music::get(connection->path);
+ if(ml) {
+ res.code = 200;
+ res.status = "OK";
+
+ ml->render(connection, res);
+ } else {
+ res.code = 404;
+ res.status = "Not Found";
+ }
+}
+
void HTTP::Connection::handle_read(const boost::system::error_code& error, size_t bytes_transferred) {
if(!parse_request(buf)) {
// Request parse error.
- return;
+ std::cout << "Request parse error." << std::endl;
+ //return;
}
std::cout << "Path: " << std::endl;
@@ -36,24 +54,7 @@ void HTTP::Connection::handle_read(const boost::system::error_code& error, size_
std::cout << " " << it->first << " = " << it->second << std::endl;
}
- return;
-
- std::istream is(&buf);
-
- HTTPRequest req(is);
-
- HTTPResponse res(socket);
-
- MusicListing::p ml = music::get(req.path);
- if(ml) {
- res.code = 200;
- res.status = "OK";
-
- ml->render(req, res);
- } else {
- res.code = 404;
- res.status = "Not Found";
- }
+ foo_handler(shared_from_this());
}
void print(char c) {