curl-library
Re: HEAD requests
Date: Fri, 23 Jan 2004 09:49:19 +0100 (CET)
On Thu, 22 Jan 2004, Mohit Kumar wrote:
> I no about this option however i am unaware as to how to use it. If u could
> give me a small example such as obtaining the Last Modified Date from a
> parcticuler resource of the net would certainly be useful.
Ok, this is written off the top of my head, but I think you'll understand the
principle anyway:
/* a little callback for the headers */
size_t headerfunc(void *ptr, size_t size, size_t nmemb, void *stream)
{
char *header = (char *)ptr;
time_t timing=0;
if(!strncmp("Last-Modified:", header, 14))
timing = curl_getdate(&header[14], NULL);
return size * nmemb;
}
... and you setup the header callback and a HEAD request like this:
/* we want the headers to this callback */
curl_easy_setopt(curl_handle, CURLOPT_HEADERFUNCTION, headerfunc);
/* use HEAD */
curl_easy_setopt(curl_handle, CURLOPT_NOBODY, TRUE);
I hope this helps!
-- Daniel Stenberg -- http://curl.haxx.se/ -- http://daniel.haxx.se/ [[ Do not send mails to this email address. They won't reach me. ]] ------------------------------------------------------- The SF.Net email is sponsored by EclipseCon 2004 Premiere Conference on Open Tools Development and Integration See the breadth of Eclipse activity. February 3-5 in Anaheim, CA. http://www.eclipsecon.org/osdnReceived on 2004-01-23