curl / Mailing Lists / curl-library / Single Mail


Multiple READFUNCTION callbacks not happening

From: Pushkar Kulkarni <>
Date: Thu, 12 Jan 2017 01:34:04 +0530

Hello Daniel, others,

I am working with the URLSession implementation in open source Swift,which
is based on libcurl. I have a question to ask. But a code snippet is not
really feasible, so kindly bear with me.

An HTTP POST request is made using the CURLOPT_READFUNCTION callback,
through which the HTTP request body is passed. In my tests, I have seen
that the READFUNCTION callback allows writing a maximum of 16K
(CURL_WRITE_MAX_SIZE) bytes of data to the buffer. So, for request body
sizes of more than 16K, I’d expect this callback to happen multiple times
until the READFUNCTION returned a 0. Is that right?

However, for body sizes more than 16K bytes in size I see the callback
happening only once. Since the subsequent callbacks don’t happen, the
server eventually times out. Hence, large requests or file uploads with
sizes > 16K simply fail.

I can confirm that the first (and only) time the callback happens, the
READFUNCTION does NOT return 0. I can also confirm that we do set the
CURLOPT_INFILESIZE value to the expected size of the body. Though I am not
sure if the CURLOPT_POSTFIELDSIZE option would make a difference here, I
did try setting it to the size of the request body but that didn’t help. I
have also fiddled with a few HTTP headers as well, but I can’t get the
callback to happen for more than once.

Am I missing some config option here? Can someone help please?


List admin:
Received on 2017-01-11