NTLM authentication fails when CURLMOPT_MAXCONNECTS is set to a value lower
than the number of easy handles added.
The code attached reproduces the issue. Issue persists in curl 7.37.1.
For some reason, the connection cache tries to maintain CURLMOPT_MAXCONNECTS
connections, closing older connections before the authentication handshake
completes.
Is the discussion in http://curl.haxx.se/mail/lib-2008-06/0392.html void in the
latest version?
--
Paras
#include <curl/curl.h>
int main(void) {
CURL *easy1 = curl_easy_init();
curl_easy_setopt(easy1, CURLOPT_USERPWD, "user:pwd");
curl_easy_setopt(easy1, CURLOPT_HTTPAUTH, CURLAUTH_NTLM);
curl_easy_setopt(easy1, CURLOPT_URL, "https://www.url.com/");
curl_easy_setopt(easy1, CURLOPT_MAXREDIRS, 3L);
curl_easy_setopt(easy1, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(easy1, CURLOPT_PROXY, "");
CURL *easy2 = curl_easy_duphandle(easy1);
CURLM *multi = curl_multi_init();
curl_multi_setopt(multi, CURLMOPT_MAXCONNECTS, 1L);
curl_multi_add_handle(multi, easy1);
curl_multi_add_handle(multi, easy2);
int still_running; /* keep number of running handles */
int i;
curl_multi_perform(multi, &still_running);
do {
struct timeval timeout;
int rc; /* select() return code */
fd_set fdread;
fd_set fdwrite;
fd_set fdexcep;
int maxfd = -1;
long curl_timeo = -1;
FD_ZERO(&fdread);
FD_ZERO(&fdwrite);
FD_ZERO(&fdexcep);
/* set a suitable timeout to play around with */
timeout.tv_sec = 1;
timeout.tv_usec = 0;
curl_multi_timeout(multi, &curl_timeo);
if(curl_timeo >= 0) {
timeout.tv_sec = curl_timeo / 1000;
if(timeout.tv_sec > 1)
timeout.tv_sec = 1;
else
timeout.tv_usec = (curl_timeo % 1000) * 1000;
}
curl_multi_fdset(multi, &fdread, &fdwrite, &fdexcep, &maxfd);
rc = select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
switch(rc) {
case -1:
break;
case 0:
default:
curl_multi_perform(multi, &still_running);
break;
}
} while(still_running);
}
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html