8 #include <boost/system/error_code.hpp> 13 : strand_(boost::asio::make_strand(context)),
23 boost::system::error_code ec;
24 stream_.socket().shutdown(Socket::shutdown_both, ec);
25 boost::ignore_unused(ec);
33 parser_ = std::make_unique<Parser>();
37 boost::beast::http::async_read(
46 auto m = std::make_shared<Response>(std::forward<Response>(message));
51 boost::beast::http::async_write(
54 boost::beast::bind_front_handler(
64 if (HttpError::end_of_stream != ec) {
75 boost::system::error_code ec,
93 std::string_view message) {
94 logger_->error(
"error occured: {}, code: {}, message: {}",
SessionImpl(Context &context, Configuration config)
constructor
void processRequest(Request request, std::shared_ptr< Session > session)
process request message
boost::beast::flat_buffer buffer_
read buffer
void reportError(boost::system::error_code ec, std::string_view message)
reports error code and message
void asyncRead()
asynchronously read http message
void start() override
starts session
boost::asio::strand< boost::asio::io_context::executor_type > strand_
Strand to ensure the connection's handlers are not called concurrently.
boost::beast::tcp_stream stream_
stream
boost::asio::io_context Context
void respond(Response response) override
sends response wrapped by http message
boost::beast::http::response< Body > Response
Duration operation_timeout
void asyncWrite(Response message)
sends http message
std::unique_ptr< Parser > parser_
request parser type
std::shared_ptr< void > res_
boost::beast::http::request< Body > Request
void onWrite(bool close, boost::system::error_code ec, std::size_t)
write completion callback
void onRead(boost::system::error_code ec, std::size_t size)
read completion callback
Configuration config_
session configuration
Logger createLogger(const std::string &tag)
void handleRequest(Request &&request)
process http request, compose and execute response