Closed
Description
I did this
I tried to make a function in libcurl that checks if a file exist on server:
curl_easy_setopt(curl, CURLOPT_URL, "ftp://user:pwd@host/fakefile.txt");
curl_easy_setopt(curl, CURLOPT_NOBODY, 1L);
CURLcode res = curl_easy_perform(curl);
//res is CURLE_OK
However, because I use the CURLOPT_NOBODY
option, perform returns CURLE_OK
(If I don't use the no body option it return CURLE_REMOTE_FILE_NOT_FOUND
) . However, on SFTP calls in reruns as I expect:
curl_easy_setopt(curl, CURLOPT_URL, "sftp://user:pwd@host/fakefile.txt");
curl_easy_setopt(curl, CURLOPT_NOBODY, 1L);
CURLcode res = curl_easy_perform(curl);
//res is CURLE_REMOTE_FILE_NOT_FOUND
I expected the following
I expect them both to return CURLE_REMOTE_FILE_NOT_FOUND
or at least have the same behaviour
curl/libcurl version
7.72.0
curl 7.72.0 (Linux) libcurl/7.72.0 OpenSSL/1.1.1g zlib/1.2.11 libssh2/1.9.0_DEV
Release-Date: 2020-08-19
Protocols: dict file ftp ftps gopher http https imap imaps pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: AsynchDNS HTTPS-proxy IPv6 Largefile libz NTLM SSL UnixSockets
operating system
Linux togtja-ubuntu 5.4.0-47-generic #51~18.04.1-Ubuntu SMP Sat Sep 5 14:35:50 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
Activity
bagder commentedon Sep 11, 2020
I think if you also do:
... it might actually do what you expected it. As a work-around.
ftp: a 550 response to SIZE is now an error
bagder commentedon Sep 12, 2020
@Togtja if you enable VERBOSE for your scenario, do you see the
SIZE
command get a 550 back? that's what I'm assuming and what my suggested fix in #5957 acts on.Togtja commentedon Sep 14, 2020
setting
curl_easy_setopt(curl, CURLOPT_FILETIME, 1L);
returnsCURLE_FTP_COULDNT_RETR_FILE
With verbose without setting
CURLOPT_FILETIME
, it does indeed return550 Could not get file size
After compiling #5957 It does indeed now actually return
CURLE_FTP_COULDNT_RETR_FILE
for me. Is there a big difference betweenCURLE_FTP_COULDNT_RETR_FILE
andCURLE_REMOTE_FILE_NOT_FOUND
?bagder commentedon Sep 14, 2020
Hm. I think I was too quick and you're right. It should rather use
CURLE_REMOTE_FILE_NOT_FOUND
for this. I'll amend my PR!ftp: a 550 response to SIZE returns CURLE_REMOTE_FILE_NOT_FOUND