cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Enabling cookies without a file

From: Dave Dribin <dave-ml_at_dribin.org>
Date: Tue, 1 Mar 2005 21:12:14 -0600

On Mar 1, 2005, at 7:29 PM, Ralph Mitchell wrote:
> Why not just use a temporary file, then delete/unlink it when the app
> exits??

We could, but, our app doesn't need to store 'em in a file. In fact,
our project is going to be a library/DLL and it doesn't need or use
files for anything else. It seems silly to use the filesystem just for
cookies, which we don't even need. And then we have to come up with a
platform specific solution to create temporary files.

Just to be clear, the current API does what we want. We can use:

   curl_easy_setopt(curl, CURLOPT_COOKIEFILE,
"/some/file/that/does/not/exist");

But, since our app is multi-platform, there is no way to come up with a
path that is guaranteed not to exist on all platforms. I've found that
using the empty string works, like this:

   curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "");

However, this causes an assert error inside some Microsoft DLL because
libcurl tries to do fopen("", "r"). Since fopen("", "r") will always
fail, the patch I submitted short circuits the failure by checking for
the empty string prior to calling fopen().

Thanks,

-Dave
Received on 2005-03-02