xrpld
Loading...
Searching...
No Matches
xrpl::SSLHTTPPeer< Handler > Class Template Referenceabstract

#include <SSLHTTPPeer.h>

Inheritance diagram for xrpl::SSLHTTPPeer< Handler >:
Collaboration diagram for xrpl::SSLHTTPPeer< Handler >:

Public Member Functions

template<class ConstBufferSequence>
 SSLHTTPPeer (Port const &port, Handler &handler, boost::asio::io_context &ioc, beast::Journal journal, endpoint_type remoteAddress, ConstBufferSequence const &buffers, middle_type &&stream)
void run ()
std::shared_ptr< WSSessionwebsocketUpgrade () override
 Convert the connection to WebSocket.
Sessionsession ()
void close () override
virtual void close (bool graceful)=0
 Close the session.
IOListios ()
 Return the IOList associated with the work.
shared_from_this (T... args)
weak_from_this (T... args)
void write (std::string_view s)
 Send a copy of data asynchronously.
void write (BufferSequence const &buffers)
virtual void write (std::shared_ptr< Writer > const &writer, bool keepAlive)=0

Public Attributes

void * tag
 A user-definable pointer.

Protected Types

using clock_type

Protected Member Functions

SSLHTTPPeer< Handler > & impl ()
void fail (error_code ec, char const *what)
void startTimer ()
void cancelTimer ()
void onTimer ()
void doRead (yield_context doYield)
void onWrite (error_code const &ec, std::size_t bytesTransferred)
void doWriter (std::shared_ptr< Writer > const &writer, bool keepAlive, yield_context doYield)
beast::Journal journal () override
 Returns the Journal to use for logging.
Port const & port () override
 Returns the Port settings for this connection.
beast::IP::Endpoint remoteAddress () override
 Returns the remote address of the connection.
http_request_typerequest () override
 Returns the current HTTP request.
void write (void const *buffer, std::size_t bytes) override
std::shared_ptr< Sessiondetach () override
 Detach the session.
void complete () override
 Indicate that the response is complete.

Protected Attributes

Port const & port_
Handler & handler_
boost::asio::executor_work_guard< boost::asio::executor > work_
boost::asio::strand< boost::asio::executor > strand_
endpoint_type remoteAddress_
beast::Journal const journal_
std::string id_
std::size_t nid_
boost::asio::streambuf readBuf_
http_request_type message_
std::vector< Buffer > wq_
std::vector< Buffer > wq2_
std::mutex mutex_
bool graceful_
bool complete_
boost::system::error_code ec_
int requestCount_
std::size_t bytesIn_
std::size_t bytesOut_

Static Protected Attributes

static constexpr auto kBufferSize
static constexpr auto kTimeoutSeconds
static constexpr auto kTimeoutSecondsLocal

Private Types

using socket_type = boost::asio::ip::tcp::socket
using middle_type = boost::beast::tcp_stream
using stream_type = boost::beast::ssl_stream<middle_type>
using endpoint_type = boost::asio::ip::tcp::endpoint
using yield_context = boost::asio::yield_context
using error_code = boost::system::error_code

Private Member Functions

void doHandshake (yield_context doYield)
void doRequest () override
void doClose () override
void onShutdown (error_code ec)
void destroy ()

Private Attributes

std::unique_ptr< stream_typestreamPtr_
stream_typestream_
socket_typesocket_
IOListios_

Friends

class BaseHTTPPeer< Handler, SSLHTTPPeer >

Detailed Description

template<class Handler>
class xrpl::SSLHTTPPeer< Handler >

Definition at line 17 of file SSLHTTPPeer.h.

Member Typedef Documentation

◆ socket_type

template<class Handler>
using xrpl::SSLHTTPPeer< Handler >::socket_type = boost::asio::ip::tcp::socket
private

Definition at line 22 of file SSLHTTPPeer.h.

◆ middle_type

template<class Handler>
using xrpl::SSLHTTPPeer< Handler >::middle_type = boost::beast::tcp_stream
private

Definition at line 23 of file SSLHTTPPeer.h.

◆ stream_type

template<class Handler>
using xrpl::SSLHTTPPeer< Handler >::stream_type = boost::beast::ssl_stream<middle_type>
private

Definition at line 24 of file SSLHTTPPeer.h.

◆ endpoint_type

template<class Handler>
using xrpl::SSLHTTPPeer< Handler >::endpoint_type = boost::asio::ip::tcp::endpoint
private

Definition at line 25 of file SSLHTTPPeer.h.

◆ yield_context

template<class Handler>
using xrpl::SSLHTTPPeer< Handler >::yield_context = boost::asio::yield_context
private

Definition at line 26 of file SSLHTTPPeer.h.

◆ error_code

template<class Handler>
using xrpl::SSLHTTPPeer< Handler >::error_code = boost::system::error_code
private

Definition at line 27 of file SSLHTTPPeer.h.

◆ clock_type

using xrpl::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::clock_type
protectedinherited

Definition at line 36 of file BaseHTTPPeer.h.

Constructor & Destructor Documentation

◆ SSLHTTPPeer()

template<class Handler>
template<class ConstBufferSequence>
xrpl::SSLHTTPPeer< Handler >::SSLHTTPPeer ( Port const & port,
Handler & handler,
boost::asio::io_context & ioc,
beast::Journal journal,
endpoint_type remoteAddress,
ConstBufferSequence const & buffers,
middle_type && stream )

Definition at line 68 of file SSLHTTPPeer.h.

Member Function Documentation

◆ run()

template<class Handler>
void xrpl::SSLHTTPPeer< Handler >::run ( )

Definition at line 92 of file SSLHTTPPeer.h.

◆ websocketUpgrade()

template<class Handler>
std::shared_ptr< WSSession > xrpl::SSLHTTPPeer< Handler >::websocketUpgrade ( )
overridevirtual

Convert the connection to WebSocket.

Implements xrpl::Session.

Definition at line 108 of file SSLHTTPPeer.h.

◆ doHandshake()

template<class Handler>
void xrpl::SSLHTTPPeer< Handler >::doHandshake ( yield_context doYield)
private

Definition at line 122 of file SSLHTTPPeer.h.

◆ doRequest()

template<class Handler>
void xrpl::SSLHTTPPeer< Handler >::doRequest ( )
overrideprivatevirtual

◆ doClose()

template<class Handler>
void xrpl::SSLHTTPPeer< Handler >::doClose ( )
overrideprivatevirtual

◆ onShutdown()

template<class Handler>
void xrpl::SSLHTTPPeer< Handler >::onShutdown ( error_code ec)
private

Definition at line 174 of file SSLHTTPPeer.h.

◆ session()

Session & xrpl::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::session ( )
inherited

Definition at line 95 of file BaseHTTPPeer.h.

◆ close() [1/2]

void xrpl::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::close ( )
overridevirtualinherited

Implements xrpl::IOList::Work.

Definition at line 101 of file BaseHTTPPeer.h.

◆ close() [2/2]

virtual void xrpl::Session::close ( bool graceful)
pure virtualinherited

Close the session.

This will be performed asynchronously. The session will be closed gracefully after all pending writes have completed.

Parameters
gracefultrue to wait until all data has finished sending.

Implemented in xrpl::BaseHTTPPeer< Handler, Impl >.

◆ impl()

SSLHTTPPeer< Handler > & xrpl::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::impl ( )
protectedinherited

Definition at line 105 of file BaseHTTPPeer.h.

◆ fail()

void xrpl::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::fail ( error_code ec,
char const * what )
protectedinherited

Definition at line 111 of file BaseHTTPPeer.h.

◆ startTimer()

void xrpl::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::startTimer ( )
protectedinherited

Definition at line 114 of file BaseHTTPPeer.h.

◆ cancelTimer()

void xrpl::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::cancelTimer ( )
protectedinherited

Definition at line 117 of file BaseHTTPPeer.h.

◆ onTimer()

void xrpl::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::onTimer ( )
protectedinherited

Definition at line 120 of file BaseHTTPPeer.h.

◆ doRead()

void xrpl::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::doRead ( yield_context doYield)
protectedinherited

Definition at line 123 of file BaseHTTPPeer.h.

◆ onWrite()

void xrpl::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::onWrite ( error_code const & ec,
std::size_t bytesTransferred )
protectedinherited

Definition at line 126 of file BaseHTTPPeer.h.

◆ doWriter()

void xrpl::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::doWriter ( std::shared_ptr< Writer > const & writer,
bool keepAlive,
yield_context doYield )
protectedinherited

Definition at line 129 of file BaseHTTPPeer.h.

◆ journal()

beast::Journal xrpl::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::journal ( )
overrideprotectedvirtualinherited

Returns the Journal to use for logging.

Implements xrpl::Session.

Definition at line 140 of file BaseHTTPPeer.h.

◆ port()

Port const & xrpl::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::port ( )
overrideprotectedvirtualinherited

Returns the Port settings for this connection.

Implements xrpl::Session.

Definition at line 146 of file BaseHTTPPeer.h.

◆ remoteAddress()

beast::IP::Endpoint xrpl::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::remoteAddress ( )
overrideprotectedvirtualinherited

Returns the remote address of the connection.

Implements xrpl::Session.

Definition at line 152 of file BaseHTTPPeer.h.

◆ request()

http_request_type & xrpl::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::request ( )
overrideprotectedvirtualinherited

Returns the current HTTP request.

Implements xrpl::Session.

Definition at line 158 of file BaseHTTPPeer.h.

◆ write() [1/4]

void xrpl::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::write ( void const * buffer,
std::size_t bytes )
overrideprotectedvirtualinherited

Implements xrpl::Session.

Definition at line 164 of file BaseHTTPPeer.h.

◆ write() [2/4]

Send a copy of data asynchronously.

Definition at line 57 of file Session.h.

◆ write() [3/4]

void xrpl::Session::write ( BufferSequence const & buffers)
inherited

Definition at line 65 of file Session.h.

◆ write() [4/4]

virtual void xrpl::Session::write ( std::shared_ptr< Writer > const & writer,
bool keepAlive )
pure virtualinherited

◆ detach()

std::shared_ptr< Session > xrpl::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::detach ( )
overrideprotectedvirtualinherited

Detach the session.

This holds the session open so that the response can be sent asynchronously. Calls to io_context::run made by the server will not return until all detached sessions are closed.

Implements xrpl::Session.

Definition at line 170 of file BaseHTTPPeer.h.

◆ complete()

void xrpl::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::complete ( )
overrideprotectedvirtualinherited

Indicate that the response is complete.

The handler should call this when it has completed writing the response. If Keep-Alive is indicated on the connection, this will trigger a read for the next request; else, the connection will be closed when all remaining data has been sent.

Implements xrpl::Session.

Definition at line 173 of file BaseHTTPPeer.h.

◆ destroy()

void xrpl::IOList::Work::destroy ( )
privateinherited

Definition at line 22 of file io_list.h.

◆ ios()

Return the IOList associated with the work.

Requirements: The call to IOList::emplace to create the work has already returned.

Definition at line 40 of file io_list.h.

◆ BaseHTTPPeer< Handler, SSLHTTPPeer >

template<class Handler>
friend class BaseHTTPPeer< Handler, SSLHTTPPeer >
friend

Definition at line 174 of file SSLHTTPPeer.h.

Member Data Documentation

◆ streamPtr_

template<class Handler>
std::unique_ptr<stream_type> xrpl::SSLHTTPPeer< Handler >::streamPtr_
private

Definition at line 29 of file SSLHTTPPeer.h.

◆ stream_

template<class Handler>
stream_type& xrpl::SSLHTTPPeer< Handler >::stream_
private

Definition at line 30 of file SSLHTTPPeer.h.

◆ socket_

template<class Handler>
socket_type& xrpl::SSLHTTPPeer< Handler >::socket_
private

Definition at line 31 of file SSLHTTPPeer.h.

◆ kBufferSize

auto xrpl::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::kBufferSize
staticconstexprprotectedinherited

Definition at line 41 of file BaseHTTPPeer.h.

◆ kTimeoutSeconds

auto xrpl::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::kTimeoutSeconds
staticconstexprprotectedinherited

Definition at line 42 of file BaseHTTPPeer.h.

◆ kTimeoutSecondsLocal

auto xrpl::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::kTimeoutSecondsLocal
staticconstexprprotectedinherited

Definition at line 43 of file BaseHTTPPeer.h.

◆ port_

Port const& xrpl::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::port_
protectedinherited

Definition at line 57 of file BaseHTTPPeer.h.

◆ handler_

Handler& xrpl::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::handler_
protectedinherited

Definition at line 58 of file BaseHTTPPeer.h.

◆ work_

boost::asio::executor_work_guard<boost::asio::executor> xrpl::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::work_
protectedinherited

Definition at line 59 of file BaseHTTPPeer.h.

◆ strand_

boost::asio::strand<boost::asio::executor> xrpl::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::strand_
protectedinherited

Definition at line 60 of file BaseHTTPPeer.h.

◆ remoteAddress_

endpoint_type xrpl::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::remoteAddress_
protectedinherited

Definition at line 61 of file BaseHTTPPeer.h.

◆ journal_

beast::Journal const xrpl::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::journal_
protectedinherited

Definition at line 62 of file BaseHTTPPeer.h.

◆ id_

std::string xrpl::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::id_
protectedinherited

Definition at line 64 of file BaseHTTPPeer.h.

◆ nid_

std::size_t xrpl::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::nid_
protectedinherited

Definition at line 65 of file BaseHTTPPeer.h.

◆ readBuf_

boost::asio::streambuf xrpl::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::readBuf_
protectedinherited

Definition at line 67 of file BaseHTTPPeer.h.

◆ message_

http_request_type xrpl::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::message_
protectedinherited

Definition at line 68 of file BaseHTTPPeer.h.

◆ wq_

std::vector<Buffer> xrpl::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::wq_
protectedinherited

Definition at line 69 of file BaseHTTPPeer.h.

◆ wq2_

std::vector<Buffer> xrpl::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::wq2_
protectedinherited

Definition at line 70 of file BaseHTTPPeer.h.

◆ mutex_

std::mutex xrpl::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::mutex_
protectedinherited

Definition at line 71 of file BaseHTTPPeer.h.

◆ graceful_

bool xrpl::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::graceful_
protectedinherited

Definition at line 72 of file BaseHTTPPeer.h.

◆ complete_

bool xrpl::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::complete_
protectedinherited

Definition at line 73 of file BaseHTTPPeer.h.

◆ ec_

boost::system::error_code xrpl::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::ec_
protectedinherited

Definition at line 74 of file BaseHTTPPeer.h.

◆ requestCount_

int xrpl::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::requestCount_
protectedinherited

Definition at line 76 of file BaseHTTPPeer.h.

◆ bytesIn_

std::size_t xrpl::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::bytesIn_
protectedinherited

Definition at line 77 of file BaseHTTPPeer.h.

◆ bytesOut_

std::size_t xrpl::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::bytesOut_
protectedinherited

Definition at line 78 of file BaseHTTPPeer.h.

◆ ios_

IOList* xrpl::IOList::Work::ios_
privateinherited

Definition at line 25 of file io_list.h.

◆ tag

void* xrpl::Session::tag
inherited

A user-definable pointer.

The initial value is always zero. Changes to the value are persisted between calls.

Definition at line 36 of file Session.h.