Class HttpConnection
Defined in File http_connection.hpp
Inheritance Relationships
Base Types
public boost::enable_shared_from_this< HttpConnection >
private boost::noncopyable
Class Documentation
-
class async_web_server_cpp::HttpConnection : public boost::enable_shared_from_this<HttpConnection>, private boost::noncopyable
Represents a connection to a client The connection to the client is maintained as long as there is a shared pointer to the connection object. If supplying the response is simple then it can be done in the request handler callback from the server. However, if the response will take time to generate or must be supplied over a long period of time then a shared_ptr to the connection can be held and used later. While reading and writing from multiple threads is supported, care should be taken to ensure that proper external synchronization is done as needed. For example, while write can be called from two threads, if two calls to write need to be unseperated then calls to write should be locked to prevent interleaving of different write calls.
Public Types
-
typedef boost::function<void(const char *begin, const char *end)> ReadHandler
-
typedef std::shared_ptr<const void> ResourcePtr
Public Functions
-
explicit HttpConnection(boost::asio::io_service &io_service, HttpServerRequestHandler request_handler)
-
boost::asio::ip::tcp::socket &socket()
-
void start()
Start async operation to read request (normally called by server)
-
void async_read(ReadHandler callback)
Perform an async read
-
void write_and_clear(std::vector<unsigned char> &data)
Write the given bytes to the socket and clear the vector
-
void write(const std::string&)
-
void write(const boost::asio::const_buffer &buffer, ResourcePtr resource)
-
void write(const std::vector<boost::asio::const_buffer> &buffer, ResourcePtr resource)
-
typedef boost::function<void(const char *begin, const char *end)> ReadHandler