cURL / Mailing Lists / curl-library / Single Mail


Response head is not retrievable

From: Nikolai Kondrashov <>
Date: Thu, 03 Apr 2008 10:17:31 +0400

Hello All,

It seems that response head cannot be retrieved if custom function is used
to retrieve the body. At least with 7.18.0. Assigning a custom head
retrieval function doesn't help.

We cannot use HEAD method, because we need a POST response head, but don't
need the body. Currently, I'm simply sending the body to /dev/null, but it
is inconvenient and non-portable. If this is the way it should work, then it
should be mentioned in the documentation.

Below is a demonstration:
#include <stdio.h>
#include <curl/curl.h>

#define SHOW_BUG

#ifdef SHOW_BUG
write_cb(void *ptr, size_t size, size_t nmemb, void *stream)

     return nmemb * size;

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();

     curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL);
     curl_easy_setopt(curl, CURLOPT_WRITEDATA, data_file);
     curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_cb);
     curl_easy_setopt(curl, CURLOPT_WRITEDATA, NULL);

     curl_easy_setopt(curl, CURLOPT_HEADERDATA, stdout);

     curl_easy_setopt(curl, CURLOPT_URL, "");


#ifndef SHOW_BUG

     return 0;

I'm sorry if this bug is already known or even fixed. I wasn't able to find
it in your bug tracker and do not dare to break my environment by installing
the latest libcurl.

Received on 2008-04-03