cURL / Mailing Lists / curl-library / Single Mail


Re: cURL-PHP GET chunked data

From: Daniel Stenberg <>
Date: Tue, 8 Apr 2008 13:15:21 +0200 (CEST)

On Tue, 8 Apr 2008, Mahendra Gayatri wrote:

> I am trying to read chunked(stream) data.. that is data to be read depending
> on the size the user mentions. So if user says 50 characters length as 1
> chunk, I must GET a file of 200 characters 4 times (at least thats what I
> believe is the way to read in chunks/stream). The requirement is as below
> The stream method provides a way to retrieve data withoutbuffering the
> entire thing into memory before returning the way read() does.
> Any ideas about GET with stream?

I'm not really following.

Are you referring to chunked-encoded streams as per the HTTP protocol? If so,
then you won't have to even think about it since libcurl will deal with that
transparantly and deliver the contents to your write callback just like with
any other downloaded content.

If you're instead referring to an application-layer chunked protocol within
the transported data, then you'll need to deal with those chunks in your
application. Possibly in the write callback.

You can in no circumstance assume that your callback will be getting any
particular amount of data per call. It can be anywhere between 1 byte and
16Kbytes in every invoke.

  Commercial curl and libcurl Technical Support:
Received on 2008-04-08