lib: add CURL_WRITEFUNC_ERROR to signal write callback error

Prior to this change if the user wanted to signal an error from their
write callbacks they would have to use logic to return a value different
from the number of bytes (nmemb) passed to the callback. Also, the
inclination of some users has been to just return 0 to signal error,
which is incorrect as that may be the number of bytes passed to the
callback.

To remedy this the user can now return CURL_WRITEFUNC_ERROR instead.

Ref: https://github.com/curl/curl/issues/9873

Closes https://github.com/curl/curl/pull/9874
This commit is contained in:
Jay Satiro 2022-11-08 18:49:21 -05:00
parent 988c1c12f5
commit 6d75115406
7 changed files with 35 additions and 35 deletions

View file

@ -256,6 +256,10 @@ typedef int (*curl_xferinfo_callback)(void *clientp,
will signal libcurl to pause receiving on the current transfer. */
#define CURL_WRITEFUNC_PAUSE 0x10000001
/* This is a magic return code for the write callback that, when returned,
will signal an error from the callback. */
#define CURL_WRITEFUNC_ERROR 0xFFFFFFFF
typedef size_t (*curl_write_callback)(char *buffer,
size_t size,
size_t nitems,