Clio develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
web::HttpSession< HandlerType > Class Template Reference

Represents a HTTP connection established by a client. More...

#include <HttpSession.hpp>

Inheritance diagram for web::HttpSession< HandlerType >:
Collaboration diagram for web::HttpSession< HandlerType >:

Public Member Functions

 HttpSession (tcp::socket &&socket, std::string const &ip, std::shared_ptr< AdminVerificationStrategy > const &adminVerification, 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.
 
boost::beast::tcp_stream & stream ()
 
void run ()
 Starts reading from the stream.
 
void doClose ()
 Closes the underlying socket.
 
void upgrade ()
 Upgrade to WebSocket connection.
 
- Public Member Functions inherited from web::impl::HttpBase< HttpSession, HandlerType >
 HttpBase (std::string const &ip, std::reference_wrapper< util::TagDecoratorFactory const > tagFactory, std::shared_ptr< AdminVerificationStrategy > adminVerification, std::reference_wrapper< dosguard::DOSGuardInterface > dosGuard, std::shared_ptr< HandlerType > handler, boost::beast::flat_buffer buffer)
 
void doRead ()
 
void onRead (boost::beast::error_code ec, std::size_t bytesTransferred)
 
void send (std::string &&msg, http::status status=http::status::ok) override
 Send a response to the client The message length will be added to the DOSGuard, if the limit is reached, a warning will be added to the response.
 
SubscriptionContextPtr makeSubscriptionContext (util::TagDecoratorFactory const &) override
 Get the subscription context for this connection.
 
void onWrite (bool close, boost::beast::error_code ec, std::size_t bytesTransferred)
 
- Public Member Functions inherited from web::ConnectionBase
 ConnectionBase (util::TagDecoratorFactory const &tagFactory, std::string ip)
 Create a new connection base.
 
virtual void send (std::shared_ptr< std::string > msg)
 Send via shared_ptr of string, that enables SubscriptionManager to publish to clients.
 
bool dead ()
 Indicates whether the connection had an error and is considered dead.
 
bool isAdmin () const
 Indicates whether the connection has admin privileges.
 
- Public Member Functions inherited from util::Taggable
 Taggable (Taggable &&)=default
 
Taggableoperator= (Taggable &&)=default
 
BaseTagDecorator const & tag () const
 Getter for tag decorator.
 

Additional Inherited Members

- Public Attributes inherited from web::ConnectionBase
std::string const clientIp
 
bool upgraded = false
 
- Protected Member Functions inherited from web::impl::HttpBase< HttpSession, HandlerType >
void httpFail (boost::beast::error_code ec, char const *what)
 
- Protected Member Functions inherited from util::Taggable
 Taggable (util::TagDecoratorFactory const &tagFactory)
 New Taggable from a specified factory.
 
- Protected Attributes inherited from web::impl::HttpBase< HttpSession, HandlerType >
boost::beast::flat_buffer buffer_
 
http::request< http::string_body > req_
 
std::reference_wrapper< dosguard::DOSGuardInterfacedosGuard_
 
std::shared_ptr< HandlerType > const handler_
 
util::Logger log_
 
util::Logger perfLog_
 
- Protected Attributes inherited from web::ConnectionBase
boost::system::error_code ec_
 
bool isAdmin_ = false
 

Detailed Description

template<SomeServerHandler HandlerType>
class web::HttpSession< HandlerType >

Represents a HTTP connection established by a client.

It will handle the upgrade to websocket, pass the ownership of the socket to the upgrade session. Otherwise, it will pass control to the base class.

Template Parameters
HandlerTypeThe type of the server handler to use

Constructor & Destructor Documentation

◆ HttpSession()

template<SomeServerHandler HandlerType>
web::HttpSession< HandlerType >::HttpSession ( tcp::socket && socket,
std::string const & ip,
std::shared_ptr< AdminVerificationStrategy > const & adminVerification,
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 )
inlineexplicit

Create a new session.

Parameters
socketThe socket. Ownership is transferred to HttpSession
ipClient's IP address
adminVerificationThe admin verification strategy to use
tagFactoryA factory that is used to generate tags to track requests and sessions
dosGuardThe denial of service guard to use
handlerThe server handler to use
bufferBuffer with initial data received from the peer
maxWsSendingQueueSizeThe maximum size of the sending queue for websocket

Member Function Documentation

◆ stream()

template<SomeServerHandler HandlerType>
boost::beast::tcp_stream & web::HttpSession< HandlerType >::stream ( )
inline
Returns
The TCP stream

The documentation for this class was generated from the following file: