cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: CURLOPT_WRITEFUNCTION function getting called multiple time even the complete http response body is only 2155 bytes

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Sat, 20 Jun 2015 01:12:05 +0200 (CEST)

On Fri, 19 Jun 2015, Ganesh Nikam wrote:

> 1. What do you mean by "as much as possible" here ? how libcurl decides it ?

It depends completley on what it receives. For every recv() call (and some
other details Jay mentioned), libcurl will call the callback to deliver data.

> 2. In my case, my complete http response boby is of 2155 bytes. For such
> small response also libcurl breaks the message in two callbacks. First with
> 1295 byte and other is 860 byte. What could be the reasons for
> calling callback two times for such small message size?

Most probably libcurl received the data in two different recv() calls.

> 3. I want to get the complete http response in single write_callbck function.

libcurl doesn't work like that.

> is there is any way to get the complete size of the http response ?

Sure, for example like this: http://curl.haxx.se/libcurl/c/getinmemory.html

> My http server sends response in chunked encoding. is there a way to get
> the chunked response size ?

You can switch off transfer-encoding in libcurl, and then you get all the
chunked data to deal with - but then you also have to do the entire chunked
decoding yourself.

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2015-06-20