-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CURLOPT_READFUNCTION documentation return value confuses bytes with objects #10328
Comments
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. |
Agreed. Adding this to the docs would be good. |
Thank you! |
Reported-by: Brian Green Fixes curl#10328 Closes curl#10355
@bagder Sorry for necro'ing this old issue, but this is one of the only search results I could find: why is it that |
For compatibility with fwrite(3) and fread(3).
|
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: