cURL / Mailing Lists / curl-library / Single Mail

curl-library

different "maxdownload" solutions

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Thu, 11 Oct 2001 08:21:47 +0200 (MET DST)

Hi Lucas

I've been thinking about your wish to see CURLOPT_MAXDOWNLOAD incorporated
into libcurl. While I understand your request, I hesitate to actually add
this. It is very specialised and I don't think that very many people will
ever find a use for it.

Instead I've been thinking about other, more generic, ways that you could
achive the same goal: cut off larger downloads at a certain point.

1. You can just return from the WRITEFUNCTION with a value that causes
   libcurl to abort. You will get an error returned from perform(), but you'd
   know when you caused this error so you could treat the error as OK when
   this happens.

2. Similar to the approach above, you can use the PROGRESSFUNCTION callback
   as that will get repeated calls with download info, and returning a
   non-zero value back when you think enough has been downloaded will cause
   perform() to return CURLE_ABORTED_BY_CALLBACK. That too is easily handled
   by your code.

Both these solutions are far better in my eyes, as they can be made without
changes to libcurl. Of course, if you can come up with other solutions I'm
all ears. I just don't like adding very odd specific cases into the generic
library code.

-- 
    Daniel Stenberg -- curl groks URLs -- http://curl.haxx.se/
Received on 2001-10-11