Cocos2d-x  v3.10
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Groups
HttpResponse Class Reference

A HttpResponse class is wrapped to the related responsed data came back from the HttpClient. More...

Inherits Ref.

Public Member Functions

 HttpResponse (HttpRequest *request)
 Constructor, it's used by HttpClient internal, users don't need to create HttpResponse manually. More...
 
virtual ~HttpResponse ()
 Destructor, it will be called in HttpClient internal. More...
 
cocos2d::Refautorelease (void)
 Override autorelease method to prevent developers from calling it. More...
 
HttpRequestgetHttpRequest ()
 Get the corresponding HttpRequest object which leads to this response. More...
 
bool isSucceed ()
 To see if the HttpReqeust is returned successfully. More...
 
var isSucceed ()
 To see if the HttpReqeust is returned successfully. More...
 
std::vector< char > * getResponseData ()
 Get the http response data. More...
 
var getResponseData ()
 Get the http response data. More...
 
std::vector< char > * getResponseHeader ()
 Get the response headers. More...
 
var getResponseHeader ()
 Get the response headers. More...
 
long getResponseCode ()
 Get the http response code to judge whether response is successful or not. More...
 
const char * getErrorBuffer ()
 Get the error buffer which will tell you more about the reason why http request failed. More...
 
var getErrorBuffer ()
 Get the error buffer which will tell you more about the reason why http request failed. More...
 
void setSucceed (bool value)
 Set whether the http request is returned successfully or not, This setter is mainly used in HttpClient, users mustn't set it directly the flag represent whether the http request is successful or not.
 
void setResponseData (std::vector< char > *data)
 Set the http response data buffer, it is used by HttpClient. More...
 
var setResponseData ( var data)
 Set the http response data buffer, it is used by HttpClient. More...
 
void setResponseHeader (std::vector< char > *data)
 Set the http response headers buffer, it is used by HttpClient. More...
 
var setResponseHeader ( var data)
 Set the http response headers buffer, it is used by HttpClient. More...
 
void setResponseCode (long value)
 Set the http response code. More...
 
void setErrorBuffer (const char *value)
 Set the error buffer which will tell you more the reason why http request failed. More...
 
void setResponseDataString (const char *value, size_t n)
 Set the response data by the string pointer and the defined size. More...
 
const char * getResponseDataString ()
 Get the string pointer that point to the response data. More...
 
- Public Member Functions inherited from Ref
void retain ()
 Retains the ownership. More...
 
local retain ()
 Retains the ownership. More...
 
void release ()
 Releases the ownership immediately. More...
 
Refautorelease ()
 Releases the ownership sometime soon automatically. More...
 
unsigned int getReferenceCount () const
 Returns the Ref's current reference count. More...
 
local getReferenceCount ()
 Returns the Ref's current reference count. More...
 
virtual ~Ref ()
 Destructor.
 

Additional Inherited Members

- Public Attributes inherited from Ref
unsigned int _ID
 object id, ScriptSupport need public _ID
 
local _ID
 object id, ScriptSupport need public _ID
 
int _luaID
 Lua reference id.
 
local _luaID
 Lua reference id.
 
void * _scriptObject
 scriptObject, support for swift
 
local _scriptObject
 scriptObject, support for swift
 
bool _rooted
 When true, it means that the object was already rooted.
 
local _rooted
 When true, it means that the object was already rooted.
 
bool _scriptOwned
 The life of the object is scrolled by the scripting engine. More...
 
local _scriptOwned
 The life of the object is scrolled by the scripting engine. More...
 

Detailed Description

A HttpResponse class is wrapped to the related responsed data came back from the HttpClient.

Constructor & Destructor Documentation

HttpResponse ( HttpRequest request)
inline

Constructor, it's used by HttpClient internal, users don't need to create HttpResponse manually.

the corresponding HttpRequest which leads to this response.

var HttpResponse ( var  request)
inline

Constructor, it's used by HttpClient internal, users don't need to create HttpResponse manually.

the corresponding HttpRequest which leads to this response.

virtual ~HttpResponse ( )
inlinevirtual

Destructor, it will be called in HttpClient internal.

Users don't need to destruct HttpResponse object manually.

var ~HttpResponse ( )
inlinevirtual

Destructor, it will be called in HttpClient internal.

Users don't need to destruct HttpResponse object manually.

Member Function Documentation

cocos2d::Ref* autorelease ( void  )
inline

Override autorelease method to prevent developers from calling it.

If this method is called , it would trigger CCASSERT. always return nullptr.

var autorelease (   )
inline

Override autorelease method to prevent developers from calling it.

If this method is called , it would trigger CCASSERT. always return nullptr.

HttpRequest* getHttpRequest ( )
inline

Get the corresponding HttpRequest object which leads to this response.

There's no paired setter for it, because it's already setted in class constructor. the corresponding HttpRequest object which leads to this response.

var getHttpRequest ( )
inline

Get the corresponding HttpRequest object which leads to this response.

There's no paired setter for it, because it's already setted in class constructor. the corresponding HttpRequest object which leads to this response.

bool isSucceed ( )
inline

To see if the HttpReqeust is returned successfully.

Althrough users can judge if (http response code == 200), we want an easier way. If this getter returns false, you can call getResponseCode and getErrorBuffer to find more details. bool the flag that represent whether the http request return sucesssfully or not.

var isSucceed ( )
inline

To see if the HttpReqeust is returned successfully.

Althrough users can judge if (http response code == 200), we want an easier way. If this getter returns false, you can call getResponseCode and getErrorBuffer to find more details. bool the flag that represent whether the http request return sucesssfully or not.

std::vector<char>* getResponseData ( )
inline

Get the http response data.

the pointer that point to the _responseData.

var getResponseData ( )
inline

Get the http response data.

the pointer that point to the _responseData.

std::vector<char>
* getResponseHeader
( )
inline

Get the response headers.

the pointer that point to the _responseHeader.

var getResponseHeader ( )
inline

Get the response headers.

the pointer that point to the _responseHeader.

long getResponseCode ( )
inline

Get the http response code to judge whether response is successful or not.

If _responseCode is not 200, you should check the meaning for _responseCode by the net. the value of _responseCode

var getResponseCode ( )
inline

Get the http response code to judge whether response is successful or not.

If _responseCode is not 200, you should check the meaning for _responseCode by the net. the value of _responseCode

const char* getErrorBuffer ( )
inline

Get the error buffer which will tell you more about the reason why http request failed.

the pointer that point to _errorBuffer.

var getErrorBuffer ( )
inline

Get the error buffer which will tell you more about the reason why http request failed.

the pointer that point to _errorBuffer.

void setResponseData ( std::vector< char > *  data)
inline

Set the http response data buffer, it is used by HttpClient.

the pointer point to the response data buffer.

var setResponseData ( var  data)
inline

Set the http response data buffer, it is used by HttpClient.

the pointer point to the response data buffer.

void setResponseHeader ( std::vector< char > *  data)
inline

Set the http response headers buffer, it is used by HttpClient.

the pointer point to the response headers buffer.

var setResponseHeader ( var  data)
inline

Set the http response headers buffer, it is used by HttpClient.

the pointer point to the response headers buffer.

void setResponseCode ( long  value)
inline

Set the http response code.

the http response code that represent whether the request is successful or not.

var setResponseCode ( var  value)
inline

Set the http response code.

the http response code that represent whether the request is successful or not.

void setErrorBuffer ( const char *  value)
inline

Set the error buffer which will tell you more the reason why http request failed.

a string pointer that point to the reason.

var setErrorBuffer ( var  value)
inline

Set the error buffer which will tell you more the reason why http request failed.

a string pointer that point to the reason.

void setResponseDataString ( const char *  value,
size_t  n 
)
inline

Set the response data by the string pointer and the defined size.

a string pointer that point to response data buffer. the defined size that the response data buffer would be copied.

var setResponseDataString ( var  value,
var  n 
)
inline

Set the response data by the string pointer and the defined size.

a string pointer that point to response data buffer. the defined size that the response data buffer would be copied.

const char* getResponseDataString ( )
inline

Get the string pointer that point to the response data.

the string pointer that point to the response data.

var getResponseDataString ( )
inline

Get the string pointer that point to the response data.

the string pointer that point to the response data.


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