cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Only receive a header file

From: Justin Skists <j.skists_at_googlemail.com>
Date: Thu, 4 Mar 2010 16:24:32 +0000

On 4 March 2010 00:13, dylan <glethro_at_gmail.com> wrote:

> Hello,
> I'm working on a small program that needs to know the size of a file before
> it is downloaded via HTTP. The header file for these files does contain
> this information, so i was wondering if it is possible to only receive the
> header without the rest of the data.
>
> If so, how is that done?
>
>
>
Use the CURLOPT_NOBODY option for curl_easy_setopt, to create a HEAD request
instead of a GET, to return just the headers.

Or, since headers usually come in before the data, you could read the
Content-Length header (through CURLOPT_HEADERFUNCTION) and act on it before
the data arrives (though CURLOPT_WRITEFUNCTION)? (Not 100% cetain that will
be the case)

Justin.

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-03-04