how can I get libcurl to callback BEFORE it sends some information on a post?

495 Views Asked by At

I'm uploading information to a server using a post call (using curlpp, but libcurl directly is fine too).

CURLOPT_PROGRESSFUNCTION callback gets called from time to time with reports on how much data was send until now. When I upload a file, I see this call being made with very small delta between calls.

I want to get a callback BEFORE each part of data is sent, with the information of how much data is going to be transmitted now.

2

There are 2 best solutions below

1
On

There is no such callbacks in libcurl. CURLOPT_DEBUGFUNCTION will tell you basically that info, but after it was sent...

1
On

You might use the callback to be set by passing CURLOPT_READFUNCTION to curl_easy_setopt().

This assumes that the amount of data to be read by this callback function will be the size of the next chunk to be sent.

For details please see here: http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTREADFUNCTION