网络 - C++使用libcurl下载文件,传入url失败?CURLE_URL_MALFORMAT
阿神
阿神 2017-04-17 14:29:26
[C++讨论组]
...
//get url by parsing xml using rapidxml 
char* url  =  root->first_node("MFC_uri")->value(); //http://xx.com/xx.bin 
printf(url ); //http://xx.com/xx.bin
char outfilename[FILENAME_MAX] = "mfc.bin"

curl = curl_easy_init();
if (curl) 
{
    fp = fopen(outfilename,"wb");
    //curl_easy_setopt(curl, CURLOPT_URL, "http://xx.com/xx.bin"); //OK
    curl_easy_setopt(curl, CURLOPT_URL,url); //NG 
    
    printf(url); //http://xx.com/xx.bin
    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
    curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
    
    res = curl_easy_perform(curl);  //CURLE_URL_MALFORMAT == 3
    printf("res code %d",res);
    /* always cleanup */
    curl_easy_cleanup(curl);
    fclose(fp);
    printf("done \n");
}
....

直接传入url没有问题,能够正常下载,
但是通过rapidxml,解析xml文件获取url,然后传入url,则不能下载,执行结果CURLE_URL_MALFORMAT,
c++菜鸟,强行上战场,求指教.

*******
自己的锅,解析别人给的xml的时候没有忽略换行符,搞了这么久,居然是这个原因....已经解决了,谢谢SF
*******
阿神
阿神

闭关修行中......

全部回复(0)
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号