Skip to content
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

lib: CURL_WRITEFUNC_ABORT is a new write callback error #12208

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions docs/libcurl/opts/CURLOPT_WRITEFUNCTION.3
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,11 @@ that amount differs from the amount passed to your callback function, it
signals an error condition to the library. This causes the transfer to get
aborted and the libcurl function used returns \fICURLE_WRITE_ERROR\fP.

You can also abort the transfer by returning CURL_WRITEFUNC_ERROR (added in
7.87.0), which makes \fICURLE_WRITE_ERROR\fP get returned.
You can stop the transfer by returning CURL_WRITEFUNC_ERROR (added in 7.87.0),
which makes \fICURLE_WRITE_ERROR\fP get returned.

You can abort the transfer by returning CURL_WRITEFUNC_ABORT (added in 8.5.0),
jay marked this conversation as resolved.
Show resolved Hide resolved
which makes \fICURLE_ABORTED_BY_CALLBACK\fP get returned.

If the callback function returns CURL_WRITEFUNC_PAUSE it pauses this
transfer. See \fIcurl_easy_pause(3)\fP for further details.
Expand Down
1 change: 1 addition & 0 deletions docs/libcurl/symbols-in-versions
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ CURL_WAIT_POLLIN 7.28.0
CURL_WAIT_POLLOUT 7.28.0
CURL_WAIT_POLLPRI 7.28.0
CURL_WIN32 7.69.0
CURL_WRITEFUNC_ABORT 8.5.0
CURL_WRITEFUNC_ERROR 7.87.0
CURL_WRITEFUNC_PAUSE 7.18.0
CURL_ZERO_TERMINATED 7.56.0
Expand Down
8 changes: 7 additions & 1 deletion include/curl/curl.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,15 @@ typedef int (*curl_xferinfo_callback)(void *clientp,
#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. */
will signal an error from the callback. Makes libcurl return
CURLE_WRITE_ERROR as a result for the transfer. */
#define CURL_WRITEFUNC_ERROR 0xFFFFFFFF

/* This is a magic return code for the write callback that, when returned,
will signal an error from the callback. Makes libcurl return
CURLE_ABORTED_BY_CALLBACK as a result for the transfer. */
#define CURL_WRITEFUNC_ABORT 0xFFFFFFFE

typedef size_t (*curl_write_callback)(char *buffer,
size_t size,
size_t nitems,
Expand Down
4 changes: 4 additions & 0 deletions lib/sendf.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,10 @@ static CURLcode chop_write(struct Curl_easy *data,
}
return pausewrite(data, type, TRUE, ptr, len);
}
else if(CURL_WRITEFUNC_ABORT == wrote) {
failf(data, "write callback aborted");
return CURLE_ABORTED_BY_CALLBACK;
}
if(wrote != chunklen) {
failf(data, "Failure writing output to destination");
return CURLE_WRITE_ERROR;
Expand Down