defines the object which users will receive at onHttpCompleted(sender, HttpResponse) callback.
More...
#include <HttpResponse.h>
|
| 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::Ref * | autorelease (void) |
| Override autorelease method to prevent developers from calling it. More...
|
|
HttpRequest * | getHttpRequest () |
| Get the corresponding HttpRequest object which leads to this response. More...
|
|
bool | isSucceed () |
| To see if the http reqeust is returned successfully. More...
|
|
var | isSucceed () |
| To see if the http reqeust is returned successfully. More...
|
|
std::vector< char > * | getResponseData () |
| Get the http response data. More...
|
|
std::vector< char > * | getResponseHeader () |
| Get the response headers. More...
|
|
long | getResponseCode () |
| Get the http response code to judge whether response is sucessful or not. More...
|
|
const char * | getErrorBuffer () |
| Get the rror 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. More...
|
|
void | setResponseData (std::vector< char > *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...
|
|
var | setErrorBuffer ( var 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...
|
|
var | setResponseDataString ( var value, var 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...
|
|
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...
|
|
defines the object which users will receive at onHttpCompleted(sender, HttpResponse) callback.
Please refer to samples/TestCpp/Classes/ExtensionTest/NetworkTest/HttpClientTest.cpp as a sample.
- Since
- v2.0.2.
Constructor, it's used by HttpClient internal, users don't need to create HttpResponse manually.
- Parameters
-
request | the corresponding HttpRequest which leads to this response. |
Constructor, it's used by HttpClient internal, users don't need to create HttpResponse manually.
- Parameters
-
request | the corresponding HttpRequest which leads to this response. |
Destructor, it will be called in HttpClient internal.
Users don't need to desturct HttpResponse object manully.
Destructor, it will be called in HttpClient internal.
Users don't need to desturct HttpResponse object manully.
Override autorelease method to prevent developers from calling it.
If this method is called , it would trigger CCASSERT.
- Returns
- cocos2d::Ref* always return nullptr.
Override autorelease method to prevent developers from calling it.
If this method is called , it would trigger CCASSERT.
- Returns
- cocos2d::Ref* always return nullptr.
const char* getErrorBuffer |
( |
| ) |
|
|
inline |
Get the rror buffer which will tell you more about the reason why http request failed.
- Returns
- const char* the pointer that point to _errorBuffer.
Get the rror buffer which will tell you more about the reason why http request failed.
- Returns
- const char* the pointer that point to _errorBuffer.
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
- Returns
- HttpRequest* the corresponding HttpRequest object which leads to this response.
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
- Returns
- HttpRequest* the corresponding HttpRequest object which leads to this response.
Get the http response code to judge whether response is sucessful or not.
I know that you want to see the _responseCode is 200. If _responseCode is not 200, you should check the meaning for _responseCode by the net.
- Returns
- long the value of _responseCode
Get the http response code to judge whether response is sucessful or not.
I know that you want to see the _responseCode is 200. If _responseCode is not 200, you should check the meaning for _responseCode by the net.
- Returns
- long the value of _responseCode
std::vector<char>* getResponseData |
( |
| ) |
|
|
inline |
Get the http response data.
- Returns
- std::vector<char>* the pointer that point to the _responseData.
Get the http response data.
- Returns
- std::vector<char>* the pointer that point to the _responseData.
const char* getResponseDataString |
( |
| ) |
|
|
inline |
Get the string pointer that point to the response data.
- Returns
- const char* the string pointer that point to the response data.
var getResponseDataString |
( |
| ) |
|
|
inline |
Get the string pointer that point to the response data.
- Returns
- const char* the string pointer that point to the response data.
std::vector<char>
* getResponseHeader |
( |
| ) |
|
|
inline |
Get the response headers.
- Returns
- std::vector<char>* the pointer that point to the _responseHeader.
var getResponseHeader |
( |
| ) |
|
|
inline |
Get the response headers.
- Returns
- std::vector<char>* the pointer that point to the _responseHeader.
var initWithRequest |
( |
var |
request | ) |
|
|
protected |
To see if the http reqeust 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.
- Returns
- bool the flag that represent whether the http request return sucesssfully or not.
To see if the http reqeust 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.
- Returns
- bool the flag that represent whether the http request return sucesssfully or not.
void setErrorBuffer |
( |
const char * |
value | ) |
|
|
inline |
Set the error buffer which will tell you more the reason why http request failed.
- Parameters
-
value | 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.
- Parameters
-
value | a string pointer that point to the reason. |
void setResponseCode |
( |
long |
value | ) |
|
|
inline |
Set the http response code.
- Parameters
-
value | the http response code that represent whether the request is successful or not. |
var setResponseCode |
( |
var |
value | ) |
|
|
inline |
Set the http response code.
- Parameters
-
value | the http response code that represent whether the request is successful or not. |
void setResponseData |
( |
std::vector< char > * |
data | ) |
|
|
inline |
Set the http response data buffer, it is used by HttpClient.
- Parameters
-
data | the pointer point to the response data buffer. |
var setResponseData |
( |
var |
data | ) |
|
|
inline |
Set the http response data buffer, it is used by HttpClient.
- Parameters
-
data | the pointer point to the response data buffer. |
void setResponseDataString |
( |
const char * |
value, |
|
|
size_t |
n |
|
) |
| |
|
inline |
Set the response data by the string pointer and the defined size.
- Parameters
-
value | a string pointer that point to response data buffer. |
n | 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.
- Parameters
-
value | a string pointer that point to response data buffer. |
n | the defined size that the response data buffer would be copied. |
void setResponseHeader |
( |
std::vector< char > * |
data | ) |
|
|
inline |
Set the http response headers buffer, it is used by HttpClient.
- Parameters
-
data | the pointer point to the response headers buffer. |
var setResponseHeader |
( |
var |
data | ) |
|
|
inline |
Set the http response headers buffer, it is used by HttpClient.
- Parameters
-
data | the pointer point to the response headers buffer. |
void setSucceed |
( |
bool |
value | ) |
|
|
inline |
Set whether the http request is returned successfully or not, This setter is mainly used in HttpClient, users mustn't set it directly.
- Parameters
-
value | the flag represent whether the http request is successful or not. |
var setSucceed |
( |
var |
value | ) |
|
|
inline |
Set whether the http request is returned successfully or not, This setter is mainly used in HttpClient, users mustn't set it directly.
- Parameters
-
value | the flag represent whether the http request is successful or not. |
the status code returned from libcurl, e.g. 200, 404
the status code returned from libcurl, e.g. 200, 404
the returned raw header data. You can also dump it as a string
the returned raw header data. You can also dump it as a string
std::vector<char> _responseData |
|
protected |
to indecate if the http reqeust is successful simply
to indecate if the http reqeust is successful simply
std::string _responseDataString |
|
protected |
if _responseCode != 200, please read _errorBuffer to find the reason
if _responseCode != 200, please read _errorBuffer to find the reason
std::vector<char> _responseHeader |
|
protected |
the returned raw data. You can also dump it as a string
the returned raw data. You can also dump it as a string
the corresponding HttpRequest pointer who leads to this response
the corresponding HttpRequest pointer who leads to this response
The documentation for this class was generated from the following file: