rippled
Public Member Functions | Public Attributes | Protected Types | Protected Member Functions | Protected Attributes | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
ripple::SSLHTTPPeer< Handler > Class Template Reference
Inheritance diagram for ripple::SSLHTTPPeer< Handler >:
Inheritance graph
[legend]
Collaboration diagram for ripple::SSLHTTPPeer< Handler >:
Collaboration graph
[legend]

Public Member Functions

template<class ConstBufferSequence >
 SSLHTTPPeer (Port const &port, Handler &handler, boost::asio::io_context &ioc, beast::Journal journal, endpoint_type remote_address, ConstBufferSequence const &buffers, middle_type &&stream)
 
void run ()
 
std::shared_ptr< WSSessionwebsocketUpgrade () override
 Convert the connection to WebSocket. More...
 
Sessionsession ()
 
void close () override
 
io_listios ()
 Return the io_list associated with the work. More...
 
shared_from_this (T... args)
 
weak_from_this (T... args)
 
void write (std::string const &s)
 Send a copy of data asynchronously. More...
 
template<typename BufferSequence >
void write (BufferSequence const &buffers)
 
void write (std::string const &s)
 Send a copy of data asynchronously. More...
 
template<typename BufferSequence >
void write (BufferSequence const &buffers)
 
void write (std::string const &s)
 Send a copy of data asynchronously. More...
 
template<typename BufferSequence >
void write (BufferSequence const &buffers)
 
void write (std::string const &s)
 Send a copy of data asynchronously. More...
 
template<typename BufferSequence >
void write (BufferSequence const &buffers)
 
void write (std::string const &s)
 Send a copy of data asynchronously. More...
 
template<typename BufferSequence >
void write (BufferSequence const &buffers)
 

Public Attributes

void * tag = nullptr
 A user-definable pointer. More...
 

Protected Types

enum  
 
using clock_type = std::chrono::system_clock
 

Protected Member Functions

void close (bool graceful) override
 Close the session. More...
 
SSLHTTPPeer< Handler > & impl ()
 
void fail (error_code ec, char const *what)
 
void start_timer ()
 
void cancel_timer ()
 
void on_timer ()
 
void do_read (yield_context do_yield)
 
void on_write (error_code const &ec, std::size_t bytes_transferred)
 
void do_writer (std::shared_ptr< Writer > const &writer, bool keep_alive, yield_context do_yield)
 
beast::Journal journal () override
 Returns the Journal to use for logging. More...
 
Port const & port () override
 Returns the Port settings for this connection. More...
 
beast::IP::Endpoint remoteAddress () override
 Returns the remote address of the connection. More...
 
http_request_typerequest () override
 Returns the current HTTP request. More...
 
void write (void const *buffer, std::size_t bytes) override
 
void write (std::shared_ptr< Writer > const &writer, bool keep_alive) override
 
std::shared_ptr< Sessiondetach () override
 Detach the session. More...
 
void complete () override
 Indicate that the response is complete. More...
 

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 remote_address_
 
const beast::Journal journal_
 
std::string id_
 
std::size_t nid_
 
boost::asio::streambuf read_buf_
 
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 request_count_
 
std::size_t bytes_in_
 
std::size_t bytes_out_
 

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 do_handshake (yield_context do_yield)
 
void do_request () override
 
void do_close () override
 
void on_shutdown (error_code ec)
 
template<class = void>
void destroy ()
 

Private Attributes

std::unique_ptr< stream_typestream_ptr_
 
stream_typestream_
 
socket_typesocket_
 
io_listios_ = nullptr
 

Friends

class BaseHTTPPeer< Handler, SSLHTTPPeer >
 

Detailed Description

template<class Handler>
class ripple::SSLHTTPPeer< Handler >

Definition at line 35 of file SSLHTTPPeer.h.

Member Typedef Documentation

◆ socket_type

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

Definition at line 40 of file SSLHTTPPeer.h.

◆ middle_type

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

Definition at line 41 of file SSLHTTPPeer.h.

◆ stream_type

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

Definition at line 42 of file SSLHTTPPeer.h.

◆ endpoint_type

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

Definition at line 43 of file SSLHTTPPeer.h.

◆ yield_context

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

Definition at line 44 of file SSLHTTPPeer.h.

◆ error_code

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

Definition at line 45 of file SSLHTTPPeer.h.

◆ clock_type

using ripple::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::clock_type = std::chrono::system_clock
protectedinherited

Definition at line 52 of file BaseHTTPPeer.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
protectedinherited

Definition at line 57 of file BaseHTTPPeer.h.

Constructor & Destructor Documentation

◆ SSLHTTPPeer()

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

Definition at line 86 of file SSLHTTPPeer.h.

Member Function Documentation

◆ run()

template<class Handler >
void ripple::SSLHTTPPeer< Handler >::run

Definition at line 112 of file SSLHTTPPeer.h.

◆ websocketUpgrade()

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

Convert the connection to WebSocket.

Implements ripple::Session.

Definition at line 133 of file SSLHTTPPeer.h.

◆ do_handshake()

template<class Handler >
void ripple::SSLHTTPPeer< Handler >::do_handshake ( yield_context  do_yield)
private

Definition at line 147 of file SSLHTTPPeer.h.

◆ do_request()

template<class Handler >
void ripple::SSLHTTPPeer< Handler >::do_request
overrideprivatevirtual

◆ do_close()

template<class Handler >
void ripple::SSLHTTPPeer< Handler >::do_close
overrideprivatevirtual

◆ on_shutdown()

template<class Handler >
void ripple::SSLHTTPPeer< Handler >::on_shutdown ( error_code  ec)
private

Definition at line 209 of file SSLHTTPPeer.h.

◆ session()

Session& ripple::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::session
inherited

Definition at line 117 of file BaseHTTPPeer.h.

◆ close() [1/2]

void ripple::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::close
overridevirtualinherited

Implements ripple::io_list::work.

Definition at line 241 of file BaseHTTPPeer.h.

◆ close() [2/2]

void ripple::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::close ( bool  graceful)
overrideprotectedvirtualinherited

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.

Implements ripple::Session.

Definition at line 504 of file BaseHTTPPeer.h.

◆ impl()

SSLHTTPPeer< Handler > & ripple::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::impl
protectedinherited

Definition at line 127 of file BaseHTTPPeer.h.

◆ fail()

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

Definition at line 256 of file BaseHTTPPeer.h.

◆ start_timer()

void ripple::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::start_timer
protectedinherited

Definition at line 269 of file BaseHTTPPeer.h.

◆ cancel_timer()

void ripple::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::cancel_timer
protectedinherited

Definition at line 280 of file BaseHTTPPeer.h.

◆ on_timer()

void ripple::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::on_timer
protectedinherited

Definition at line 288 of file BaseHTTPPeer.h.

◆ do_read()

void ripple::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::do_read ( yield_context  do_yield)
protectedinherited

Definition at line 299 of file BaseHTTPPeer.h.

◆ on_write()

void ripple::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::on_write ( error_code const &  ec,
std::size_t  bytes_transferred 
)
protectedinherited

Definition at line 320 of file BaseHTTPPeer.h.

◆ do_writer()

void ripple::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::do_writer ( std::shared_ptr< Writer > const &  writer,
bool  keep_alive,
yield_context  do_yield 
)
protectedinherited

Definition at line 368 of file BaseHTTPPeer.h.

◆ journal()

beast::Journal ripple::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::journal
overrideprotectedvirtualinherited

Returns the Journal to use for logging.

Implements ripple::Session.

Definition at line 165 of file BaseHTTPPeer.h.

◆ port()

Port const& ripple::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::port
overrideprotectedvirtualinherited

Returns the Port settings for this connection.

Implements ripple::Session.

Definition at line 171 of file BaseHTTPPeer.h.

◆ remoteAddress()

beast::IP::Endpoint ripple::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::remoteAddress
overrideprotectedvirtualinherited

Returns the remote address of the connection.

Implements ripple::Session.

Definition at line 177 of file BaseHTTPPeer.h.

◆ request()

http_request_type& ripple::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::request
overrideprotectedvirtualinherited

Returns the current HTTP request.

Implements ripple::Session.

Definition at line 183 of file BaseHTTPPeer.h.

◆ write() [1/4]

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

Implements ripple::Session.

Definition at line 421 of file BaseHTTPPeer.h.

◆ write() [2/4]

void ripple::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::write ( std::shared_ptr< Writer > const &  writer,
bool  keep_alive 
)
overrideprotectedvirtualinherited

Implements ripple::Session.

Definition at line 446 of file BaseHTTPPeer.h.

◆ write() [3/4]

void ripple::Session::write ( std::string const &  s)
inherited

Send a copy of data asynchronously.

Definition at line 74 of file Session.h.

◆ write() [4/4]

template<typename BufferSequence >
void ripple::Session::write ( BufferSequence const &  buffers)
inherited

Definition at line 82 of file Session.h.

◆ detach()

std::shared_ptr< Session > ripple::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_service::run made by the server will not return until all detached sessions are closed.

Implements ripple::Session.

Definition at line 464 of file BaseHTTPPeer.h.

◆ complete()

void ripple::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 ripple::Session.

Definition at line 473 of file BaseHTTPPeer.h.

◆ destroy()

template<class = void>
void ripple::io_list::work::destroy ( )
privateinherited

Definition at line 182 of file io_list.h.

◆ ios()

io_list& ripple::io_list::work::ios ( )
inherited

Return the io_list associated with the work.

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

Definition at line 60 of file io_list.h.

Friends And Related Function Documentation

◆ BaseHTTPPeer< Handler, SSLHTTPPeer >

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

Definition at line 39 of file SSLHTTPPeer.h.

Member Data Documentation

◆ stream_ptr_

template<class Handler >
std::unique_ptr<stream_type> ripple::SSLHTTPPeer< Handler >::stream_ptr_
private

Definition at line 47 of file SSLHTTPPeer.h.

◆ stream_

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

Definition at line 48 of file SSLHTTPPeer.h.

◆ socket_

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

Definition at line 49 of file SSLHTTPPeer.h.

◆ port_

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

Definition at line 79 of file BaseHTTPPeer.h.

◆ handler_

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

Definition at line 80 of file BaseHTTPPeer.h.

◆ work_

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

Definition at line 81 of file BaseHTTPPeer.h.

◆ strand_

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

Definition at line 82 of file BaseHTTPPeer.h.

◆ remote_address_

endpoint_type ripple::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::remote_address_
protectedinherited

Definition at line 83 of file BaseHTTPPeer.h.

◆ journal_

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

Definition at line 84 of file BaseHTTPPeer.h.

◆ id_

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

Definition at line 86 of file BaseHTTPPeer.h.

◆ nid_

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

Definition at line 87 of file BaseHTTPPeer.h.

◆ read_buf_

boost::asio::streambuf ripple::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::read_buf_
protectedinherited

Definition at line 89 of file BaseHTTPPeer.h.

◆ message_

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

Definition at line 90 of file BaseHTTPPeer.h.

◆ wq_

std::vector<buffer> ripple::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::wq_
protectedinherited

Definition at line 91 of file BaseHTTPPeer.h.

◆ wq2_

std::vector<buffer> ripple::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::wq2_
protectedinherited

Definition at line 92 of file BaseHTTPPeer.h.

◆ mutex_

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

Definition at line 93 of file BaseHTTPPeer.h.

◆ graceful_

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

Definition at line 94 of file BaseHTTPPeer.h.

◆ complete_

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

Definition at line 95 of file BaseHTTPPeer.h.

◆ ec_

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

Definition at line 96 of file BaseHTTPPeer.h.

◆ request_count_

int ripple::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::request_count_
protectedinherited

Definition at line 98 of file BaseHTTPPeer.h.

◆ bytes_in_

std::size_t ripple::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::bytes_in_
protectedinherited

Definition at line 99 of file BaseHTTPPeer.h.

◆ bytes_out_

std::size_t ripple::BaseHTTPPeer< Handler, SSLHTTPPeer< Handler > >::bytes_out_
protectedinherited

Definition at line 100 of file BaseHTTPPeer.h.

◆ ios_

io_list* ripple::io_list::work::ios_ = nullptr
privateinherited

Definition at line 45 of file io_list.h.

◆ tag

void* ripple::Session::tag = nullptr
inherited

A user-definable pointer.

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

Definition at line 53 of file Session.h.