curl-library
CURLOPT_WRITEFUNCTION function getting called multiple time even the complete http response body is only 2155 bytes
Date: Fri, 19 Jun 2015 16:34:18 +0530
Hi All,
In my application I am using libcul's multi interface and
write_callback. My application is asynchronous and I am using all
libcurl's asyc apis (multi_socket_callback, multi_timer_callback,
socket_action etc).
I have registered the easy_write_callback to get the response. My
application sends very high number of https requests/sec.
The problem I am facing with curl is that, my write_callback is getting
called multiple times for single http response. As per the documentation
this callback can be called multiple times in some cases. My query is in
what scenarios it will be called multiple times ? How curls decides it?
Here is the text from documentation:
/"The callback function will be passed as much data as possible in all
invokes, but you must not make any assumptions. It may be one byte, it
may be thousands. The maximum amount of body data that will be passed to
the write callback is defined in the curl.h header file:
CURL_MAX_WRITE_SIZE (the usual default is 16K)".
/
Some queries on this point:
1. What do you mean by "as much as possible" here ? how libcurl decides it ?
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? My server
response is not going to be more than 5K.
3. I want to get the complete http response in single write_callbck
function. But as per below thread it is not possible:
http://curl.haxx.se/mail/lib-2003-09/0174.html
I have implemented wrapper class over the libcurl api. My
applications requirement is that, this wrapper class should return
complete http response to it. Now I would like to collect the multiple
chunks (received
from multiple write_callback function calls) together. For that I
want to know he complete size of the http response. is there is any way
to get the complete size of the http response ? I checked easy_get_opt
flags, but
I didn't find any relevant flag. Can you please suggest any way to
achieve this ?
My http server sends response in chunked encoding. is there a way to
get the chunked response size ?
libcurl version is 7.40 and the platform is Ubuntu 12.04
- Ganesh
//
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2015-06-19