Curlpp, incomplete data from request Curlpp, incomplete data from request curl curl

Curlpp, incomplete data from request


The problem with the code is that the data is put into a std::string, despite having the data in binary (ZIP) format. I'd recommend to put the data into a stream (or a binary array).You can also register a callback to retrieve the response headers and act in the WriteCallback according to the "Content-type".

curlpp::options::HeaderFunction to register a callback to retrieve response-headers.


std::string is not a problem, but the concatenation is:

requestData += ptr;

C string (ptr) is terminated with zero, if the input contains any zero bytes, the input will be truncated. You should wrap it into a string which knows the length of its data:

requestData += std::string(ptr, size*nmemb);