diff --git a/extensions/network/HttpClient.cpp b/extensions/network/HttpClient.cpp index bde526ed21..c35126d856 100644 --- a/extensions/network/HttpClient.cpp +++ b/extensions/network/HttpClient.cpp @@ -74,12 +74,10 @@ size_t writeData(void *ptr, size_t size, size_t nmemb, void *stream) { std::vector *recvBuffer = (std::vector*)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; } diff --git a/extensions/network/HttpClient.h b/extensions/network/HttpClient.h index 67b91ebaf0..c63d32042a 100644 --- a/extensions/network/HttpClient.h +++ b/extensions/network/HttpClient.h @@ -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);