curl-library
Re: Response head is not retrievable
Date: Thu, 03 Apr 2008 10:35:33 +0400
Nikolai Kondrashov wrote:
> int
> main(int argc, char **argv)
> {
> CURL *curl = NULL;
>
> #ifndef SHOW_BUG
> FILE *data_file = NULL;
>
> data_file = fopen("/dev/null", "w");
>
> curl = curl_easy_init();
Uh, of course the above line should be before #ifndef SHOW_BUG. Sorry.
I.e. the full listing should be this:
---:<---
#include <stdio.h>
#include <curl/curl.h>
#define SHOW_BUG
#ifdef SHOW_BUG
size_t
write_cb(void *ptr, size_t size, size_t nmemb, void *stream)
{
(void)ptr;
(void)stream;
return nmemb * size;
}
#endif
int
main(int argc, char **argv)
{
CURL *curl = NULL;
curl = curl_easy_init();
#ifndef SHOW_BUG
FILE *data_file = NULL;
data_file = fopen("/dev/null", "w");
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, data_file);
#else
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_cb);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, NULL);
#endif
curl_easy_setopt(curl, CURLOPT_HEADERDATA, stdout);
curl_easy_setopt(curl, CURLOPT_URL, "http://www.google.com/");
curl_easy_perform(curl);
curl_easy_cleanup(curl);
#ifndef SHOW_BUG
fclose(data_file);
#endif
return 0;
}
--->:---
Sincerely,
Nick
Received on 2008-04-03