[sr-dev] Fwd: Handling large responses with utils:http_query()

Alex Balashov abalashov at evaristesys.com
Wed Dec 10 23:24:33 CET 2014


Hi Daniel,

Thank you very much for your feedback, I really appreciate it. I'll 
reimplement the callback to dynamically resize the buffer and submit as 
a patch to the Kamailio project.

Cheers,

-- Alex

On 12/10/2014 05:20 PM, Daniel Stenberg wrote:

> Hey
>
> Responding to a forwarded message and I'm not subscribed. Excuse the
> formatting. I'm the lead developer of libcurl and was asked to comment
> on this.
>
>>> From: Alex Balashov <abalashov at evaristesys.com>
>
>>>    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_function);
>>>
>>> As far as I can tell from how write_function() is constructed, it
>>> expects to be called once:
>
>>> 1) Does this function need to be rewritten to realloc() and concatenate?
>
> Yes. libcurl will deliver data to the callback as soon as it has read
> some off the network, it can thus deliver one byte at a time during slow
> conditions or a whole bunch. It will keep calling the callback as long
> as data is coming.
>
> This is also documented in the man page:
> http://curl.haxx.se/libcurl/c/CURLOPT_WRITEFUNCTION.html
>
>>> 2) Is there an option in CURL that can use internal buffering and
>>> only invoke the callback once all the response chunks are received?
>
> Nope.
>
>>> 3) Would increasing the curl.h constant CURL_MAX_WRITE_SIZE help?
>
> No. That would just make libcurl able to read a larger chunk from the
> socket into its own buffer, but it wouldn't prevent it from calling the
> callback one or many times.
>


-- 
Alex Balashov - Principal
Evariste Systems LLC
235 E Ponce de Leon Ave
Suite 106
Decatur, GA 30030
United States

Tel: +1-678-954-0670
Web: http://www.evaristesys.com/, http://www.alexbalashov.com/



More information about the sr-dev mailing list