From: Daniel Stenberg Date: Mon, 21 Oct 2019 08:43:03 +0000 (+0200) Subject: conn-reuse: requests wanting NTLM can reuse non-NTLM connections X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=807c056c08bd6314e27148c348d027a808e3a632;p=curl conn-reuse: requests wanting NTLM can reuse non-NTLM connections Added test case 338 to verify. Reported-by: Daniel Silverstone Fixes #4499 Closes #4514 --- diff --git a/lib/url.c b/lib/url.c index 1b3c15c2f..660d24141 100644 --- a/lib/url.c +++ b/lib/url.c @@ -1282,8 +1282,14 @@ ConnectionExists(struct Curl_easy *data, partway through a handshake!) */ if(wantNTLMhttp) { if(strcmp(needle->user, check->user) || - strcmp(needle->passwd, check->passwd)) + strcmp(needle->passwd, check->passwd)) { + + /* we prefer a credential match, but this is at least a connection + that can be reused and "upgraded" to NTLM */ + if(check->http_ntlm_state == NTLMSTATE_NONE) + chosen = check; continue; + } } else if(check->http_ntlm_state != NTLMSTATE_NONE) { /* Connection is using NTLM auth but we don't want NTLM */ diff --git a/tests/data/Makefile.inc b/tests/data/Makefile.inc index ba6dfcf73..557f92891 100644 --- a/tests/data/Makefile.inc +++ b/tests/data/Makefile.inc @@ -57,7 +57,7 @@ test298 test299 test300 test301 test302 test303 test304 test305 test306 \ test307 test308 test309 test310 test311 test312 test313 test314 test315 \ test316 test317 test318 test319 test320 test321 test322 test323 test324 \ test325 test326 test327 test328 test329 test330 test331 test332 test333 \ -test334 test335 test336 test337 \ +test334 test335 test336 test337 test338 \ test340 \ \ test350 test351 test352 test353 test354 test355 test356 \ diff --git a/tests/data/test338 b/tests/data/test338 new file mode 100644 index 000000000..f8dab6528 --- /dev/null +++ b/tests/data/test338 @@ -0,0 +1,63 @@ +# See https://github.com/curl/curl/issues/4499 + + + +HTTP +HTTP GET + + + +# +# Server-side + + +HTTP/1.1 200 OK +Date: Thu, 09 Nov 2010 14:49:00 GMT +Server: test-server/fake +Last-Modified: Tue, 13 Jun 2000 12:10:00 GMT +ETag: "21025-dc7-39462498" +Accept-Ranges: bytes +Content-Length: 6 +Content-Type: text/html +Funny-head: yesyes + +-foo- + + +connection-monitor + + + +# +# Client-side + + +http + + +ANYAUTH connection reuse of non-authed connection + + +http://%HOSTIP:%HTTPPORT/338 --next http://%HOSTIP:%HTTPPORT/338 --anyauth -u foo:moo + + + +# +# Verify data after the test has been "shot" + + +^User-Agent:.* + + +GET /338 HTTP/1.1 +Host: %HOSTIP:%HTTPPORT +Accept: */* + +GET /338 HTTP/1.1 +Host: %HOSTIP:%HTTPPORT +Accept: */* + +[DISCONNECT] + + +