CppServer  1.0.4.0
C++ Server Library
Public Member Functions | Protected Member Functions | List of all members
CppServer::HTTP::HTTPSClientEx Class Reference

HTTPS extended client. More...

#include <https_client.h>

Inheritance diagram for CppServer::HTTP::HTTPSClientEx:
CppServer::HTTP::HTTPSClient CppServer::Asio::SSLClient

Public Member Functions

std::shared_ptr< Asio::TCPResolver > & resolver () noexcept
 Get the TCP resolver. More...
 
const std::shared_ptr< Asio::TCPResolver > & resolver () const noexcept
 
std::shared_ptr< Asio::Timer > & timeout () noexcept
 Get the timeout check timer. More...
 
const std::shared_ptr< Asio::Timer > & timeout () const noexcept
 
std::future< HTTPResponseSendRequest (const CppCommon::Timespan &timeout=CppCommon::Timespan::minutes(1))
 Send HTTP request. More...
 
std::future< HTTPResponseSendRequest (const HTTPRequest &request, const CppCommon::Timespan &timeout=CppCommon::Timespan::minutes(1))
 HTTP request. More...
 
std::future< HTTPResponseSendHeadRequest (std::string_view url, const CppCommon::Timespan &timeout=CppCommon::Timespan::minutes(1))
 Send HEAD request. More...
 
std::future< HTTPResponseSendGetRequest (std::string_view url, const CppCommon::Timespan &timeout=CppCommon::Timespan::minutes(1))
 Send GET request. More...
 
std::future< HTTPResponseSendPostRequest (std::string_view url, std::string_view content, const CppCommon::Timespan &timeout=CppCommon::Timespan::minutes(1))
 Send POST request. More...
 
std::future< HTTPResponseSendPutRequest (std::string_view url, std::string_view content, const CppCommon::Timespan &timeout=CppCommon::Timespan::minutes(1))
 Send PUT request. More...
 
std::future< HTTPResponseSendDeleteRequest (std::string_view url, const CppCommon::Timespan &timeout=CppCommon::Timespan::minutes(1))
 Send DELETE request. More...
 
std::future< HTTPResponseSendOptionsRequest (std::string_view url, const CppCommon::Timespan &timeout=CppCommon::Timespan::minutes(1))
 Send OPTIONS request. More...
 
std::future< HTTPResponseSendTraceRequest (std::string_view url, const CppCommon::Timespan &timeout=CppCommon::Timespan::minutes(1))
 Send TRACE request. More...
 
 HTTPSClient (const HTTPSClient &)=delete
 
 HTTPSClient (HTTPSClient &&)=delete
 
- Public Member Functions inherited from CppServer::HTTP::HTTPSClient
 HTTPSClient (const HTTPSClient &)=delete
 
 HTTPSClient (HTTPSClient &&)=delete
 
virtual ~HTTPSClient ()=default
 
HTTPSClientoperator= (const HTTPSClient &)=delete
 
HTTPSClientoperator= (HTTPSClient &&)=delete
 
HTTPRequestrequest () noexcept
 Get the HTTP request. More...
 
const HTTPRequestrequest () const noexcept
 
size_t SendRequest ()
 Send the current HTTP request (synchronous) More...
 
size_t SendRequest (const HTTPRequest &request)
 Send the HTTP request (synchronous) More...
 
size_t SendRequestBody (std::string_view body)
 Send the HTTP request body (synchronous) More...
 
size_t SendRequestBody (const void *buffer, size_t size)
 Send the HTTP request body (synchronous) More...
 
size_t SendRequest (const CppCommon::Timespan &timeout)
 Send the current HTTP request with timeout (synchronous) More...
 
size_t SendRequest (const HTTPRequest &request, const CppCommon::Timespan &timeout)
 Send the HTTP request with timeout (synchronous) More...
 
size_t SendRequestBody (std::string_view body, const CppCommon::Timespan &timeout)
 Send the HTTP request body with timeout (synchronous) More...
 
size_t SendRequestBody (const void *buffer, size_t size, const CppCommon::Timespan &timeout)
 Send the HTTP request body with timeout (synchronous) More...
 
bool SendRequestAsync ()
 Send the current HTTP request (asynchronous) More...
 
bool SendRequestAsync (const HTTPRequest &request)
 Send the HTTP request (asynchronous) More...
 
bool SendRequestBodyAsync (std::string_view body)
 Send the HTTP request body (asynchronous) More...
 
bool SendRequestBodyAsync (const void *buffer, size_t size)
 Send the HTTP request body (asynchronous) More...
 
- Public Member Functions inherited from CppServer::Asio::SSLClient
 SSLClient (const std::shared_ptr< Service > &service, const std::shared_ptr< SSLContext > &context, const std::string &address, int port)
 Initialize SSL client with a given Asio service, SSL context, server address and port number. More...
 
 SSLClient (const std::shared_ptr< Service > &service, const std::shared_ptr< SSLContext > &context, const std::string &address, const std::string &scheme)
 Initialize SSL client with a given Asio service, SSL context, server address and scheme name. More...
 
 SSLClient (const std::shared_ptr< Service > &service, const std::shared_ptr< SSLContext > &context, const asio::ip::tcp::endpoint &endpoint)
 Initialize SSL client with a given Asio service, SSL context and endpoint. More...
 
 SSLClient (const SSLClient &)=delete
 
 SSLClient (SSLClient &&client)=delete
 
virtual ~SSLClient ()
 
SSLClientoperator= (const SSLClient &)=delete
 
SSLClientoperator= (SSLClient &&client)=delete
 
const CppCommon::UUID & id () const noexcept
 Get the client Id. More...
 
std::shared_ptr< Service > & service () noexcept
 Get the Asio service. More...
 
std::shared_ptr< asio::io_service > & io_service () noexcept
 Get the Asio IO service. More...
 
asio::io_service::strand & strand () noexcept
 Get the Asio service strand for serialized handler execution. More...
 
std::shared_ptr< SSLContext > & context () noexcept
 Get the client SSL context. More...
 
asio::ip::tcp::endpoint & endpoint () noexcept
 Get the client endpoint. More...
 
asio::ssl::stream< asio::ip::tcp::socket > & stream () noexcept
 Get the client SSL stream. More...
 
asio::ssl::stream< asio::ip::tcp::socket >::next_layer_type & socket () noexcept
 Get the client socket. More...
 
const std::string & address () const noexcept
 Get the server address. More...
 
const std::string & scheme () const noexcept
 Get the scheme name. More...
 
int port () const noexcept
 Get the server port number. More...
 
uint64_t bytes_pending () const noexcept
 Get the number of bytes pending sent by the client. More...
 
uint64_t bytes_sent () const noexcept
 Get the number of bytes sent by the client. More...
 
uint64_t bytes_received () const noexcept
 Get the number of bytes received by the client. More...
 
bool option_keep_alive () const noexcept
 Get the option: keep alive. More...
 
bool option_no_delay () const noexcept
 Get the option: no delay. More...
 
size_t option_receive_buffer_limit () const
 Get the option: receive buffer limit. More...
 
size_t option_receive_buffer_size () const
 Get the option: receive buffer size. More...
 
size_t option_send_buffer_limit () const
 Get the option: send buffer limit. More...
 
size_t option_send_buffer_size () const
 Get the option: send buffer size. More...
 
bool IsConnected () const noexcept
 Is the client connected? More...
 
bool IsHandshaked () const noexcept
 Is the session handshaked? More...
 
virtual bool Connect ()
 Connect the client (synchronous) More...
 
virtual bool Connect (const std::shared_ptr< TCPResolver > &resolver)
 Connect the client using the given DNS resolver (synchronous) More...
 
virtual bool Disconnect ()
 Disconnect the client (synchronous) More...
 
virtual bool Reconnect ()
 Reconnect the client (synchronous) More...
 
virtual bool ConnectAsync ()
 Connect the client (asynchronous) More...
 
virtual bool ConnectAsync (const std::shared_ptr< TCPResolver > &resolver)
 Connect the client using the given DNS resolver (asynchronous) More...
 
virtual bool DisconnectAsync ()
 Disconnect the client (asynchronous) More...
 
virtual bool ReconnectAsync ()
 Reconnect the client (asynchronous) More...
 
virtual size_t Send (const void *buffer, size_t size)
 Send data to the server (synchronous) More...
 
virtual size_t Send (std::string_view text)
 Send text to the server (synchronous) More...
 
virtual size_t Send (const void *buffer, size_t size, const CppCommon::Timespan &timeout)
 Send data to the server with timeout (synchronous) More...
 
virtual size_t Send (std::string_view text, const CppCommon::Timespan &timeout)
 Send text to the server with timeout (synchronous) More...
 
virtual bool SendAsync (const void *buffer, size_t size)
 Send data to the server (asynchronous) More...
 
virtual bool SendAsync (std::string_view text)
 Send text to the server (asynchronous) More...
 
virtual size_t Receive (void *buffer, size_t size)
 Receive data from the server (synchronous) More...
 
virtual std::string Receive (size_t size)
 Receive text from the server (synchronous) More...
 
virtual size_t Receive (void *buffer, size_t size, const CppCommon::Timespan &timeout)
 Receive data from the server with timeout (synchronous) More...
 
virtual std::string Receive (size_t size, const CppCommon::Timespan &timeout)
 Receive text from the server with timeout (synchronous) More...
 
virtual void ReceiveAsync ()
 Receive data from the server (asynchronous) More...
 
void SetupKeepAlive (bool enable) noexcept
 Setup option: keep alive. More...
 
void SetupNoDelay (bool enable) noexcept
 Setup option: no delay. More...
 
void SetupReceiveBufferLimit (size_t limit)
 Setup option: receive buffer limit. More...
 
void SetupReceiveBufferSize (size_t size)
 Setup option: receive buffer size. More...
 
void SetupSendBufferLimit (size_t limit)
 Setup option: send buffer limit. More...
 
void SetupSendBufferSize (size_t size)
 Setup option: send buffer size. More...
 

Protected Member Functions

void onHandshaked () override
 Handle session handshaked notification. More...
 
void onDisconnected () override
 Handle client disconnected notification. More...
 
void onReceivedResponse (const HTTPResponse &response) override
 Handle HTTP response received notification. More...
 
void onReceivedResponseError (const HTTPResponse &response, const std::string &error) override
 Handle HTTP response error notification. More...
 
- Protected Member Functions inherited from CppServer::HTTP::HTTPSClient
void onReceived (const void *buffer, size_t size) override
 Handle buffer received notification. More...
 
virtual void onReceivedResponseHeader (const HTTPResponse &response)
 Handle HTTP response header received notification. More...
 
- Protected Member Functions inherited from CppServer::Asio::SSLClient
virtual void onConnected ()
 Handle client connected notification. More...
 
virtual void onSent (size_t sent, size_t pending)
 Handle buffer sent notification. More...
 
virtual void onEmpty ()
 Handle empty send buffer notification. More...
 
virtual void onError (int error, const std::string &category, const std::string &message)
 Handle error notification. More...
 

Additional Inherited Members

- Protected Attributes inherited from CppServer::HTTP::HTTPSClient
HTTPRequest _request
 HTTP request. More...
 
HTTPResponse _response
 HTTP response. More...
 

Detailed Description

HTTPS extended client.

HTTPS extended client make requests to HTTPS Web server with returning std::future as a synchronization primitive.

Thread-safe.

Definition at line 175 of file https_client.h.

Member Function Documentation

◆ HTTPSClient() [1/2]

CppServer::HTTP::HTTPSClient::HTTPSClient
delete

◆ HTTPSClient() [2/2]

CppServer::HTTP::HTTPSClient::HTTPSClient
delete

◆ onDisconnected()

void CppServer::HTTP::HTTPSClientEx::onDisconnected ( )
overrideprotectedvirtual

Handle client disconnected notification.

Reimplemented from CppServer::HTTP::HTTPSClient.

Definition at line 132 of file https_client.cpp.

◆ onHandshaked()

void CppServer::HTTP::HTTPSClientEx::onHandshaked ( )
overrideprotectedvirtual

Handle session handshaked notification.

Reimplemented from CppServer::Asio::SSLClient.

Definition at line 122 of file https_client.cpp.

◆ onReceivedResponse()

void CppServer::HTTP::HTTPSClientEx::onReceivedResponse ( const HTTPResponse response)
overrideprotectedvirtual

Handle HTTP response received notification.

Notification is called when HTTP response was received from the server.

Parameters
response- HTTP response

Reimplemented from CppServer::HTTP::HTTPSClient.

Definition at line 141 of file https_client.cpp.

◆ onReceivedResponseError()

void CppServer::HTTP::HTTPSClientEx::onReceivedResponseError ( const HTTPResponse response,
const std::string &  error 
)
overrideprotectedvirtual

Handle HTTP response error notification.

Notification is called when HTTP response error was received from the server.

Parameters
response- HTTP response
error- HTTP response error

Reimplemented from CppServer::HTTP::HTTPSClient.

Definition at line 150 of file https_client.cpp.

◆ resolver() [1/2]

const std::shared_ptr<Asio::TCPResolver>& CppServer::HTTP::HTTPSClientEx::resolver ( ) const
inlinenoexcept

Definition at line 182 of file https_client.h.

◆ resolver() [2/2]

std::shared_ptr<Asio::TCPResolver>& CppServer::HTTP::HTTPSClientEx::resolver ( )
inlinenoexcept

Get the TCP resolver.

Definition at line 181 of file https_client.h.

◆ SendDeleteRequest()

std::future<HTTPResponse> CppServer::HTTP::HTTPSClientEx::SendDeleteRequest ( std::string_view  url,
const CppCommon::Timespan &  timeout = CppCommon::Timespan::minutes(1) 
)
inline

Send DELETE request.

Parameters
url- URL to request
timeout- HTTP request timeout
Returns
HTTP request future

Definition at line 241 of file https_client.h.

◆ SendGetRequest()

std::future<HTTPResponse> CppServer::HTTP::HTTPSClientEx::SendGetRequest ( std::string_view  url,
const CppCommon::Timespan &  timeout = CppCommon::Timespan::minutes(1) 
)
inline

Send GET request.

Parameters
url- URL to request
timeout- HTTP request timeout
Returns
HTTP request future

Definition at line 215 of file https_client.h.

◆ SendHeadRequest()

std::future<HTTPResponse> CppServer::HTTP::HTTPSClientEx::SendHeadRequest ( std::string_view  url,
const CppCommon::Timespan &  timeout = CppCommon::Timespan::minutes(1) 
)
inline

Send HEAD request.

Parameters
url- URL to request
timeout- HTTP request timeout
Returns
HTTP request future

Definition at line 207 of file https_client.h.

◆ SendOptionsRequest()

std::future<HTTPResponse> CppServer::HTTP::HTTPSClientEx::SendOptionsRequest ( std::string_view  url,
const CppCommon::Timespan &  timeout = CppCommon::Timespan::minutes(1) 
)
inline

Send OPTIONS request.

Parameters
url- URL to request
timeout- HTTP request timeout
Returns
HTTP request future

Definition at line 249 of file https_client.h.

◆ SendPostRequest()

std::future<HTTPResponse> CppServer::HTTP::HTTPSClientEx::SendPostRequest ( std::string_view  url,
std::string_view  content,
const CppCommon::Timespan &  timeout = CppCommon::Timespan::minutes(1) 
)
inline

Send POST request.

Parameters
url- URL to request
content- Content
timeout- HTTP request timeout
Returns
HTTP request future

Definition at line 224 of file https_client.h.

◆ SendPutRequest()

std::future<HTTPResponse> CppServer::HTTP::HTTPSClientEx::SendPutRequest ( std::string_view  url,
std::string_view  content,
const CppCommon::Timespan &  timeout = CppCommon::Timespan::minutes(1) 
)
inline

Send PUT request.

Parameters
url- URL to request
content- Content
timeout- HTTP request timeout
Returns
HTTP request future

Definition at line 233 of file https_client.h.

◆ SendRequest() [1/2]

std::future<HTTPResponse> CppServer::HTTP::HTTPSClientEx::SendRequest ( const CppCommon::Timespan &  timeout = CppCommon::Timespan::minutes(1))
inline

Send HTTP request.

Parameters
timeout- HTTP request timeout
Returns
HTTP request future

Definition at line 192 of file https_client.h.

◆ SendRequest() [2/2]

std::future< HTTPResponse > CppServer::HTTP::HTTPSClientEx::SendRequest ( const HTTPRequest request,
const CppCommon::Timespan &  timeout = CppCommon::Timespan::minutes(1) 
)

HTTP request.

Parameters
request- HTTP request
timeout- HTTP request timeout
Returns
HTTP request future

Definition at line 63 of file https_client.cpp.

◆ SendTraceRequest()

std::future<HTTPResponse> CppServer::HTTP::HTTPSClientEx::SendTraceRequest ( std::string_view  url,
const CppCommon::Timespan &  timeout = CppCommon::Timespan::minutes(1) 
)
inline

Send TRACE request.

Parameters
url- URL to request
timeout- HTTP request timeout
Returns
HTTP request future

Definition at line 257 of file https_client.h.

◆ timeout() [1/2]

const std::shared_ptr<Asio::Timer>& CppServer::HTTP::HTTPSClientEx::timeout ( ) const
inlinenoexcept

Definition at line 185 of file https_client.h.

◆ timeout() [2/2]

std::shared_ptr<Asio::Timer>& CppServer::HTTP::HTTPSClientEx::timeout ( )
inlinenoexcept

Get the timeout check timer.

Definition at line 184 of file https_client.h.


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