ゴミ箱
|
Public Member Functions | |
HttpListener ()=delete | |
HttpListener (tcp::acceptor &acceptor, Router &router) | |
void | accept () |
void | send_response () |
void | prepare_response () |
template<typename Error > | |
void | send_error_response (Error &&error, http::status status=http::status::internal_server_error) |
void | read_request () |
void | handle_request () |
HTTP boost::io_service handler.
Object of this class should live as long as boost::io_service::run() is executing. It can be achieved through different means:
First can case can be found in multiple examples. But the second works as charm even in multithreaded environment. So why settle for unnecessary overhead of shared_ptr?
TODO: There is a question whether you'd need a synchronization for pure heap-allocated members.
|
delete |
|
inline |
|
inline |
Handle new incoming connection.
After finishing handling each new connection the function is called once again. The function should be called only after request's handling is finished! As long as it is called there will be jobs to do for boost::io_service and it will loop through them forever.
|
inline |
Handles HTTP Request.
TODO: Next step is to think of API to provide routing.
|
inline |
Finalize response by setting default headers.
|
inline |
Reads Client's request
On failure to read it would make sense to send back some meaningful error response.
|
inline |
Sends response with error to client.
[in] | error | Error type. It is inserted into response using stream operator. |
[in] | status | HTTP Status code. Default is 500. |
|
inline |
Sends response back to client.
Closes socket and accepts another connection.