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

CURLE_RECV_ERROR was returned in case of a write function error #13669

Closed
Trumeet opened this issue May 16, 2024 · 4 comments
Closed

CURLE_RECV_ERROR was returned in case of a write function error #13669

Trumeet opened this issue May 16, 2024 · 4 comments
Assignees

Comments

@Trumeet
Copy link

Trumeet commented May 16, 2024

I did this

#define _POSIX_C_SOURCE 200809L

#include <stdio.h>
#include <assert.h>
#include <curl/curl.h>

static size_t cb_curl(void *buffer, size_t size, size_t nmemb, void *userp) {
	return CURL_WRITEFUNC_ERROR; // Or anything != size * nmemb.
}

int main(int argc, char **argv) {
	curl_global_init(CURL_GLOBAL_SSL);
	CURL *curl = curl_easy_init();
	curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, cb_curl);

	curl_easy_setopt(curl, CURLOPT_URL, "https://www.youtube.com/watch?v=dQw4w9WgXcQ");
	CURLcode res = curl_easy_perform(curl);
	printf("Returned %d, should be %d.\n", res, CURLE_WRITE_ERROR);
	fflush(stdout);
	assert(res == CURLE_WRITE_ERROR);

	curl_easy_cleanup(curl);
	curl_global_cleanup();
}

curl_easy_perform() returns CURLE_RECV_ERROR when the write function returns an error.

I expected the following

curl_easy_perform() returns CURLE_WRITE_ERROR as indicated in CURLOPT_WRITEFUNCTION manual.

curl/libcurl version

curl 8.7.1 (x86_64-pc-linux-gnu) libcurl/8.7.1 OpenSSL/3.2.1 zlib/1.3.1 brotli/1.1.0 zstd/1.5.5 libidn2/2.3.7 libpsl/0.21.2 libssh2/1.11.0 nghttp2/1.61.0 nghttp3/1.2.0
Release-Date: 2024-03-27
Protocols: dict file ftp ftps gopher gophers http https imap imaps ipfs ipns mqtt pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: alt-svc AsynchDNS brotli GSS-API HSTS HTTP2 HTTP3 HTTPS-proxy IDN IPv6 Kerberos Largefile libz NTLM PSL SPNEGO SSL threadsafe TLS-SRP UnixSockets zstd

operating system

Linux sana.ad.yuuta.moe 6.6.27-1-lts #1 SMP PREEMPT_DYNAMIC Sat, 13 Apr 2024 11:50:59 +0000 x86_64 GNU/Linux
@icing icing self-assigned this May 16, 2024
@icing
Copy link
Contributor

icing commented May 16, 2024

I believe this was fixed in 5c59f91. Could you test the current master if this is still happening for you?

@bagder
Copy link
Member

bagder commented May 16, 2024

@Trumeet's test case above works fine for me in master:

Returned 23, should be 23.

bagder added a commit that referenced this issue May 16, 2024
Verifies that the issue in #13669 actually is fixed. This return code is
what the CURLOPT_WRITEFUNCTION manpage documents should be returned.

This code is mostly from the
Source-written-by: Trumeet at github
@jay
Copy link
Member

jay commented May 16, 2024

Works here with master 7dc376a 2024-05-16 in Windows. (Note: I had to modify the curl_global_init call to use CURL_GLOBAL_ALL to initialize Windows stuff)

curl 8.8.0-DEV (i386-pc-win32) libcurl/8.8.0-DEV OpenSSL/3.0.8 nghttp2/1.52.0
Release-Date: [unreleased]
Protocols: dict file ftp ftps gopher gophers http https imap imaps ipfs ipns ldap ldaps mqtt pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: alt-svc AsynchDNS Debug HSTS HTTP2 HTTPS-proxy IPv6 Largefile NTLM SSL Unicode UnixSockets

bagder added a commit that referenced this issue May 16, 2024
Verifies that the issue in #13669 actually is fixed. This return code is
what the CURLOPT_WRITEFUNCTION manpage documents should be returned.

This code is mostly from the
Source-written-by: Trumeet on github
Closes #13671
bagder added a commit that referenced this issue May 16, 2024
Verifies that the issue in #13669 actually is fixed. This return code is
what the CURLOPT_WRITEFUNCTION manpage documents should be returned.

This code is mostly from the
Source-written-by: Trumeet on github
Closes #13671
@bagder
Copy link
Member

bagder commented May 20, 2024

Confirmed to work correctly in master anyway.

@bagder bagder closed this as completed May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

4 participants