LibCurl似乎逃脱了我的POSTFIELDS
LibCurl seems to escape my POSTFIELDS
我使用此代码将json发布到服务器:
但CURL似乎在某种程度上逃脱了数据,即将其转换为"{\"电子邮件\":\"test@example.se\"}"(使我的引号转义)。我认为curl发布的内容类型仍然是"application/x-www-form-urlencoded",即使是你,我也在标题中用application/json覆盖了它。我怎么能让卷发不那样做?
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(curl, CURLOPT_POST, 1L);
const std::string& data = "{"email":"test@example.se"}";
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data.c_str() );
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, data.size() );
// Headers
curl_easy_setopt(headers, "Content-Type: application/json");
curl_easy_setopt(headers, "Authorization: Basic: something:something");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_perform(curl);
从这里开始:http://curl.haxx.se/libcurl/c/CURLOPT_POSTFIELDS.html
libcurl不会以任何方式为您转换或编码它。
指向的数据不会被库复制:因此,它必须由调用应用程序保留,直到相关的传输完成。
你确定你在遵守这些通知吗?
相关文章:
- 我的神经网络不起作用 [XOR 问题]
- C++我的数学有什么问题,为什么我的代码不能正确循环
- 我的字符计数代码计算错误.为什么
- 为什么我的C#代码在调用回C++COM直到Task时会暂停.等待/线程.加入
- cmake在我的项目中所需的所有静态库都不成功
- 为什么我的代码在输出中增加了93天
- 我的简单if-else语句是如何无法访问的代码
- 为什么我的for循环不能正确获取argv
- 我的项目不会像"undefined reference to `grpc::g_core_codegen_interface'"那样使用未定义的引用错误进行编译
- 0-1背包代码中的错误.我的代码中有什么错误
- 当我的阵列太大时出现分段错误
- 如何确认我的constexpr表达式实际上已经在编译时执行
- 为什么二进制搜索在我的测试中不起作用
- 如何指定我希望我的LIB链接到的DLL文件?-Visual Studio 2019
- 我的代码中有错误吗?使用BGI图形的C++代码对我不起作用
- 当我在main中声明了我的2d数组时,为什么我的程序会退出
- OpenGL在启用深度测试时不会丢弃我的碎片
- 为什么我的 std::ref 无法按预期工作?
- clang整洁10忽略了我的NOLINT命令
- LibCurl似乎逃脱了我的POSTFIELDS