1 #ifndef CPP_WEB_SERVER_HTTP_CONNECTION_HPP 2 #define CPP_WEB_SERVER_HTTP_CONNECTION_HPP 8 #include <boost/asio.hpp> 9 #include <boost/enable_shared_from_this.hpp> 10 #include <boost/noncopyable.hpp> 11 #include <boost/shared_ptr.hpp> 12 #include <boost/thread/mutex.hpp> 34 class HttpConnection :
public boost::enable_shared_from_this<HttpConnection>,
35 private boost::noncopyable
38 typedef boost::function<void(const char* begin, const char* end)>
45 boost::asio::ip::tcp::socket&
socket();
62 void write(
const std::string&);
64 void write(
const boost::asio::const_buffer& buffer, ResourcePtr resource);
66 void write(
const std::vector<boost::asio::const_buffer>& buffer,
67 ResourcePtr resource);
70 void handle_read(
const char* begin,
const char* end);
72 const boost::system::error_code& e,
73 std::size_t bytes_transferred);
79 std::vector<ResourcePtr> resources);
void handle_read_raw(ReadHandler callback, const boost::system::error_code &e, std::size_t bytes_transferred)
boost::array< char, 8192 > buffer_
boost::mutex write_mutex_
boost::asio::ip::tcp::socket socket_
void write(const std::string &)
HttpServerRequestHandler request_handler_
HttpConnection(boost::asio::io_service &io_service, HttpServerRequestHandler request_handler)
void async_read(ReadHandler callback)
std::vector< boost::asio::const_buffer > pending_write_buffers_
boost::shared_ptr< HttpConnection > HttpConnectionPtr
boost::system::error_code last_error_
boost::function< void(const char *begin, const char *end)> ReadHandler
boost::asio::io_service::strand strand_
void handle_write(const boost::system::error_code &e, std::vector< ResourcePtr > resources)
std::vector< ResourcePtr > pending_write_resources_
void write_and_clear(std::vector< unsigned char > &data)
HttpRequestParser request_parser_
boost::function< bool(const HttpRequest &, boost::shared_ptr< HttpConnection >, const char *begin, const char *end)> HttpServerRequestHandler
boost::weak_ptr< HttpConnection > HttpConnectionWeakPtr
void handle_read(const char *begin, const char *end)
ReadHandler read_handler_
boost::asio::ip::tcp::socket & socket()
boost::shared_ptr< const void > ResourcePtr