1
下面的代码(从现有的应用程序中提取):为什么在尝试使用http post时收到CURLE_URL_MALFORMAT?
CURL *curl = curl_easy_init();
_ASSERTE(curl);
string url = "http://127.0.0.1:8000/";
char *data = "mode=test";
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
curl_easy_setopt(curl, CURLOPT_URL, url);
CURLcode res = curl_easy_perform(curl);
bool success = (res == CURLE_OK);
curl_easy_cleanup(curl);
的res
值是CURLE_URL_MALFORMAT
。这个URL与curl不兼容?
m_checkUrl是什么类型的?您是否使用内联字符*进行了测试?即把“http://127.0.0.1:8000/”放在第三个参数中curl_easy_setopt? – 2009-12-01 18:06:12
该网址应该有一个http:前缀 – 2009-12-01 18:07:03
我更新了我的代码示例 - 我使用字符串而不是char * - 哎呀! – 2009-12-01 18:21:04