cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Unable to retrieve some document header

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Mon, 15 Oct 2001 10:20:19 +0200 (MET DST)

On Fri, 12 Oct 2001, Yanick Pelletier wrote:

(I reply on your libcurl post, as it sounds as if you're using the library.)

> I'm trying to retrieve the header for a web page without downloading the
> document body, so i set the option CGLOPT_NOBODY.

Eh, I assume you mean CURLOPT_NOBODY here?

> I correctly recieve the header when i pass a direct URL (ex:
> http://www.microsoft.com <http://www.microsoft.com/> ) but when a gives
> an URL that is redirected (like http://www.yahoo.com/r/fi
> <http://www.yahoo.com/r/fi> ) i don't recieve any header at all until i
> download the body of the document.

Gosh. That web server is not behaving.

The option CURLOPT_NOBODY will make curl use a "command" that only requests
the headers. For HTTP that command is named HEAD, and obviosly this server
does not respond very nicely to that kind of request.

This is not really curl's fault and there's nothing we can do about it. The
only thing you can do, is to do a normal request with CURLOPT_HEADER set (or
simimilar) and then stop reading as soon as the headers have been received.

> Does any buddy know a work around this problem since i relly don't want
> to download the body of the document only to retrieve its header!

You can stop the transfer from within your callback.

-- 
    Daniel Stenberg -- curl groks URLs -- http://curl.haxx.se/
Received on 2001-10-15