Cuberite
A lightweight, fast and extensible game server for Minecraft
Classes | Public Types | Static Public Member Functions | List of all members
cUrlClient Class Reference

#include <UrlClient.h>

Classes

class  cCallbacks
 Callbacks that are used for progress and result reporting. More...
 

Public Types

using cCallbacksPtr = std::shared_ptr< cCallbacks >
 
enum  eHTTPStatus {
  HTTP_STATUS_OK = 200 , HTTP_STATUS_MULTIPLE_CHOICES = 300 , HTTP_STATUS_MOVED_PERMANENTLY = 301 , HTTP_STATUS_FOUND = 302 ,
  HTTP_STATUS_SEE_OTHER = 303 , HTTP_STATUS_TEMPORARY_REDIRECT = 307
}
 Used for HTTP status codes. More...
 

Static Public Member Functions

static std::pair< bool, AStringBlockingGet (const AString &a_URL, AStringMap a_Headers={}, const AString &a_Body={}, const AStringMap &a_Options={})
 Alias for BlockingRequest("GET", ...) More...
 
static std::pair< bool, AStringBlockingPost (const AString &a_URL, AStringMap &&a_Headers, const AString &a_Body, const AStringMap &a_Options={})
 Alias for BlockingRequest("POST", ...) More...
 
static std::pair< bool, AStringBlockingPut (const AString &a_URL, AStringMap &&a_Headers, const AString &a_Body, const AStringMap &a_Options={})
 Alias for BlockingRequest("PUT", ...) More...
 
static std::pair< bool, AStringBlockingRequest (const AString &a_Method, const AString &a_URL, AStringMap &&a_Headers={}, const AString &a_Body={}, const AStringMap &a_Options={})
 Sends a generic request and block until a response is received or an error occurs. More...
 
static std::pair< bool, AStringGet (const AString &a_URL, cCallbacksPtr &&a_Callbacks, AStringMap &&a_Headers={}, const AString &a_Body={}, const AStringMap &a_Options={})
 Alias for Request("GET", ...) More...
 
static std::pair< bool, AStringPost (const AString &a_URL, cCallbacksPtr &&a_Callbacks, AStringMap &&a_Headers, const AString &a_Body, const AStringMap &a_Options={})
 Alias for Request("POST", ...) More...
 
static std::pair< bool, AStringPut (const AString &a_URL, cCallbacksPtr &&a_Callbacks, AStringMap &&a_Headers, const AString &a_Body, const AStringMap &a_Options={})
 Alias for Request("PUT", ...) More...
 
static std::pair< bool, AStringRequest (const AString &a_Method, const AString &a_URL, cCallbacksPtr &&a_Callbacks, AStringMap &&a_Headers, const AString &a_Body, const AStringMap &a_Options)
 Makes a network request to the specified URL, using the specified method (if applicable). More...
 

Detailed Description

Definition at line 34 of file UrlClient.h.

Member Typedef Documentation

◆ cCallbacksPtr

using cUrlClient::cCallbacksPtr = std::shared_ptr<cCallbacks>

Definition at line 90 of file UrlClient.h.

Member Enumeration Documentation

◆ eHTTPStatus

Used for HTTP status codes.

Enumerator
HTTP_STATUS_OK 
HTTP_STATUS_MULTIPLE_CHOICES 
HTTP_STATUS_MOVED_PERMANENTLY 
HTTP_STATUS_FOUND 
HTTP_STATUS_SEE_OTHER 
HTTP_STATUS_TEMPORARY_REDIRECT 

Definition at line 94 of file UrlClient.h.

Member Function Documentation

◆ BlockingGet()

std::pair< bool, AString > cUrlClient::BlockingGet ( const AString a_URL,
AStringMap  a_Headers = {},
const AString a_Body = {},
const AStringMap a_Options = {} 
)
static

Alias for BlockingRequest("GET", ...)

Definition at line 779 of file UrlClient.cpp.

◆ BlockingPost()

std::pair< bool, AString > cUrlClient::BlockingPost ( const AString a_URL,
AStringMap &&  a_Headers,
const AString a_Body,
const AStringMap a_Options = {} 
)
static

Alias for BlockingRequest("POST", ...)

Definition at line 793 of file UrlClient.cpp.

◆ BlockingPut()

std::pair< bool, AString > cUrlClient::BlockingPut ( const AString a_URL,
AStringMap &&  a_Headers,
const AString a_Body,
const AStringMap a_Options = {} 
)
static

Alias for BlockingRequest("PUT", ...)

Definition at line 807 of file UrlClient.cpp.

◆ BlockingRequest()

std::pair< bool, AString > cUrlClient::BlockingRequest ( const AString a_Method,
const AString a_URL,
AStringMap &&  a_Headers = {},
const AString a_Body = {},
const AStringMap a_Options = {} 
)
static

Sends a generic request and block until a response is received or an error occurs.

The first returned value specifies whether the response was received successfully. If successful, the second value provides the actual response data.

Definition at line 744 of file UrlClient.cpp.

◆ Get()

std::pair< bool, AString > cUrlClient::Get ( const AString a_URL,
cCallbacksPtr &&  a_Callbacks,
AStringMap &&  a_Headers = {},
const AString a_Body = {},
const AStringMap a_Options = {} 
)
static

Alias for Request("GET", ...)

Definition at line 693 of file UrlClient.cpp.

◆ Post()

std::pair< bool, AString > cUrlClient::Post ( const AString a_URL,
cCallbacksPtr &&  a_Callbacks,
AStringMap &&  a_Headers,
const AString a_Body,
const AStringMap a_Options = {} 
)
static

Alias for Request("POST", ...)

Definition at line 710 of file UrlClient.cpp.

◆ Put()

std::pair< bool, AString > cUrlClient::Put ( const AString a_URL,
cCallbacksPtr &&  a_Callbacks,
AStringMap &&  a_Headers,
const AString a_Body,
const AStringMap a_Options = {} 
)
static

Alias for Request("PUT", ...)

Definition at line 727 of file UrlClient.cpp.

◆ Request()

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

Makes a network request to the specified URL, using the specified method (if applicable).

The response is reported via the a_ResponseCallback callback, in a single call. The metadata about the response (HTTP headers) are reported via a_InfoCallback before the a_ResponseCallback call. If there is an asynchronous error, it is reported in via the a_ErrorCallback. If there is an immediate error (misformatted URL etc.), the function returns false and an error message. a_Headers contains additional headers to use for the request. a_Body specifies optional body to include with the request, if applicable. a_Options contains various options for the request that govern the request behavior, but aren't sent to the server, such as the proxy server, whether to follow redirects, and client certificate for TLS.

Definition at line 675 of file UrlClient.cpp.


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