Re: Avoid write callbacks

2013-03-15 Thread Florian Weimer
* Dan Fandrich:

 It sounds like the API you want doesn't quite match the API libcurl
 provides, in which case some amount of code is going to be necessary
 to handle the mismatch. It doesn't have to be a lot. Take a look
 also at the existing C++ binding (or bindings?) to see if that might
 not better suit you.

What binding options are there?  curlpp appears to be mostly dead.
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Avoid write callbacks

2013-03-13 Thread Florian Weimer
Is there a way to avoid callbacks, while still supporting incremental
retrieval of data?  In a nutshell, I'm looking for an iterator-like
interface.

I could use the multi interface with a custom write function which
writes to an in-memory buffer.  I would run the event loop until that
buffer contains some data.  My iterator would return data from the
buffer as long as some is available.  It would run some iterations of
the event loop to get more data.

But I wonder if there is an easier way to accomplish this.
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: Avoid write callbacks

2013-03-13 Thread Dan Fandrich
On Wed, Mar 13, 2013 at 01:01:35PM +0100, Florian Weimer wrote:
 Is there a way to avoid callbacks, while still supporting incremental
 retrieval of data?  

Unless you're writing to a FILE*, libcurl gives no other option for
writing received data without using callbacks. But, you can certainly
wrap libcurl in such a way that the use of callbacks is hidden from the 
application.

 In a nutshell, I'm looking for an iterator-like
 interface.
 
 I could use the multi interface with a custom write function which
 writes to an in-memory buffer.  I would run the event loop until that
 buffer contains some data.  My iterator would return data from the
 buffer as long as some is available.  It would run some iterations of
 the event loop to get more data.

That solution sounds perfectly doable. Take a look at the fopen.c example
program for an example of a libcurl wrapper that provides a stdio-like
interface.

 But I wonder if there is an easier way to accomplish this.

It sounds like the API you want doesn't quite match the API libcurl provides,
in which case some amount of code is going to be necessary to handle the
mismatch. It doesn't have to be a lot. Take a look also at the existing C++
binding (or bindings?) to see if that might not better suit you.

 Dan
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html