Defines the object which users must packed for HttpClient::send(HttpRequest*) method. More...
#include <HttpRequest.h>
Classes | |
class | _prxy |
This sub class is just for migration SEL_CallFuncND to SEL_HttpResponse,someday this way will be removed. More... | |
Public Types | |
enum | Type { GET, POST, PUT, DELETE, UNKNOWN } |
The HttpRequest type enum used in the HttpRequest::setRequestType. More... | |
Public Member Functions | |
HttpRequest () | |
Constructor. More... | |
virtual | ~HttpRequest () |
Destructor. More... | |
var | ~HttpRequest () |
Destructor. More... | |
Ref * | autorelease (void) |
Override autorelease method to avoid developers to call it. More... | |
var | autorelease () |
Override autorelease method to avoid developers to call it. More... | |
void | setRequestType (Type type) |
Set request type of HttpRequest object before being sent,now it support the enum value of HttpRequest::Type. More... | |
Type | getRequestType () |
Get the request type of HttpRequest object. More... | |
void | setUrl (const char *url) |
Set the url address of HttpRequest object. More... | |
const char * | getUrl () |
Get the url address of HttpRequest object. More... | |
void | setRequestData (const char *buffer, size_t len) |
Set the request data of HttpRequest object. More... | |
var | setRequestData ( var buffer, var len) |
Set the request data of HttpRequest object. More... | |
char * | getRequestData () |
Get the request data pointer of HttpRequest object. More... | |
var | getRequestData () |
Get the request data pointer of HttpRequest object. More... | |
ssize_t | getRequestDataSize () |
Get the size of request data. More... | |
var | getRequestDataSize () |
Get the size of request data. More... | |
void | setTag (const char *tag) |
Set a string tag to identify your request. More... | |
const char * | getTag () |
Get the string tag to identify the request. More... | |
var | getTag () |
Get the string tag to identify the request. More... | |
void | setUserData (void *pUserData) |
Set user-customed data of HttpRequest object. More... | |
void * | getUserData () |
Get the user-customed data pointer which were pre-setted. More... | |
var | getUserData () |
Get the user-customed data pointer which were pre-setted. More... | |
void | setResponseCallback (Ref *pTarget, SEL_CallFuncND pSelector) |
Set the target and related callback selector. More... | |
void | setResponseCallback (Ref *pTarget, SEL_HttpResponse pSelector) |
Set the target and related callback selector of HttpRequest object. More... | |
void | setResponseCallback (const ccHttpRequestCallback &callback) |
Set response callback function of HttpRequest object. More... | |
Ref * | getTarget () |
Get the target of callback selector funtion, mainly used by HttpClient. More... | |
_prxy | getSelector () |
Get _prxy object by the _pSelector. More... | |
var | getSelector () |
Get _prxy object by the _pSelector. More... | |
const ccHttpRequestCallback & | getCallback () |
Get ccHttpRequestCallback callback function. More... | |
void | setHeaders (std::vector< std::string > pHeaders) |
Set custom-defined headers. More... | |
var | setHeaders ( var pHeaders) |
Set custom-defined headers. More... | |
std::vector< std::string > | getHeaders () |
Get custom headers. More... | |
Public Member Functions inherited from Ref | |
void | retain () |
Retains the ownership. More... | |
void | release () |
Releases the ownership immediately. More... | |
Ref * | autorelease () |
Releases the ownership sometime soon automatically. More... | |
unsigned int | getReferenceCount () const |
Returns the Ref's current reference count. More... | |
virtual | ~Ref () |
Destructor. More... | |
Protected Attributes | |
Type | _requestType |
std::string | _url |
kHttpRequestGet, kHttpRequestPost or other enums More... | |
var | _url |
kHttpRequestGet, kHttpRequestPost or other enums More... | |
std::vector< char > | _requestData |
target url that this request is sent to More... | |
var | _requestData |
target url that this request is sent to More... | |
std::string | _tag |
used for POST More... | |
var | _tag |
used for POST More... | |
Ref * | _pTarget |
user defined tag, to identify different requests in response callback More... | |
var | _pTarget |
user defined tag, to identify different requests in response callback More... | |
SEL_HttpResponse | _pSelector |
callback target of pSelector function More... | |
var | _pSelector |
callback target of pSelector function More... | |
ccHttpRequestCallback | _pCallback |
callback function, e.g. MyLayer::onHttpResponse(HttpClient *sender, HttpResponse * response) More... | |
var | _pCallback |
callback function, e.g. MyLayer::onHttpResponse(HttpClient *sender, HttpResponse * response) More... | |
void * | _pUserData |
C++11 style callbacks. More... | |
std::vector< std::string > | _headers |
You can add your customed data here. More... | |
var | _headers |
You can add your customed data here. More... | |
Protected Attributes inherited from Ref | |
unsigned int | _referenceCount |
count of references More... | |
local | _referenceCount |
count of references More... | |
Additional Inherited Members | |
Protected Member Functions inherited from Ref | |
Ref () | |
Constructor. More... | |
Ref () | |
Constructor. More... | |
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
|
strong |
The HttpRequest type enum used in the HttpRequest::setRequestType.
Enumerator | |
---|---|
GET | |
POST | |
PUT | |
DELETE | |
UNKNOWN |
|
strong |
The HttpRequest type enum used in the HttpRequest::setRequestType.
Enumerator | |
---|---|
GET | |
POST | |
PUT | |
DELETE | |
UNKNOWN |
|
inline |
Constructor.
Because HttpRequest object will be used between UI thead 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.
|
inline |
Constructor.
Because HttpRequest object will be used between UI thead 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.
|
inlinevirtual |
Destructor.
|
inlinevirtual |
Destructor.
|
inline |
Override autorelease method to avoid developers to call it.
If this function was called, it would trigger assert in debug mode
|
inline |
Override autorelease method to avoid developers to call it.
If this function was called, it would trigger assert in debug mode
|
inline |
Get ccHttpRequestCallback callback function.
|
inline |
Get ccHttpRequestCallback callback function.
|
inline |
Get custom headers.
|
inline |
Get custom headers.
|
inline |
Get the request data pointer of HttpRequest object.
|
inline |
Get the request data pointer of HttpRequest object.
|
inline |
Get the size of request data.
|
inline |
Get the size of request data.
|
inline |
Get the request type of HttpRequest object.
|
inline |
Get the request type of HttpRequest object.
|
inline |
Get the string tag to identify the request.
The best practice is to use it in your MyClass::onMyHttpRequestCompleted(sender, HttpResponse*) callback.
|
inline |
Get the string tag to identify the request.
The best practice is to use it in your MyClass::onMyHttpRequestCompleted(sender, HttpResponse*) callback.
|
inline |
Get the target of callback selector funtion, mainly used by HttpClient.
|
inline |
Get the target of callback selector funtion, mainly used by HttpClient.
|
inline |
Get the url address of HttpRequest object.
|
inline |
Get the url address of HttpRequest object.
|
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.
|
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.
|
inline |
Set custom-defined headers.
pHeaders | the string vector of custom-defined headers. |
|
inline |
Set custom-defined headers.
pHeaders | the string vector of custom-defined headers. |
|
inline |
Set the request data of HttpRequest object.
buffer | the buffer of request data, it support binary data. |
len | the size of request data. |
|
inline |
Set the request data of HttpRequest object.
buffer | the buffer of request data, it support binary data. |
len | the size of request data. |
|
inline |
Set request type of HttpRequest object before being sent,now it support the enum value of HttpRequest::Type.
type | the request type. |
|
inline |
Set request type of HttpRequest object before being sent,now it support the enum value of HttpRequest::Type.
type | the request type. |
|
inline |
Set the target and related callback selector.
When response come back, it would call (pTarget->*pSelector) to process something.
pTarget | the target object pointer. |
pSelector | the callback function. |
|
inline |
Set the target and related callback selector.
When response come back, it would call (pTarget->*pSelector) to process something.
pTarget | the target object pointer. |
pSelector | the callback function. |
|
inline |
Set the target and related callback selector of HttpRequest object.
When response come back, we would call (pTarget->*pSelector) to process response data.
pTarget | the target object pointer. |
pSelector | the SEL_HttpResponse function. |
|
inline |
Set the target and related callback selector of HttpRequest object.
When response come back, we would call (pTarget->*pSelector) to process response data.
pTarget | the target object pointer. |
pSelector | the SEL_HttpResponse function. |
|
inline |
Set response callback function of HttpRequest object.
When response come back, we would call _pCallback to process response data.
callback | the ccHttpRequestCallback function. |
|
inline |
Set response callback function of HttpRequest object.
When response come back, we would call _pCallback to process response data.
callback | the ccHttpRequestCallback function. |
|
inline |
Set a string tag to identify your request.
This tag can be found in HttpResponse->getHttpRequest->getTag().
tag | the string pointer |
|
inline |
Set a string tag to identify your request.
This tag can be found in HttpResponse->getHttpRequest->getTag().
tag | the string pointer |
|
inline |
Set the url address of HttpRequest object.
The url value could be like these: "http://httpbin.org/ip" or "https://httpbin.org/get"
url | the string pointer. |
|
inline |
Set the url address of HttpRequest object.
The url value could be like these: "http://httpbin.org/ip" or "https://httpbin.org/get"
url | the string pointer. |
|
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 manully.
pUserData | the string pointer |
|
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 manully.
pUserData | the string pointer |
|
protected |
You can add your customed data here.
|
protected |
You can add your customed data here.
|
protected |
callback function, e.g. MyLayer::onHttpResponse(HttpClient *sender, HttpResponse * response)
|
protected |
callback function, e.g. MyLayer::onHttpResponse(HttpClient *sender, HttpResponse * response)
|
protected |
callback target of pSelector function
|
protected |
callback target of pSelector function
|
protected |
user defined tag, to identify different requests in response callback
|
protected |
user defined tag, to identify different requests in response callback
|
protected |
C++11 style callbacks.
|
protected |
C++11 style callbacks.
|
protected |
target url that this request is sent to
|
protected |
target url that this request is sent to
|
protected |
|
protected |
|
protected |
used for POST
|
protected |
used for POST
|
protected |
kHttpRequestGet, kHttpRequestPost or other enums
|
protected |
kHttpRequestGet, kHttpRequestPost or other enums