cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Total file length

From: Johan Nilsson <johan_at_nnl.se>
Date: Mon, 11 Dec 2000 15:15:16 +0100

Thanks for the speedy reply!

Daniel Stenberg wrote:

> On Mon, 11 Dec 2000, Johan Nilsson wrote:
>
> > How can I find out the files total length (when starting to download,
> > i.e. after the first response) using the easy interface without having to
> > use a progress function?
>
> You can't.

Just as I thought!

>
>
> I could imagine adding a separate function or some option to
> curl_easy_getinfo() that could get that ability. Or perhaps it would be even
> better to add a separate function to use for querying the library during
> operations (as curl_easy_getinfo() is otherwise only to be used after
> transfers are done).
>
> The problem is that we don't necessary know the size and we can't really tell
> when we'll know it. Theoretically, from a very slow or loaded server sending
> lots of headers, we could wait a long time for the length to get known and
> the write function can be called numerous times before that.
>
> > I don't want to parse any headers and I saw that this information was
> > sent as an argument to the progress function.
>
> Consider it an information I thought mostly was interestin for progress
> information,

I will use file length (if it is reported by the server) for progress information
and for checking if there's enough disk space left on the HD.

>
>
> > I use a write function of my own and I wouldn't need to use the progress
> > function if it wheren't for that feature.
>
> Adding a progress function is a very minor thing, and if you pass a struct
> you define you could set it as soon as the information is there and then your
> program would get to know...

That is exactly what I'm doing. I pass an object as a parameter for the progress
function and as soon as the file length is known I tell the object the file
length.
I was however a little bit afraid that you were going to remove the progress
function (?) as stated in the documentation. I consider the file to be of unknown
size as long as dltotal is 0.

>
>
> Of course I need people's views on this!

Another question: Is it only possible to abort a transfer by returning anything
but 0 from the progress function? This means that if a request takes a long time
it is not possible to abort the transfer until a progresscallback or the request
has timed out.

I think the easy interface is great! It didn't take long to figure it out! Great
work!

//Johan

--
| Johan Nilsson, M.Sc. in C.S.E., johan_at_nnl.se
| NNL Technology AB, http://www.nnl.se
| Phone: +46 (0)13 211400
| Mobile: +46 (0)70 9634472
| Address: Teknikringen 1B, S-58330 Linköping, SWEDEN
_______________________________________________
Curl-library mailing list
Curl-library_at_lists.sourceforge.net
http://lists.sourceforge.net/mailman/listinfo/curl-library
Received on 2000-12-11