Defines the object which users must packed for HttpClient::send(HttpRequest*) method.
More...
Inherits Ref.
|
class | _prxy |
| This sub class is just for migration SEL_CallFuncND to SEL_HttpResponse,someday this way will be removed. More...
|
|
|
unsigned int | _ID |
| object id, ScriptSupport need public _ID
|
|
int | _luaID |
| Lua reference id.
|
|
void * | _scriptObject |
| scriptObject, support for swift
|
|
bool | _rooted |
| When true, it means that the object was already rooted.
|
|
Defines the object which users must packed for HttpClient::send(HttpRequest*) method.
Please refer to tests/test-cpp/Classes/ExtensionTest/NetworkTest/HttpClientTest.cpp as a sample
- Since
- v2.0.2
NA
Constructor.
Because HttpRequest object will be used between UI thread and network thread, requestObj->autorelease() is forbidden to avoid crashes in AutoreleasePool new/retain/release still works, which means you need to release it manually Please refer to HttpRequestTest.cpp to find its usage.
Override autorelease method to avoid developers to call it.
If this function was called, it would trigger assert in debug mode
- Returns
- Ref* always return nullptr.
void setRequestType |
( |
Type |
type | ) |
|
|
inline |
Type getRequestType |
( |
| ) |
const |
|
inline |
void setUrl |
( |
const std::string & |
url | ) |
|
|
inline |
Set the url address of HttpRequest object.
The url value could be like these: "http://httpbin.org/ip" or "https://httpbin.org/get"
- Parameters
-
const char* getUrl |
( |
| ) |
const |
|
inline |
Get the url address of HttpRequest object.
- Returns
- const char* the pointer of _url.
void setRequestData |
( |
const char * |
buffer, |
|
|
size_t |
len |
|
) |
| |
|
inline |
Set the request data of HttpRequest object.
- Parameters
-
buffer | the buffer of request data, it support binary data. |
len | the size of request data. |
Get the request data pointer of HttpRequest object.
- Returns
- char* the request data pointer.
ssize_t getRequestDataSize |
( |
| ) |
const |
|
inline |
Get the size of request data.
- Returns
- ssize_t the size of request data
void setTag |
( |
const std::string & |
tag | ) |
|
|
inline |
Set a string tag to identify your request.
This tag can be found in HttpResponse->getHttpRequest->getTag().
- Parameters
-
const char* getTag |
( |
| ) |
const |
|
inline |
Get the string tag to identify the request.
The best practice is to use it in your MyClass::onMyHttpRequestCompleted(sender, HttpResponse*) callback.
- Returns
- const char* the pointer of _tag
void setUserData |
( |
void * |
pUserData | ) |
|
|
inline |
Set user-customed data of HttpRequest object.
You can attach a customed data in each request, and get it back in response callback. But you need to new/delete the data pointer manually.
- Parameters
-
pUserData | the string pointer |
void* getUserData |
( |
| ) |
const |
|
inline |
Get the user-customed data pointer which were pre-setted.
Don't forget to delete it. HttpClient/HttpResponse/HttpRequest will do nothing with this pointer.
- Returns
- void* the pointer of user-customed data.
void setResponseCallback |
( |
Ref * |
pTarget, |
|
|
SEL_HttpResponse |
pSelector |
|
) |
| |
|
inline |
Set the target and related callback selector of HttpRequest object.
When response come back, we would call (pTarget->*pSelector) to process response data.
- Parameters
-
pTarget | the target object pointer. |
pSelector | the SEL_HttpResponse function. |
void setResponseCallback |
( |
const ccHttpRequestCallback & |
callback | ) |
|
|
inline |
Set response callback function of HttpRequest object.
When response come back, we would call _pCallback to process response data.
- Parameters
-
callback | the ccHttpRequestCallback function. |
Get the target of callback selector function, mainly used by HttpClient.
- Returns
- Ref* the target of callback selector function
_prxy getSelector |
( |
| ) |
const |
|
inline |
const ccHttpRequestCallback& getCallback |
( |
| ) |
const |
|
inline |
Get ccHttpRequestCallback callback function.
- Returns
- const ccHttpRequestCallback& ccHttpRequestCallback callback function.
void setHeaders |
( |
const std::vector< std::string > & |
headers | ) |
|
|
inline |
Set custom-defined headers.
- Parameters
-
headers | The string vector of custom-defined headers. |
std::vector<std::string> getHeaders |
( |
| ) |
const |
|
inline |
Get custom headers.
- Returns
- std::vector<std::string> the string vector of custom-defined headers.
The documentation for this class was generated from the following file: