curl: better error message when -O fails to get a good name

Due to how this currently works internally, it needs a working initial
file name to store contents in, so it may still fail even with -J is
used (and thus accepting a name from content-disposition:) if the file
name part of the URL isn't "good enough".

Fixes #7628
Closes #7635
This commit is contained in:
Daniel Stenberg 2021-08-26 07:43:34 +02:00
parent 1a042be270
commit e8e656c845
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View File

@ -950,8 +950,11 @@ static CURLcode single_transfer(struct GlobalConfig *global,
if(!per->outfile) {
/* extract the file name from the URL */
result = get_url_file_name(&per->outfile, per->this_url);
if(result)
if(result) {
errorf(global, "Failed to extract a sensible file name"
" from the URL to use for storage!\n");
break;
}
if(!*per->outfile && !config->content_disposition) {
errorf(global, "Remote file name has no length!\n");
result = CURLE_WRITE_ERROR;