22#include "util/Taggable.hpp"
23#include "web/AdminVerificationStrategy.hpp"
24#include "web/PlainWsSession.hpp"
25#include "web/ProxyIpResolver.hpp"
26#include "web/dosguard/DOSGuardInterface.hpp"
27#include "web/impl/HttpBase.hpp"
28#include "web/interface/Concepts.hpp"
29#include "web/interface/ConnectionBase.hpp"
31#include <boost/asio/ip/tcp.hpp>
32#include <boost/beast/core/error.hpp>
33#include <boost/beast/core/flat_buffer.hpp>
34#include <boost/beast/core/tcp_stream.hpp>
44using tcp = boost::asio::ip::tcp;
54template <SomeServerHandler HandlerType>
56 public std::enable_shared_from_this<HttpSession<HandlerType>> {
57 boost::beast::tcp_stream stream_;
58 std::reference_wrapper<util::TagDecoratorFactory const> tagFactory_;
59 std::uint32_t maxWsSendingQueueSize_;
77 std::string
const& ip,
78 std::shared_ptr<AdminVerificationStrategy>
const& adminVerification,
79 std::shared_ptr<ProxyIpResolver> proxyIpResolver,
80 std::reference_wrapper<util::TagDecoratorFactory const> tagFactory,
81 std::reference_wrapper<dosguard::DOSGuardInterface> dosGuard,
82 std::shared_ptr<HandlerType>
const& handler,
83 boost::beast::flat_buffer buffer,
84 std::uint32_t maxWsSendingQueueSize
90 std::move(proxyIpResolver),
95 , stream_(std::move(socket))
96 , tagFactory_(tagFactory)
97 , maxWsSendingQueueSize_(maxWsSendingQueueSize)
104 boost::beast::tcp_stream&
114 boost::asio::dispatch(
115 stream_.get_executor(),
116 boost::beast::bind_front_handler(
126 boost::beast::error_code ec;
127 stream_.socket().shutdown(tcp::socket::shutdown_send, ec);
134 std::make_shared<WsUpgrader<HandlerType>>(
140 std::move(this->buffer_),
141 std::move(this->req_),
143 maxWsSendingQueueSize_
Represents a HTTP connection established by a client.
Definition HttpSession.hpp:56
void doClose()
Closes the underlying socket.
Definition HttpSession.hpp:124
boost::beast::tcp_stream & stream()
Definition HttpSession.hpp:105
void run()
Starts reading from the stream.
Definition HttpSession.hpp:112
void upgrade()
Upgrade to WebSocket connection.
Definition HttpSession.hpp:132
HttpSession(tcp::socket &&socket, std::string const &ip, std::shared_ptr< AdminVerificationStrategy > const &adminVerification, std::shared_ptr< ProxyIpResolver > proxyIpResolver, std::reference_wrapper< util::TagDecoratorFactory const > tagFactory, std::reference_wrapper< dosguard::DOSGuardInterface > dosGuard, std::shared_ptr< HandlerType > const &handler, boost::beast::flat_buffer buffer, std::uint32_t maxWsSendingQueueSize)
Create a new session.
Definition HttpSession.hpp:75
This is the implementation class for http sessions.
Definition HttpBase.hpp:83
This namespace implements the web server and related components.
Definition Types.hpp:43
bool isAdmin() const
Indicates whether the connection has admin privileges.
Definition ConnectionBase.hpp:118