cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Control the download

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Thu, 22 Sep 2011 14:27:30 +0200 (CEST)

On Wed, 21 Sep 2011, Yoav Einav wrote:

> I was wondering how can I change the GET request behavior, so I'll have
> control of the response -
>
> let's say for example:
>
> 1. Example 1: getting the file in chunks of 100KB (chunk by chunk).

You can't. libcurl will deliver data as it thinks is good and you'll have to
adapt. If you need to wait for 100K before you can do anything, then just
buffer data until you have enough!

> 2. Example 2: getting 1MB as fast as possible, and then continue in a given
> download rate.

You can easily create your own bandwidth throtteling exactly how you want it
done, so yes.

> . I've seen in the code the CURL_MAX_WRITE_SIZE MACRO (in curl.h header
> file) that calls the maximum amount of data that can be passed to the write
> callback.

Yes, but that's a build-time limit and it is only a maximum amount - you will
never get any guarantees about the minimum size it can pass on.

> Also using the CURLOPT_MAX_RECV_SPEED_LARGE option to control the average
> download rate

Implement your own by sleeping in the callback or pausing handles if the
built-in isn't good enough.

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2011-09-22