RealGas RealGas - 3 months ago 23
C++ Question

CURLOPT_POSTFIELDS sends data with strange encoding?

This is what I get http://requestb.in/1kduz591?inspect

curl_easy_setopt(curl, CURLOPT_URL, "http://requestb.in/1kduz591");
curl_easy_setopt(curl, CURLOPT_REFERER, "http://requestb.in/1kduz591");
string data="abc";

curl_easy_setopt(curl,CURLOPT_POST,1);
curl_easy_setopt(curl,CURLOPT_POSTFIELDS,data);

Answer

CURLOPT_POSTFIELDS sends the data exactly as you pass to it, it doesn't translate, transcode or encode anything of it.

libcurl is a C API so you MUST provide the data as a plain char * and not a string. Use [string].c_str() or similar if you insist on using C++.