curl-library
RE: Problems with Http download under windows
Date: Mon, 30 Jun 2008 12:30:09 -0700
Loic Quertenmont wrote:
>
> Maybe Libcurl will guarantee that this works across all platforms, and
not
> just linux.
> But when I do this on windows it just crashes :
>
> FILE * fp = fopen(out_file, "wb"); // also with option "w" it
> crashes
> curl_easy_setopt(session, CURLOPT_WRITEDATA, fp);
> curl_easy_setopt(session, CURLOPT_WRITEFUNCTION, NULL);
> curl_easy_perform(session);
> fclose(fp);
>
> So maybe my way, will maybe confuse future maintainers of your code...
> But it is the only way that doesn't crashes.
>
Please don't top post.
The following code works fine for me, without crashing, using libcurl
7.17.0 and MS DevStudio 2003, so I can't explain why yours crashes. More
details on the libcurl version and build tools you are using would be
helpful.
CURL *session = curl_easy_init( );
CURLcode cStatus;
FILE * fp = fopen("foobar.txt", "wb");
cStatus = curl_easy_setopt(session, CURLOPT_WRITEDATA, fp);
cStatus = curl_easy_setopt(session, CURLOPT_WRITEFUNCTION, NULL);
cStatus = curl_easy_setopt(session, CURLOPT_URL, "http://cool.haxx.se/"
);
cStatus = curl_easy_perform(session);
curl_easy_cleanup(session);
fclose(fp);
Cheers,
-Gary
Received on 2008-06-30