cURL / Mailing Lists / curl-library / Single Mail

curl-library

Curl and Push/Pull data receiving

From: <nico.verboven.nv_at_belgium.agfa.com>
Date: Tue, 12 Dec 2000 13:24:30 +0100

Hi,

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.
Tthis callback can be custom tailered for the receiving application.

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?

I tell you why I want to this. I'm writing a C++ URLConnection class which
looks like the
JAVA version. The JAVA class are so simple to use. What's available in C has
so much complexity involved.

 the URLConnection class looks like

class URLConnection
{
public:
 URLConnection(const URL& url);

 virtual void connect() = 0;
 virtual InputStream& getInputStream();
 virtual OutputStream& getOutputStream();
 virtual URL getURL();
};

Look at the InputStream and OutputStream classes. These are Java like classes,
with
read and write methods.
Basically you construct a URLConnection from a URL and then use the
getInputStream()
for reading from the URL resource or use the getOutputStream() if you would
like to write to
the resource. Dead easy. This class uses the PULL mechanism of receiving the
data.
Through the InputStream the user passes a a buffer in the read(char* data,int
len) call of
the InputStream.

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

Just some thoughts I wanted to share,

Regards,
Nico

email: nico.verboven.nv_at_belgium.agfa.be
_______________________________________________
Curl-library mailing list
Curl-library_at_lists.sourceforge.net
http://lists.sourceforge.net/mailman/listinfo/curl-library
Received on 2000-12-12