#ifndef HTTP_CONNECTION_H #define HTTP_CONNECTION_H #include #include #include #include #include using boost::asio::ip::tcp; #include namespace HTTP { class Connection : public boost::enable_shared_from_this { friend class Server; public: typedef boost::shared_ptr p; typedef boost::function Handler; void read_request(Handler callback); //! Request method. std::string method; //! Request path. std::vector path; //! Request arguments. std::map args; //! Request version. std::string version; //! Request headers. std::map headers; tcp::socket socket; private: Connection(boost::asio::io_service& io_service); void handle_write(const boost::system::error_code& error, size_t bytes_transferred); void handle_read(const boost::system::error_code& error, size_t bytes_transferred, Handler callback); boost::asio::streambuf buf; //! Parse request headers. bool parse_request(boost::asio::streambuf& buf); }; typedef Connection::Handler Handler; }; #endif