cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: http HEAD reuest

From: Linus Nielsen Feltzing <linus_at_haxx.se>
Date: Wed, 03 Oct 2007 15:43:10 +0200

Nishantha Pradeep wrote:
> I am going to use libcurl for my project and compiled a given programe
> which brings the http header and associated file as well.But i want to
> get the http header only (send the http HEAD request).is there any api
> can be used in libcurl.(My project is writen in c language)
> thanks

Combine the CURLOPT_HEADER and CURLOPT_NOBODY options and voila!

A small test program that works:

#include <curl/curl.h>

int main(int argc, char *argv[])
{
   CURLcode ret;
   CURL *hnd = curl_easy_init();
   curl_easy_setopt(hnd, CURLOPT_URL, "http://www.haxx.se");
   curl_easy_setopt(hnd, CURLOPT_HEADER, 1);
   curl_easy_setopt(hnd, CURLOPT_NOBODY, 1);
   ret = curl_easy_perform(hnd);
   curl_easy_cleanup(hnd);
}

Linus
Received on 2007-10-03