From 9a5138ce981697e243fa0de2bc2668eaa80efb76 Mon Sep 17 00:00:00 2001 From: Vegard Storheil Eriksen Date: Fri, 31 Dec 2010 00:09:06 +0100 Subject: Hacked stuff to work again. --- http_connection.cpp | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) (limited to 'http_connection.cpp') 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) { -- cgit v1.2.3