cURL / Mailing Lists / curl-library / Single Mail

curl-library

RE: Unable to retrieve some document header

From: Yanick Pelletier <ypelletier_at_copernic.com>
Date: Mon, 15 Oct 2001 09:02:00 -0400

Hum. Your solution work since i have already test it, but my biggest
problem it to ask the server for a document that a don't really want, it for
this reason that the HEAD command exist. So does it is possible for curl to
check the result of the HEAD command to see if an header is returned, if no
header is found it can send the GET command to retrieve it.

-----Original Message-----
From: Daniel Stenberg [mailto:daniel_at_haxx.se]
Sent: Monday, October 15, 2001 4:20 AM
To: Yanick Pelletier
Cc: libcurl Mailing list
Subject: Re: Unable to retrieve some document header

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