cURL / Mailing Lists / curl-library / Single Mail

curl-library

how to set maximum bytes to read by CURLOPT_READFUNCTION

From: Sergey Naumov <sknaumov_at_gmail.com>
Date: Sat, 18 Jan 2014 06:34:09 +0400

Hello.

I'm using libcurl 7.25.0 and want to ask how to set maximum bytes to read
by CURLOPT_READFUNCTION. I thought that it is done by
CURLFORM_CONTENTSLENGTH argument to curl_formadd, and then callback
function will be called with such size_t size, size_t nmemb parameters,
that it will not read more than CURLFORM_CONTENTSLENGTH bytes, but it looks
like size * nmemb only represents a buffer size:
read_from_files: bytes to read: 16384 // size * nmemb
read_from_files: total_bytes_read: 16384
read_from_files: bytes to read: 16384
read_from_files: total_bytes_read: 9116
read_from_files: bytes to read: 16384
read_from_files: total_bytes_read: 0

while I would expect:
read_from_files: bytes to read: 16384
read_from_files: total_bytes_read: 16384
read_from_files: bytes to read: 3616
read_from_files: total_bytes_read: 3616

if CURLFORM_CONTENTSLENGTH == 20000.

Is it a bug or I have to pass max length somehow through userdata parameter?

Thanks in advance,
Sergey Naumov.

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2014-01-18