mirror of https://github.com/axmolengine/axmol.git
fixed #1475, use vector::insert instead of vector::clear + assign in CCHttpClient::writeData, to prevent losing data
This commit is contained in:
parent
07f82af35e
commit
0cd3552ef7
|
@ -74,12 +74,10 @@ size_t writeData(void *ptr, size_t size, size_t nmemb, void *stream)
|
|||
{
|
||||
std::vector<char> *recvBuffer = (std::vector<char>*)stream;
|
||||
size_t sizes = size * nmemb;
|
||||
|
||||
recvBuffer->clear();
|
||||
// someone reported a bug of losting data potentially here
|
||||
// use recvBuffer->insert(recvBuffer->end(), (char*)ptr, (char*)ptr+sizes); can resolve.
|
||||
|
||||
recvBuffer->assign((char*)ptr, (char*)ptr + sizes);
|
||||
// add data to the end of recvBuffer
|
||||
// write data maybe called more than once in a single request
|
||||
recvBuffer->insert(recvBuffer->end(), (char*)ptr, (char*)ptr+sizes);
|
||||
|
||||
return sizes;
|
||||
}
|
||||
|
|
|
@ -55,6 +55,7 @@ public:
|
|||
/**
|
||||
* Add a get request to task queue
|
||||
* @param request a CCHttpRequest object, which includes url, response callback etc.
|
||||
please make sure request->_requestData is clear before calling "send" here.
|
||||
* @return NULL
|
||||
*/
|
||||
void send(CCHttpRequest* request);
|
||||
|
|
Loading…
Reference in New Issue