Search code examples
clibcurlhttp-authentication

Can I make libcurl remember HTTP Digest auth state between requests?


I am using libcurl's "easy" interface to access network devices over HTTP, currently using HTTP Basic authentication (which is the default in curl). I've found that it's possible to allow Digest authentication using curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC|CURLAUTH_DIGEST) but unfortunately this makes curl try all requests without any auth information at all, and then choosing the appropriate method according to WWW-Authenticate header in the response.

I know this has to be done the first time a specific device is accessed, but doing this for every single request seem quite excessive to me. Is it possible to make curl remember authentication state, and using the info in subsequent requests?


Solution

  • Re-use the same easy handle for the subsequent requests!