curl-library
Re: HTTP POSTing large amount of data in chunks
Date: Mon, 17 Jun 2013 17:29:13 +0200 (CEST)
On Mon, 17 Jun 2013, Zeman, Vaclav wrote:
> I am trying to find a way to HTTP POST larger amount of data that I am
> receiving from upstream (potentially) in chunks. It seems to me that the
> only way with libCurl is to accumulate all of the blocks I am receiving from
> upstream and build one large buffer that I can then set with
> CURLOPT_POSTFIELDS or CURLOPT_COPYPOSTFIELDS. Is this right? Is there any
> kind of “push” API as opposed to the “pull” API of CURLOPT_READFUNCTION?
Not exactly, but you can make libcurl only pull when you have data. One simple
way to achieve that is to use CURLOPT_READFUNCTION (see
http://curl.haxx.se/libcurl/c/post-callback.html) but simply wait in the read
callback until there's data available to send.
An alternative approach is to pause the uploading with curl_easy_pause() until
you have data to send and then unpause it to have it call the read function
again.
You can do variations of those using either the easy interface or the multi
interface depending on your preference.
-- / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2013-06-17