I expected to understand if the return value should be the number of bytes read, like the return value of read, or the number of objects read, like the return value of fread.
This is confusing because the documentation is not consistent with itself.
First, it says the return value should be the the number of bytes read:
Scanning through the codebase, it looks like one of those arguments is always 1, so in practice the difference might not matter. If that's the case, explicitly saying that the size argument is always 1 would also be helpful to make it less ambiguous.
The text was updated successfully, but these errors were encountered:
I went back and forth on whether this was a bug in the documentation, or something I should discuss on the mailing list. If this is the wrong place, I can move this over to the mailing list 🙇
Internally we always call those callbacks with an element size of 1. We have already documented this for CURLOPT_WRITEFUNCTION and I can't think of a reason why we couldn't do the same for CURLOPT_READFUNCTION.
I did this
I read the documentation at https://curl.se/libcurl/c/CURLOPT_READFUNCTION.html.
I expected the following
I expected to understand if the return value should be the number of bytes read, like the return value of read, or the number of objects read, like the return value of fread.
This is confusing because the documentation is not consistent with itself.
First, it says the return value should be the the number of bytes read:
curl/docs/libcurl/opts/CURLOPT_READFUNCTION.3
Lines 47 to 49 in c12fb3d
However the example it provides uses
fread
, which returns the number of objects read:curl/docs/libcurl/opts/CURLOPT_READFUNCTION.3
Line 88 in c12fb3d
If the return value is indeed
bytes
, then it seems the example should instead be something like:Scanning through the codebase, it looks like one of those arguments is always
1
, so in practice the difference might not matter. If that's the case, explicitly saying that thesize
argument is always1
would also be helpful to make it less ambiguous.The text was updated successfully, but these errors were encountered: