cURL / Mailing Lists / curl-library / Single Mail

curl-library

return codes of curl_easy_getinfo()

From: Christian Vogt <christian.vogt_at_loewe-komp.de>
Date: Wed, 22 Aug 2007 13:28:12 +0200

Hi all,

I'd like to dicuss the behavior of the curl_easy_getinfo() routine,
because I've found out that its hard to get some information through the
API that is already available inside curl.

My application wants to validate some FTP URLs, i.e. check for the
presentce and size of files stored on an FTP server without downloading
them. Therefore I use the CURLOPT_NOBODY option and ask for the
CURLINFO_CONTENT_LENGTH_DOWNLOAD after the call to curl_easy_perform().

Now it turned out that this way, I can't distinguish between
a.) a file that is not present on the server, and
b.) a file that is there but has a size of 0 bytes.

In either case everything went well ( CURLE_OK from both
curl_easy_perform() and curl_easy_getinfo() ) and a file size of 0 is
returned.

Wouldn't it be good to give an indication to the caller of
curl_easy_getinfo() whether the requested information is internally
available or not? In progress.c I've seen that there are a couple of
flags available that carry that information.

I know that I could distinguish these cases if I look for the 'faked'
"content-length: %" output in my write callback, (if it appears, there
is a file with zero length. If not, the file is not found) but because
Daniel thought about "Kicking out the HTTP-like responses from FTP?", I
thought I should bring this topic to your attention.

Thanks & best regards,
   Christian
Received on 2007-08-22