【发布时间】:2014-08-13 21:34:51
【问题描述】:
我正在尝试编写一个 c++ 程序,它使用 curl 库在 Red Hat Enterprise Virtualizatio (RHEV) 上执行操作(创建 VM 等)。我正在使用 CURL 处理程序来执行发布操作(创建 VM)。
CURL *curl;
struct curl_slist *headers=NULL; // init to NULL is important
curl_slist_append(headers, "Accept: application/xml");
curl_slist_append( headers, "Content-Type: application/xml");
/* get a curl handle */
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
但是当我运行这段代码时,我得到了
HTTP Status 415 - Cannot consume content type
Cannot consume content type
The server refused this request because the request entity is in a format not supported by the requested resource for the requested method.
即使我将内容类型设置为 xml,我也检查了调试器
0087: Accept: */*
0094: Content-Length: 173
00a9: Content-Type: application/x-www-form-urlencoded
有人可以帮我弄清楚发生了什么吗?非常感谢!
【问题讨论】:
-
@leemes 谢谢你,这真的很有帮助。