如何解决libcurl简单C文件下载器示例立即返回
我尝试编译有关此问题的两个示例:Download file using libcurl in C/C++
这里是其中之一:
if role == 1:
doctor_group = Group.objects.get(name='Doctor')
reg.groups.add(doctor_group)
return redirect('register_user')
elif role == 2:
nurse_group = Group.objects.get(name='Nurse')
reg.groups.add(nurse_group)
return redirect('register_user')
问题在于,此示例在运行时立即返回,并且我得到一个空白文件。为什么?我修改为
#include <stdio.h>
#include <curl/curl.h>
int main(void)
{
CURL *curl;
FILE *fp;
CURLcode res;
char *url = "http://stackoverflow.com";
char outfilename[FILENAME_MAX] = "page.html";
curl = curl_easy_init();
if (curl)
{
fp = fopen(outfilename,"wb");
curl_easy_setopt(curl,CURLOPT_URL,url);
curl_easy_setopt(curl,CURLOPT_WRITEFUNCTION,NULL);
curl_easy_setopt(curl,CURLOPT_WRITEDATA,fp);
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
fclose(fp);
}
return 0;
}
但是我没有看到错误。我尝试使用C ++和C进行编译,但两者却得到相同的结果。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。