Cuberite
A lightweight, fast and extensible game server for Minecraft
Public Member Functions | Protected Attributes | List of all members
cSimpleUrlClientCallbacks Class Reference

Used when the cUrlClient Lua request has just a single callback. More...

Inheritance diagram for cSimpleUrlClientCallbacks:
Inheritance graph
[legend]
Collaboration diagram for cSimpleUrlClientCallbacks:
Collaboration graph
[legend]

Public Member Functions

 cSimpleUrlClientCallbacks (cLuaState::cCallbackPtr &&a_Callback)
 Creates a new instance that uses the specified callback to report when request finishes. More...
 
virtual void OnBodyData (const void *a_Data, size_t a_Size) override
 Called when the next fragment of the response body is received, unless the response is an allowed redirect. More...
 
virtual void OnBodyFinished () override
 Called after the response body has been fully reported by OnBody() calls, unless the response is an allowed redirect. More...
 
virtual void OnError (const AString &a_ErrorMsg) override
 Called when an asynchronous error is encountered. More...
 
virtual void OnHeader (const AString &a_Key, const AString &a_Value) override
 Called when a single HTTP header is received and parsed, unless the response is an allowed redirect Called once for each incoming header. More...
 
- Public Member Functions inherited from cUrlClient::cCallbacks
virtual bool OnCertificateReceived ()
 Called for TLS connections, when the server certificate is received. More...
 
virtual void OnConnected (cTCPLink &a_Link)
 Called when the TCP connection is established. More...
 
virtual void OnHeadersFinished ()
 Called when the HTTP headers have been fully parsed, unless the response is an allowed redirect. More...
 
virtual void OnRedirecting (const AString &a_NewLocation)
 Called when a redirect is to be followed. More...
 
virtual void OnRequestSent ()
 Called after the entire request has been sent to the remote peer. More...
 
virtual void OnStatusLine (const AString &a_HttpVersion, int a_StatusCode, const AString &a_Rest)
 Called after the first line of the response is parsed, unless the response is an allowed redirect. More...
 
virtual void OnTlsHandshakeCompleted ()
 Called for TLS connections, when the TLS handshake has been completed. More...
 
virtual ~cCallbacks ()
 

Protected Attributes

cLuaState::cCallbackPtr m_Callback
 The callback to call when the request finishes. More...
 
AStringMap m_Headers
 Accumulator for all the headers to be reported in the combined callback. More...
 
AString m_ResponseBody
 The accumulator for the partial body data, so that OnBodyFinished() can send the entire thing at once. More...
 

Detailed Description

Used when the cUrlClient Lua request has just a single callback.

The callback is used to report the entire body at once, together with the HTTP headers, or to report an error: callback("BodyContents", {headers}) callback(nil, "ErrorMessage") Accumulates the body contents into a single string until the body is finished. Accumulates all HTTP headers into an AStringMap.

Definition at line 897 of file ManualBindings_Network.cpp.

Constructor & Destructor Documentation

◆ cSimpleUrlClientCallbacks()

cSimpleUrlClientCallbacks::cSimpleUrlClientCallbacks ( cLuaState::cCallbackPtr &&  a_Callback)
inline

Creates a new instance that uses the specified callback to report when request finishes.

Definition at line 902 of file ManualBindings_Network.cpp.

Member Function Documentation

◆ OnBodyData()

virtual void cSimpleUrlClientCallbacks::OnBodyData ( const void *  a_Data,
size_t  a_Size 
)
inlineoverridevirtual

Called when the next fragment of the response body is received, unless the response is an allowed redirect.

This can be called multiple times, as data arrives over the network.

Reimplemented from cUrlClient::cCallbacks.

Definition at line 914 of file ManualBindings_Network.cpp.

◆ OnBodyFinished()

virtual void cSimpleUrlClientCallbacks::OnBodyFinished ( )
inlineoverridevirtual

Called after the response body has been fully reported by OnBody() calls, unless the response is an allowed redirect.

There will be no more OnBody() calls.

Reimplemented from cUrlClient::cCallbacks.

Definition at line 920 of file ManualBindings_Network.cpp.

◆ OnError()

virtual void cSimpleUrlClientCallbacks::OnError ( const AString a_ErrorMsg)
inlineoverridevirtual

Called when an asynchronous error is encountered.

Reimplemented from cUrlClient::cCallbacks.

Definition at line 926 of file ManualBindings_Network.cpp.

◆ OnHeader()

virtual void cSimpleUrlClientCallbacks::OnHeader ( const AString a_Key,
const AString a_Value 
)
inlineoverridevirtual

Called when a single HTTP header is received and parsed, unless the response is an allowed redirect Called once for each incoming header.

Reimplemented from cUrlClient::cCallbacks.

Definition at line 908 of file ManualBindings_Network.cpp.

Member Data Documentation

◆ m_Callback

cLuaState::cCallbackPtr cSimpleUrlClientCallbacks::m_Callback
protected

The callback to call when the request finishes.

Definition at line 935 of file ManualBindings_Network.cpp.

◆ m_Headers

AStringMap cSimpleUrlClientCallbacks::m_Headers
protected

Accumulator for all the headers to be reported in the combined callback.

Definition at line 941 of file ManualBindings_Network.cpp.

◆ m_ResponseBody

AString cSimpleUrlClientCallbacks::m_ResponseBody
protected

The accumulator for the partial body data, so that OnBodyFinished() can send the entire thing at once.

Definition at line 938 of file ManualBindings_Network.cpp.


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