cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: cURL easy interface / buffer alloc.

From: Jason Pump <jpump_at_mindspring.com>
Date: Wed, 25 Jan 2006 11:36:02 -0800

You'll get the data in a bunch of parts of varying size. You have to
glom the data together to get your full page. There is an example
receive function in the tutorial or samples, basically just use realloc
to resize your programs buffer and memcpy to copy the buffer from curl
onto the end of your programs buffer.

Robbie wrote:

>I think I know where my problem lie but I don't understand why.
>
>My interpretation of the docs I thinks is a bit off. I notice the data size is around 2K everytime I use curl_perform and I'm expecting a 56K data. Is the received size limited by curl? The http server expects a request and provides 56K of data for each request and it appears that only a 2k portion is being received.
>Is this a curl config mistake on my part, program, or that the way curl do things?
>Anyone have any ideas?
>
>Much thanks,
>Robbie.
>
>
> --- On Tue 01/24, Daniel Stenberg < daniel_at_haxx.se > wrote:
>From: Daniel Stenberg [mailto: daniel_at_haxx.se]
>To: sheriff_at_excite.com, curl-users_at_cool.haxx.se
>Date: Wed, 25 Jan 2006 00:14:03 +0100 (CET)
>Subject: Re: cURL easy interface / buffer alloc.
>
>
>
>>I'm using libcurl easy interface to accomplish two tasks.
>>
>>
>
>Then consider the curl-library list, which is for libcurl users, hackers and
>wannabes.
>
>
>
>>1. to grab data from a url at will, and process it, and
>>2. initiate a stream and grab an updated sequence of data and process it.
>>
>>In the first case, I notice my data chunks in memory are the same. That is,
>>its not being updated. When I call curl_perform, does it actually get new
>>data and put it in the specified buffer or do I have to update it myself?
>>
>>
>
>You're talking about the buffer passed to the write callback here? Then yes,
>it is filled with contents before the function is called and you need to copy
>the data or do what you want with it as when you return from the write
>callback the data will be gone.
>
>
>
>>Or am I actually using the right functions? I tried clearing the buffer
>>after processing but I got segfaults as if its looking for the same data.
>>Does anyone have any ideas here? My App uses libcurl much like the
>>getinmemory.c example and I've written a thread form that does the same
>>thing.
>>
>>
>
>... and in that example you see how the data is copied from the buffer every
>time the callback is invoked.
>
>
>
>>For the second case, I just have one question, How does libcurl determine
>>the size of the buffer to use in such a case?
>>
>>
>
>It has a fixed-size internal buffer that it fills with a varying amount of
>data depending on the situation and then it calls the callback telling it how
>much of the buffer that is filled with data for the callback to use.
>
>I believe all this (and more) is mentioned in the libcurl tutorial.
>
>_______________________________________________
>Join Excite! - http://www.excite.com
>The most personalized portal on the Web!
>
>
>
>
>
Received on 2006-01-25