3#include "data/LedgerCacheInterface.hpp"
4#include "util/Taggable.hpp"
5#include "web/AdminVerificationStrategy.hpp"
6#include "web/PlainWsSession.hpp"
7#include "web/ProxyIpResolver.hpp"
8#include "web/dosguard/DOSGuardInterface.hpp"
9#include "web/impl/HttpBase.hpp"
10#include "web/interface/Concepts.hpp"
11#include "web/interface/ConnectionBase.hpp"
13#include <boost/asio/ip/tcp.hpp>
14#include <boost/beast/core/error.hpp>
15#include <boost/beast/core/flat_buffer.hpp>
16#include <boost/beast/core/tcp_stream.hpp>
26using tcp = boost::asio::ip::tcp;
36template <SomeServerHandler HandlerType>
38 public std::enable_shared_from_this<HttpSession<HandlerType>> {
39 boost::beast::tcp_stream stream_;
40 std::reference_wrapper<util::TagDecoratorFactory const> tagFactory_;
41 std::uint32_t maxWsSendingQueueSize_;
60 std::string
const& ip,
61 std::shared_ptr<AdminVerificationStrategy>
const& adminVerification,
62 std::shared_ptr<ProxyIpResolver> proxyIpResolver,
63 std::reference_wrapper<util::TagDecoratorFactory const> tagFactory,
64 std::reference_wrapper<dosguard::DOSGuardInterface> dosGuard,
65 std::shared_ptr<HandlerType>
const& handler,
66 std::reference_wrapper<data::LedgerCacheInterface const> cache,
67 boost::beast::flat_buffer buffer,
68 std::uint32_t maxWsSendingQueueSize
74 std::move(proxyIpResolver),
80 , stream_(std::move(socket))
81 , tagFactory_(tagFactory)
82 , maxWsSendingQueueSize_(maxWsSendingQueueSize)
89 boost::beast::tcp_stream&
99 boost::asio::dispatch(
100 stream_.get_executor(),
101 boost::beast::bind_front_handler(
102 &impl::HttpBase<HttpSession, HandlerType>::doRead, this->shared_from_this()
111 boost::beast::error_code ec;
112 stream_.socket().shutdown(tcp::socket::shutdown_send, ec);
119 std::make_shared<WsUpgrader<HandlerType>>(
125 std::move(this->buffer_),
126 std::move(this->req_),
128 maxWsSendingQueueSize_
Represents a HTTP connection established by a client.
Definition HttpSession.hpp:38
void doClose()
Closes the underlying socket.
Definition HttpSession.hpp:109
boost::beast::tcp_stream & stream()
Definition HttpSession.hpp:90
void run()
Starts reading from the stream.
Definition HttpSession.hpp:97
void upgrade()
Upgrade to WebSocket connection.
Definition HttpSession.hpp:117
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, std::reference_wrapper< data::LedgerCacheInterface const > cache, boost::beast::flat_buffer buffer, std::uint32_t maxWsSendingQueueSize)
Create a new session.
Definition HttpSession.hpp:58
This is the implementation class for http sessions.
Definition HttpBase.hpp:81
This namespace implements the web server and related components.
Definition Types.hpp:24
bool isAdmin() const
Indicates whether the connection has admin privileges.
Definition ConnectionBase.hpp:99