Hi All, As we know from the documentation, passing the empty string ("") to the CURLOPT_COOKIEFILE option allows to enable the cookie engine without reading any initial cookies.
While this is true, the Curl_cookie_init() function in \lib\cookie.c still tries to open a file using "" as a file name with fopen() and giving the "failed to open cookie file" warning for such cases. Besides giving a warning, the empty name "" also creates unnecessary performance penalty because of calling fopen() (i.e. on Windows fopen() even with an empty name is very untrivial call). I propose to add a simple check for the cookie file name length and call fopen() only if it is greater than zero like: --- lib/cookie.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cookie.c b/lib/cookie.c index 9095cea3e..8f95b0a97 100644 --- a/lib/cookie.c +++ b/lib/cookie.c @@ -1229,7 +1229,7 @@ struct CookieInfo *Curl_cookie_init(struct Curl_easy *data, if(data) { FILE *fp = NULL; - if(file) { + if(file && strlen(file) > 0) { if(!strcmp(file, "-")) fp = stdin; else { -- Thanks, Dmitry Karpov -- Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-library Etiquette: https://curl.se/mail/etiquette.html