Public Member Functions | List of all members
HttpSession Class Referencefinal

Manages the handling of HTTP messages and WebSocket upgrade requests in an HTTP connection. More...

#include <HttpSession.hpp>

Inherits enable_shared_from_this< HttpSession >.

Public Member Functions

 HttpSession (Impl::HttpSessions &httpSessions_, Impl::ClientSessions &clientSessions_, std::shared_ptr< HttpServerConfiguration > serverConfiguration_, TCP::socket &&socket_)
 Create an HTTP session object with the supplied data. More...
 
void close ()
 Close the session if it is still open. More...
 
HttpServerConfiguration & configuration () const
 Get the shared state of the http server. More...
 
void doRead ()
 
Address remoteIpAddress () const
 Get the requester's IP address for logging. More...
 
template<typename BodyT >
void sendResponse (Response< BodyT > &&response, const std::string &extraLogging="")
 Send the response back to the client. More...
 
template<typename BodyT >
void sendResponse (Response< BodyT > &&response, const BalauLogger &log, const std::string &extraLogging="")
 Send the response back to the client. More...
 

Detailed Description

Manages the handling of HTTP messages and WebSocket upgrade requests in an HTTP connection.

Holds a pointer to the private session information object for the client.

Multiple HTTP sessions may occur within the lifetime of a single client session.

Constructor & Destructor Documentation

◆ HttpSession()

HttpSession ( Impl::HttpSessions &  httpSessions_,
Impl::ClientSessions &  clientSessions_,
std::shared_ptr< HttpServerConfiguration >  serverConfiguration_,
TCP::socket &&  socket_ 
)

Create an HTTP session object with the supplied data.

Parameters
owner_the owning HTTP session manager
clientSessions_the HTTP client session manager
serverConfiguration_the configuration of the HTTP server that created this session
socket_the session socket

Member Function Documentation

◆ close()

void close ( )

Close the session if it is still open.

◆ configuration()

HttpServerConfiguration& configuration ( ) const
inline

Get the shared state of the http server.

◆ doRead()

void doRead ( )
Exceptions
NetworkExceptionif there was an issue reading

◆ remoteIpAddress()

Address remoteIpAddress ( ) const
inline

Get the requester's IP address for logging.

◆ sendResponse() [1/2]

void sendResponse ( Response< BodyT > &&  response,
const std::string &  extraLogging = "" 
)
inline

Send the response back to the client.

Called by handlers.

◆ sendResponse() [2/2]

void sendResponse ( Response< BodyT > &&  response,
const BalauLogger &  log,
const std::string &  extraLogging = "" 
)
inline

Send the response back to the client.

Called by handlers.


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