cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: How to get the file size, prior to downloading it.

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Sun, 12 May 2002 17:08:05 +0200 (MET DST)

On Fri, 10 May 2002, Javi Montesa-Andres wrote:

> I want to download one of the files that are compressed in a ZIP file that
> is on the http server, without downloading the entire file.
>
> To do that I need to read de Central Directory of the ZIP file that is the
> list of files in the ZIP and the position where you can find them. The
> central directory is at the end of the file, does anyone know how to get
> the file size in order to get the last part of it?

Set CURLOPT_NOBODY to TRUE (makes a 'HEAD' request in HTTP).

Set CURLOPT_HEADER to TRUE if you want the headers passed to the normal data
write callback. Otherwise you can just use the header callback.

Then, when you know the size, you can use CURLOPT_RANGE to attempt to only
get a specified piece of the file.

-- 
    Daniel Stenberg -- curl groks URLs -- http://curl.haxx.se/
_______________________________________________________________
Have big pipes? SourceForge.net is looking for download mirrors. We supply
the hardware. You get the recognition. Email Us: bandwidth_at_sourceforge.net
Received on 2002-05-12