cURL / Mailing Lists / curl-library / Single Mail

curl-library

Stating remote files

From: Rafael Fernández López <ereslibre_at_gmail.com>
Date: Tue, 2 Jun 2009 21:12:43 +0200

Hi there,

I am trying to 'stat' remote files in the sense of getting the size of the
file, also the timestamp and so on. Obviously, my approach has been to set
CURLOPT_NOBODY to 1L. I also use the return from curl_easy_perform() to
determine whether everything went fine (CURLE_OK), I need a login
(CURLE_LOGIN_DENIED), or file could not be found:
CURLE_FTP_COULDNT_RETR_FILE or CURLE_REMOTE_FILE_NOT_FOUND.

I have found that when a file does not exist and I ask for it with
CURLOPT_NOBODY set on the handle, CURLE_OK is returned. I have been thinking
of ways to bypass this: like writing a callback a bit smarter, which will
for example only download the first 1 or 4 bytes, and letting CURLOPT_NOBODY
as default.

I wonder if this return code (CURLE_OK) when CURLOPT_NOBODY is set to 1L and
the file does not exist is a bug, or is this the expected behavior.

I am attaching a libcurl example modified to show this example.

Regards,
Rafael Fernández López.

Received on 2009-06-02