cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Curl and Push/Pull data receiving

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Tue, 12 Dec 2000 13:41:43 +0100 (MET)

On Tue, 12 Dec 2000 nico.verboven.nv_at_belgium.agfa.com wrote:

> I've a a question regarding the data receiving of a Curl session. It
> looks like that Curl uses a PUSH mechanism for sending data to the
> application. It pushes the data to you through means of the
> CURLOPT_WRITEFUNCTION.

That is correct.

> However, in my application, I would prefer to have a PULL mechanism of
> receiving data. That is the application has to ask curl for buffers. This
> PULL methology allows more fine-grained control on handling the data. As
> it seems now the curl_easy_perform just starts reading ALL the data in a
> loop and pumps it to the write callback function. What I could do is to
> create a large memory buffer and store all the buffers into there. But
> this is considerable memory footprint which I would like to avoid. Is
> there a way to pull data from the Curl?

It is not currently possible to use curl with a "PULL mechanism". The easy
interface is this easy and simple thanks to the PUSH nature of its interface.

I have been planning and I still want to add a more low level interface to
libcurl that would be pull based. It would however not have all the fancy
features of the easy-interface.

That non-pushing interface is far from reality at this point, as there are
design issues to straigten out first. And before I would go ahead and
actually implement that interface, I'd need help and someone that actually
would use it. curl, the tool, does not need anything else but the easy
interface.

You could actually implement a pulling interface yourself by having libcurl
do the pushing in a separate thread and offer the pulling functions in
another thread. All data that arrives with the push gets sent to the
pull-thread that queues everything until the data gets read.

> Why isn't somebody writing a C++ version of the JAVA URL classes?

Personally, I'd rather see a nice C++ wrapper for the libcurl easy interface.
Possibly with the dual-thread approach I described above.

-- 
  Daniel Stenberg -- curl project maintainer -- http://curl.haxx.se/
_______________________________________________
Curl-library mailing list
Curl-library_at_lists.sourceforge.net
http://lists.sourceforge.net/mailman/listinfo/curl-library
Received on 2000-12-12