使用libCurl POST添加未知的页眉和页脚
Using libCurl to POST adds unknown header and footer
我使用libCurl在c++中使一个xml文件的POST请求到我的服务器。后工作,我收到我的服务器上的xml。然而,xml也有一个奇怪的头&xml:
页脚------------------------------b6966127f870Content-Disposition: form-data; name="myName"; filename="myFile.xml"Content-Type: application/xml<CORRECT XML FILE HERE>------------------------------b6966127f870--
这个页眉/页脚是什么?
我可以摆脱它吗?或者我应该对它进行解析?
是curl添加这些吗?
下面是我用来发布xml文件的相关curl调用。
void CurlUtils::postFileToURL(const char* const inFile,
const char* const urlString)
{
// Setup
CURL* const curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
// Post
struct curl_httppost* post = NULL;
struct curl_httppost* last = NULL;
curl_formadd(&post, &last,
CURLFORM_COPYNAME, "myName",
CURLFORM_FILE, inFile,
CURLFORM_END);
curl_easy_setopt(curl, CURLOPT_URL, urlString);
curl_easy_setopt(curl, CURLOPT_HTTPPOST, post);
curl_easy_perform(curl);
// Cleanup ...
}
您使用的是CURLOPT_HTTPPOST
,它使多部分表单post到服务器。多部分formpost是一系列带有MIME样式分隔符的部分,每个部分都有一组标题,正如您在这里看到的。
如果你想要一个普通的POST,没有多部分的东西,使用CURLOPT_POSTFIELDS
或设置一个读回调,使用CURLOPT_POST
。
相关文章:
- 继承期间显示未知行为的子类
- 输入中的字符串数未知(以字母表示)
- 发送一个带有libcurl C++问题的帖子请求:s
- 具有未知值时的时间复杂性
- 链表中写入访问冲突的未知原因
- 正在生成未知类实例
- Bjarne Stroustrup Book - std_lib_facilities.h - 不起作用(未知类型名称)
- 读取文件时运行时的未知行为
- 使用libcurl提交批量url的正确BING Api POST url是什么
- 代码在我的计算机上运行良好,但是在将其提交给coursera时遇到未知的信号11问题
- 在 libcurl 连接池中预创建连接
- 初始化多个未知基类
- libcurl 和 DNS ttl 中的内部连接管理
- 如何在 cmake 库中包含 libcurl
- 使用 make 编译 MPI,几个命名空间错误,例如"错误:未知类型名称'使用'?
- 如何应用 libcurl 的持久连接选项
- VS 2015 链接错误 无法构建依赖于 libcurl 的项目
- 如何存储未知次数迭代的输入?
- 组合字符串不适用于 libCurl,C++
- 使用libCurl POST添加未知的页眉和页脚