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

docs/CURLOPT_WRITEFUNCTION: size is always 1 #2787

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
2 participants
@Hawk777
Contributor

Hawk777 commented Jul 25, 2018

For compatibility with fwrite, the CURLOPT_WRITEFUNCTION callback is
passed two size_t parameters which, when multiplied, designate the
number of bytes of data passed in. In practice, CURL always sets the
first parameter (size) to 1.

This practice is also enshrined in documentation and cannot be changed
in future. The documentation states that the default callback is
fwrite, which means fwrite must be a suitable function for this
purpose. However, the documentation also states that the callback must
return the number of bytes it successfully handled, whereas ISO C
fwrite returns the number of items (each of size size) which it
wrote. The only way these numbers can be equal is if size is 1.

Since size is 1 and can never be changed in future anyway, document
that fact explicitly and let users rely on it.

docs/CURLOPT_WRITEFUNCTION: size is always 1
For compatibility with `fwrite`, the `CURLOPT_WRITEFUNCTION` callback is
passed two `size_t` parameters which, when multiplied, designate the
number of bytes of data passed in. In practice, CURL always sets the
first parameter (`size`) to 1.

This practice is also enshrined in documentation and cannot be changed
in future. The documentation states that the default callback is
`fwrite`, which means `fwrite` must be a suitable function for this
purpose. However, the documentation also states that the callback must
return the number of *bytes* it successfully handled, whereas ISO C
`fwrite` returns the number of items (each of size `size`) which it
wrote. The only way these numbers can be equal is if `size` is 1.

Since `size` is 1 and can never be changed in future anyway, document
that fact explicitly and let users rely on it.
@bagder

bagder approved these changes Jul 25, 2018

It's also been like this always so there's no reason to believe we would ever want to change it...

@bagder

This comment has been minimized.

Show comment
Hide comment
@bagder

bagder Jul 26, 2018

Member

Thanks!

Member

bagder commented Jul 26, 2018

Thanks!

@bagder bagder closed this in 9526cbe Jul 26, 2018

xquery added a commit to xquery/curl that referenced this pull request Aug 9, 2018

docs/CURLOPT_WRITEFUNCTION: size is always 1
For compatibility with `fwrite`, the `CURLOPT_WRITEFUNCTION` callback is
passed two `size_t` parameters which, when multiplied, designate the
number of bytes of data passed in. In practice, CURL always sets the
first parameter (`size`) to 1.

This practice is also enshrined in documentation and cannot be changed
in future. The documentation states that the default callback is
`fwrite`, which means `fwrite` must be a suitable function for this
purpose. However, the documentation also states that the callback must
return the number of *bytes* it successfully handled, whereas ISO C
`fwrite` returns the number of items (each of size `size`) which it
wrote. The only way these numbers can be equal is if `size` is 1.

Since `size` is 1 and can never be changed in future anyway, document
that fact explicitly and let users rely on it.

Closes #2787

@Hawk777 Hawk777 deleted the Hawk777:write-function-param branch Aug 22, 2018

falconindy added a commit to falconindy/curl that referenced this pull request Sep 10, 2018

docs/CURLOPT_WRITEFUNCTION: size is always 1
For compatibility with `fwrite`, the `CURLOPT_WRITEFUNCTION` callback is
passed two `size_t` parameters which, when multiplied, designate the
number of bytes of data passed in. In practice, CURL always sets the
first parameter (`size`) to 1.

This practice is also enshrined in documentation and cannot be changed
in future. The documentation states that the default callback is
`fwrite`, which means `fwrite` must be a suitable function for this
purpose. However, the documentation also states that the callback must
return the number of *bytes* it successfully handled, whereas ISO C
`fwrite` returns the number of items (each of size `size`) which it
wrote. The only way these numbers can be equal is if `size` is 1.

Since `size` is 1 and can never be changed in future anyway, document
that fact explicitly and let users rely on it.

Closes #2787
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment