Axmol Engine 2.4.0-258ceca
|
Singleton that handles asynchronous http requests. More...
#include <HttpClient.h>
Public Member Functions | |
void | enableCookies (const char *cookieFile) |
Enable cookie support. | |
std::string_view | getCookieFilename () |
Get the cookie filename. | |
void | setSSLVerification (std::string_view caFile) |
Set root certificate path for SSL verification. | |
std::string_view | getSSLVerification () |
Get the ssl CA filename. | |
void | send (HttpRequest *request) |
Add a get request to task queue. | |
void | sendImmediate (HttpRequest *request) |
Immediate send a request. | |
void | setTimeoutForConnect (int value) |
Set the timeout value for connecting. | |
int | getTimeoutForConnect () |
Get the timeout value for connecting. | |
void | setTimeoutForRead (int value) |
Set the timeout value for reading. | |
int | getTimeoutForRead () |
Get the timeout value for reading. | |
void | clearResponseAndRequestQueue () |
Clears the pending http responses and http requests If defined, the method uses the ClearRequestPredicate and ClearResponsePredicate to check for each request/response which to delete. | |
void | setClearRequestPredicate (ClearRequestPredicate predicate) |
Sets a predicate function that is going to be called to determine if we proceed each of the pending requests. | |
void | setClearResponsePredicate (ClearResponsePredicate predicate) |
Sets a predicate function that is going to be called to determine if we proceed each of the pending requests. | |
void | enableCookies (const char *cookieFile) |
Enable cookie support. | |
std::string_view | getCookieFilename () |
Get the cookie filename. | |
void | setSSLVerification (std::string_view caFile) |
Set root certificate path for SSL verification. | |
std::string_view | getSSLVerification () |
Get the ssl CA filename. | |
void | send (HttpRequest *request) |
Send http request concurrently, non-blocking. | |
void | setTimeoutForConnect (int value) |
Set the timeout value for connecting. | |
int | getTimeoutForConnect () |
Get the timeout value for connecting. | |
void | setTimeoutForRead (int value) |
Set the timeout value for reading. | |
int | getTimeoutForRead () |
Get the timeout value for reading. | |
void | clearResponseQueue () |
Clears the pending & finished http response. | |
void | clearPendingResponseQueue () |
Clears the pending http response. | |
void | clearFinishedResponseQueue () |
Clears the finished http response. | |
void | setClearResponsePredicate (ClearResponsePredicate predicate) |
Sets a predicate function that is going to be called to determine if we proceed each of the pending requests. | |
Static Public Member Functions | |
static HttpClient * | getInstance () |
Get instance of HttpClient. | |
static void | destroyInstance () |
Release the instance of HttpClient. | |
static HttpClient * | getInstance () |
Get instance of HttpClient. | |
static void | destroyInstance () |
Release the instance of HttpClient. | |
Static Public Attributes | |
static const int | RESPONSE_BUFFER_SIZE = 256 |
The buffer size of _responseMessage. | |
static const int | MAX_CHANNELS = 21 |
How many requests could be perform concurrency. | |
Singleton that handles asynchronous http requests.
Once the request completed, a callback will issued in main thread when it provided during make request.
@lua NA
|
static |
Get instance of HttpClient.
void enableCookies | ( | const char * | cookieFile | ) |
Enable cookie support.
[nullable] | cookieFile the filepath of cookie file. |
std::string_view getCookieFilename | ( | ) |
Get the cookie filename.
void setSSLVerification | ( | std::string_view | caFile | ) |
Set root certificate path for SSL verification.
caFile | a full path of root certificate.if it is empty, SSL verification is disabled. |
std::string_view getSSLVerification | ( | ) |
Get the ssl CA filename.
void send | ( | HttpRequest * | request | ) |
Add a get request to task queue.
request | a HttpRequest object, which includes url, response callback etc. please make sure request->_requestData is clear before calling "send" here. |
void sendImmediate | ( | HttpRequest * | request | ) |
Immediate send a request.
request | a HttpRequest object, which includes url, response callback etc. please make sure request->_requestData is clear before calling "sendImmediate" here. |
void setTimeoutForConnect | ( | int | value | ) |
Set the timeout value for connecting.
value | the timeout value for connecting. |
int getTimeoutForConnect | ( | ) |
Get the timeout value for connecting.
void setTimeoutForRead | ( | int | value | ) |
Set the timeout value for reading.
value | the timeout value for reading. |
int getTimeoutForRead | ( | ) |
Get the timeout value for reading.
|
inline |
Sets a predicate function that is going to be called to determine if we proceed each of the pending requests.
predicate | function that will be called |
|
inline |
Sets a predicate function that is going to be called to determine if we proceed each of the pending requests.
cb | predicate function that will be called |
|
static |
Get instance of HttpClient.
void enableCookies | ( | const char * | cookieFile | ) |
Enable cookie support.
[nullable] | cookieFile the filepath of cookie file. |
std::string_view getCookieFilename | ( | ) |
Get the cookie filename.
void setSSLVerification | ( | std::string_view | caFile | ) |
Set root certificate path for SSL verification.
caFile | a full path of root certificate.if it is empty, SSL verification is disabled. |
std::string_view getSSLVerification | ( | ) |
Get the ssl CA filename.
void send | ( | HttpRequest * | request | ) |
Send http request concurrently, non-blocking.
request | a HttpRequest object, which includes url, response callback etc. please make sure request->_requestData is clear before calling "send" here. @notes for post data a. By default will fill Content-Type: application/x-www-form-urlencoded;charset=UTF-8 b. You can specific content-type at custom header, such as: std::vector<std::string> headers = {"Content-Type: application/json;charset=UTF-8"}; request->setHeaders(headers); c. other content type, please see: https://stackoverflow.com/questions/23714383/what-are-all-the-possible-values-for-http-content-type-header |
void setTimeoutForConnect | ( | int | value | ) |
Set the timeout value for connecting.
value | the timeout value for connecting. |
int getTimeoutForConnect | ( | ) |
Get the timeout value for connecting.
void setTimeoutForRead | ( | int | value | ) |
Set the timeout value for reading.
value | the timeout value for reading. |
int getTimeoutForRead | ( | ) |
Get the timeout value for reading.
|
inline |
Sets a predicate function that is going to be called to determine if we proceed each of the pending requests.
cb | predicate function that will be called |