Cuberite
A lightweight, fast and extensible game server for Minecraft
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
cUrlClientRequest Class Reference
Inheritance diagram for cUrlClientRequest:
Inheritance graph
[legend]
Collaboration diagram for cUrlClientRequest:
Collaboration graph
[legend]

Public Member Functions

void CallErrorCallback (const AString &a_ErrorMessage)
 Calls the error callback with the specified message, if it exists, and terminates the request. More...
 
cUrlClient::cCallbacksGetCallbacks ()
 
cX509CertPtr GetOwnCert () const
 
cCryptoKeyPtr GetOwnPrivKey () const
 
cX509CertPtr GetTrustedRootCAs () const
 Returns the parsed TrustedRootCAs from the options, or an empty pointer if the option is not set. More...
 
void RedirectTo (const AString &a_RedirectUrl)
 
bool ShouldAllowRedirects () const
 
- Public Member Functions inherited from cNetwork::cConnectCallbacks
virtual ~cConnectCallbacks ()
 
- Public Member Functions inherited from cTCPLink::cCallbacks
virtual ~cCallbacks ()
 

Static Public Member Functions

static std::pair< bool, AStringRequest (const AString &a_Method, const AString &a_URL, cUrlClient::cCallbacksPtr &&a_Callbacks, AStringMap &&a_Headers, const AString &a_Body, const AStringMap &a_Options)
 

Protected Member Functions

 cUrlClientRequest (const AString &a_Method, const AString &a_Url, cUrlClient::cCallbacksPtr &&a_Callbacks, AStringMap &&a_Headers, const AString &a_Body, const AStringMap &a_Options)
 
std::pair< bool, AStringDoRequest (const std::shared_ptr< cUrlClientRequest > &a_Self)
 
virtual void OnConnected (cTCPLink &a_Link) override
 Called when the Connect call succeeds. More...
 
virtual void OnError (int a_ErrorCode, const AString &a_ErrorMsg) override
 Called when an error is detected on the connection. More...
 
virtual void OnLinkCreated (cTCPLinkPtr a_Link) override
 Called when the cTCPLink for the connection is created. More...
 
virtual void OnReceivedData (const char *a_Data, size_t a_Length) override
 Called when there's data incoming from the remote peer. More...
 
virtual void OnRemoteClosed (void) override
 Called when the remote end closes the connection. More...
 
virtual void OnTlsHandshakeCompleted (void) override
 Called when the TLS handshake has been completed and communication can continue regularly. More...
 

Protected Attributes

AString m_Body
 Body to be sent with the request, if any. More...
 
cUrlClient::cCallbacksPtr m_Callbacks
 Callbacks that report progress and results of the request. More...
 
AStringMap m_Headers
 Extra headers to be sent with the request (besides the normal ones). More...
 
std::weak_ptr< cTCPLinkm_Link
 The link handling the request. More...
 
AString m_Method
 Method to be used for the request. More...
 
int m_NumRemainingRedirects
 The number of redirect attempts that will still be followed. More...
 
AStringMap m_Options
 Extra options to be used for the request. More...
 
std::shared_ptr< cSchemeHandler > m_SchemeHandler
 The handler that "talks" the protocol specified in m_UrlScheme, handles all the sending and receiving. More...
 
std::weak_ptr< cUrlClientRequestm_Self
 weak_ptr to self, so that this object can keep itself alive as needed by calling lock(), and pass self as callbacks to cNetwork functions. More...
 
AString m_Url
 URL that will be requested. More...
 
AString m_UrlFragment
 
AString m_UrlHost
 
AString m_UrlPassword
 
AString m_UrlPath
 
UInt16 m_UrlPort
 
AString m_UrlQuery
 
AString m_UrlScheme
 Individual components of the URL that will be requested. More...
 
AString m_UrlUsername
 

Friends

class cHttpSchemeHandler
 

Detailed Description

Definition at line 71 of file UrlClient.cpp.

Constructor & Destructor Documentation

◆ cUrlClientRequest()

cUrlClientRequest::cUrlClientRequest ( const AString a_Method,
const AString a_Url,
cUrlClient::cCallbacksPtr &&  a_Callbacks,
AStringMap &&  a_Headers,
const AString a_Body,
const AStringMap a_Options 
)
inlineprotected

Definition at line 207 of file UrlClient.cpp.

Member Function Documentation

◆ CallErrorCallback()

void cUrlClientRequest::CallErrorCallback ( const AString a_ErrorMessage)
inline

Calls the error callback with the specified message, if it exists, and terminates the request.

Definition at line 97 of file UrlClient.cpp.

◆ DoRequest()

std::pair< bool, AString > cUrlClientRequest::DoRequest ( const std::shared_ptr< cUrlClientRequest > &  a_Self)
protected

Definition at line 639 of file UrlClient.cpp.

◆ GetCallbacks()

cUrlClient::cCallbacks& cUrlClientRequest::GetCallbacks ( )
inline

Definition at line 110 of file UrlClient.cpp.

◆ GetOwnCert()

cX509CertPtr cUrlClientRequest::GetOwnCert ( ) const
inline

Definition at line 116 of file UrlClient.cpp.

◆ GetOwnPrivKey()

cCryptoKeyPtr cUrlClientRequest::GetOwnPrivKey ( ) const
inline

Definition at line 132 of file UrlClient.cpp.

◆ GetTrustedRootCAs()

cX509CertPtr cUrlClientRequest::GetTrustedRootCAs ( ) const
inline

Returns the parsed TrustedRootCAs from the options, or an empty pointer if the option is not set.

Throws a std::runtime_error if CAs are provided, but parsing them fails.

Definition at line 151 of file UrlClient.cpp.

◆ OnConnected()

void cUrlClientRequest::OnConnected ( cTCPLink a_Link)
overrideprotectedvirtual

Called when the Connect call succeeds.

Provides the newly created link that can be used for communication.

Implements cNetwork::cConnectCallbacks.

Definition at line 591 of file UrlClient.cpp.

◆ OnError()

virtual void cUrlClientRequest::OnError ( int  a_ErrorCode,
const AString a_ErrorMsg 
)
inlineoverrideprotectedvirtual

Called when an error is detected on the connection.

Implements cTCPLink::cCallbacks.

Definition at line 233 of file UrlClient.cpp.

◆ OnLinkCreated()

virtual void cUrlClientRequest::OnLinkCreated ( cTCPLinkPtr  a_Link)
inlineoverrideprotectedvirtual

Called when the cTCPLink for the connection is created.

The callback may store the cTCPLink instance for later use, but it should remove it in OnError(), OnRemoteClosed() or right after Close().

Implements cTCPLink::cCallbacks.

Definition at line 240 of file UrlClient.cpp.

◆ OnReceivedData()

void cUrlClientRequest::OnReceivedData ( const char *  a_Data,
size_t  a_Length 
)
overrideprotectedvirtual

Called when there's data incoming from the remote peer.

Implements cTCPLink::cCallbacks.

Definition at line 612 of file UrlClient.cpp.

◆ OnRemoteClosed()

void cUrlClientRequest::OnRemoteClosed ( void  )
overrideprotectedvirtual

Called when the remote end closes the connection.

The link is still available for connection information query (IP / port). Sending data on the link is not an error, but the data won't be delivered.

Implements cTCPLink::cCallbacks.

Definition at line 625 of file UrlClient.cpp.

◆ OnTlsHandshakeCompleted()

void cUrlClientRequest::OnTlsHandshakeCompleted ( void  )
overrideprotectedvirtual

Called when the TLS handshake has been completed and communication can continue regularly.

Has an empty default implementation, so that link callback descendants don't need to specify TLS handlers when they don't use TLS at all.

Reimplemented from cTCPLink::cCallbacks.

Definition at line 601 of file UrlClient.cpp.

◆ RedirectTo()

void cUrlClientRequest::RedirectTo ( const AString a_RedirectUrl)

Definition at line 550 of file UrlClient.cpp.

◆ Request()

static std::pair<bool, AString> cUrlClientRequest::Request ( const AString a_Method,
const AString a_URL,
cUrlClient::cCallbacksPtr &&  a_Callbacks,
AStringMap &&  a_Headers,
const AString a_Body,
const AStringMap a_Options 
)
inlinestatic

Definition at line 78 of file UrlClient.cpp.

◆ ShouldAllowRedirects()

bool cUrlClientRequest::ShouldAllowRedirects ( ) const

Definition at line 582 of file UrlClient.cpp.

Friends And Related Function Documentation

◆ cHttpSchemeHandler

friend class cHttpSchemeHandler
friend

Definition at line 75 of file UrlClient.cpp.

Member Data Documentation

◆ m_Body

AString cUrlClientRequest::m_Body
protected

Body to be sent with the request, if any.

Definition at line 186 of file UrlClient.cpp.

◆ m_Callbacks

cUrlClient::cCallbacksPtr cUrlClientRequest::m_Callbacks
protected

Callbacks that report progress and results of the request.

Definition at line 180 of file UrlClient.cpp.

◆ m_Headers

AStringMap cUrlClientRequest::m_Headers
protected

Extra headers to be sent with the request (besides the normal ones).

Definition at line 183 of file UrlClient.cpp.

◆ m_Link

std::weak_ptr<cTCPLink> cUrlClientRequest::m_Link
protected

The link handling the request.

Definition at line 199 of file UrlClient.cpp.

◆ m_Method

AString cUrlClientRequest::m_Method
protected

Method to be used for the request.

Definition at line 170 of file UrlClient.cpp.

◆ m_NumRemainingRedirects

int cUrlClientRequest::m_NumRemainingRedirects
protected

The number of redirect attempts that will still be followed.

If the response specifies a redirect and this is nonzero, the redirect is followed. If the response specifies a redirect and this is zero, a redirect loop is reported as an error.

Definition at line 204 of file UrlClient.cpp.

◆ m_Options

AStringMap cUrlClientRequest::m_Options
protected

Extra options to be used for the request.

Definition at line 189 of file UrlClient.cpp.

◆ m_SchemeHandler

std::shared_ptr<cSchemeHandler> cUrlClientRequest::m_SchemeHandler
protected

The handler that "talks" the protocol specified in m_UrlScheme, handles all the sending and receiving.

Definition at line 196 of file UrlClient.cpp.

◆ m_Self

std::weak_ptr<cUrlClientRequest> cUrlClientRequest::m_Self
protected

weak_ptr to self, so that this object can keep itself alive as needed by calling lock(), and pass self as callbacks to cNetwork functions.

Definition at line 193 of file UrlClient.cpp.

◆ m_Url

AString cUrlClientRequest::m_Url
protected

URL that will be requested.

Definition at line 173 of file UrlClient.cpp.

◆ m_UrlFragment

AString cUrlClientRequest::m_UrlFragment
protected

Definition at line 176 of file UrlClient.cpp.

◆ m_UrlHost

AString cUrlClientRequest::m_UrlHost
protected

Definition at line 176 of file UrlClient.cpp.

◆ m_UrlPassword

AString cUrlClientRequest::m_UrlPassword
protected

Definition at line 176 of file UrlClient.cpp.

◆ m_UrlPath

AString cUrlClientRequest::m_UrlPath
protected

Definition at line 176 of file UrlClient.cpp.

◆ m_UrlPort

UInt16 cUrlClientRequest::m_UrlPort
protected

Definition at line 177 of file UrlClient.cpp.

◆ m_UrlQuery

AString cUrlClientRequest::m_UrlQuery
protected

Definition at line 176 of file UrlClient.cpp.

◆ m_UrlScheme

AString cUrlClientRequest::m_UrlScheme
protected

Individual components of the URL that will be requested.

Definition at line 176 of file UrlClient.cpp.

◆ m_UrlUsername

AString cUrlClientRequest::m_UrlUsername
protected

Definition at line 176 of file UrlClient.cpp.


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