curl-library
Re: return codes of curl_easy_getinfo()
Date: Fri, 24 Aug 2007 09:51:46 +0200
on 8/22/2007 11:33 PM, Daniel Stenberg wrote:
> On Wed, 22 Aug 2007, Christian Vogt wrote:
>
>> 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.
>
> Yes, I think it would be useful for applications to be able to know
> which of the cases it is.
>
> Any suggestions on how they could work to make it nice?
>
Well, the user might get an error code from curl_easy_getinfo() when
asking for information that could not be collected during the last
transfer. CURLE_GOT_NOTHING may be a candidate for this, or you define a
new one.
However, this may require some more work, because from what I've seen,
the availability flags will be set according to the given values in
progress.c :
~~~~~~~~~~~~~~~~~
void Curl_pgrsSetDownloadSize(struct SessionHandle *data, curl_off_t size)
{
data->progress.size_dl = size;
if(size > 0)
data->progress.flags |= PGRS_DL_SIZE_KNOWN;
else
data->progress.flags &= ~PGRS_DL_SIZE_KNOWN;
}
~~~~~~~~~~~~~~~~~
So at the moment, it is not possible to say "we know the download size
and it is zero". Most probably, similar things apply to the gathering of
other information too.
Because this would be a change of the user interface, I guess it is
something for the next SO number increment.
Cheers,
Christian
Received on 2007-08-24