curl-library
Problem with CURLOPT_FILETIME
Date: Mon, 12 Nov 2007 14:39:20 -0800
Please excuse me if this an elementary question as I've just begun using
libcurl. I've read all the documentation and example programs that I
can find
and have not been able to get my program to work as I'd like.
Basically I'd like to poll a web server to see if a file has been
updated
since the last time I downloaded it. I'm trying to use the
"CURLOPT_FILETIME"
function for this and cannot get it to work.
I'm using libcurl.so.3.0.0 on a RedHat 5.0.0 system.
Here's my test program:
int main(int argc, char **argv)
{
CURL *curl_handle;
time_t fileTime = 1;
curl_global_init(CURL_GLOBAL_ALL);
curl_handle = curl_easy_init();
curl_easy_setopt(curl_handle, CURLOPT_URL, "http://curl.haxx.se"
);
curl_easy_setopt(curl_handle, CURLOPT_NOBODY, 1 );
curl_easy_setopt(curl_handle, CURLOPT_FILETIME, &fileTime );
curl_easy_perform(curl_handle);
printf ( "Got file time %d - %s\n", fileTime, ctime(&fileTime));
curl_easy_cleanup(curl_handle);
return 0;
}
No matter what I do, it does not appear to update my fileTime variable.
I
always get:
% curlTest
Got file time 1 - Wed Dec 31 16:00:01 1969
I've checked the return status on all of the calls (omitted here for
clarity)
and none of the functions are returning any errors. I've also tried it
on a
variety of web servers including our own in-house server and they all
behave
the same way.
When I download the header and body of one of these locations the header
looks something like:
HTTP/1.1 200 OK
Date: Mon, 12 Nov 2007 21:38:10 GMT
Server: Apache/2.2.4 (Unix) mod_ssl/2.2.4 OpenSSL/0.9.8b
Last-Modified: Mon, 12 Nov 2007 21:04:34 GMT
ETag: "24cec5-24ec5b-ade63c80"
Accept-Ranges: bytes
Content-Length: 2419803
Content-Type: text/plain
which contains a "Last-Modified" date.
What am I doing wrong?
TIA!
Don
Received on 2007-11-12