]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
ConnectionExists: re-use connections better
authorDaniel Stenberg <daniel@haxx.se>
Sun, 16 Feb 2014 13:07:56 +0000 (14:07 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Sun, 16 Feb 2014 13:30:02 +0000 (14:30 +0100)
When allowing NTLM, the re-use connection logic was too focused on
finding an existing NTLM connection to use and didn't properly allow
re-use of other ones. This made the logic not re-use perfectly re-usable
connections.

Added test case 1418 and 1419 to verify.

Regression brought in 8ae35102c (curl 7.35.0)

Reported-by: Jeff King
Bug: http://thread.gmane.org/gmane.comp.version-control.git/242213

lib/url.c
tests/data/Makefile.am
tests/data/test1418 [new file with mode: 0644]
tests/data/test1419 [new file with mode: 0644]

index 085b3a2f91562aea81bc29ba833b6768ff38adca..c0aebef16e5fa2c9e2b551f3ef920074ec91f658 100644 (file)
--- a/lib/url.c
+++ b/lib/url.c
@@ -3133,8 +3133,10 @@ ConnectionExists(struct SessionHandle *data,
             *force_reuse = TRUE;
             break;
           }
-          else
-            continue;
+          else if(credentialsMatch)
+            /* this is a backup choice */
+            chosen = check;
+          continue;
         }
 
         if(canPipeline) {
index d526a4b69a2100c34f2f87fd3041daf7a5938de8..53e8327fa5f64f291952500fb34c7eaaf098e591 100644 (file)
@@ -120,7 +120,7 @@ test1396 \
 \
 test1400 test1401 test1402 test1403 test1404 test1405 test1406 test1407 \
 test1408 test1409 test1410          test1412 test1413 test1414 test1415 \
-test1416 test1417 \
+test1416 test1417 test1418 test1419 \
 \
 test1500 test1501 test1502 test1503 test1504 test1505 test1506 test1507 \
 test1508 test1509 test1510 test1511 test1512 test1513 test1514 test1515 \
diff --git a/tests/data/test1418 b/tests/data/test1418
new file mode 100644 (file)
index 0000000..fb4e91a
--- /dev/null
@@ -0,0 +1,107 @@
+<testcase>
+<info>
+<keywords>
+HTTP
+HTTP GET
+HTTP NTLM auth
+connection re-use
+</keywords>
+</info>
+# Server-side
+<reply>
+<servercmd>
+connection-monitor
+</servercmd>
+
+<data>
+HTTP/1.1 401 Authentication please!\r
+Content-Length: 20\r
+WWW-Authenticate: Digest realm="loonie", nonce="314156592"\r
+WWW-Authenticate: Basic\r
+\r
+Please auth with me
+</data>
+
+# This is supposed to be returned when the server gets the second
+# Authorization: NTLM line passed-in from the client
+<data1000>
+HTTP/1.1 200 Things are fine in server land\r
+Server: Microsoft-IIS/5.0\r
+Content-Length: 4\r
+\r
+moo
+</data1000>
+
+<data1003>
+HTTP/1.1 200 OK\r
+Server: Another one/1.0\r
+Content-Length: 4\r
+\r
+boo
+</data1003>
+
+# This is the first reply after the redirection
+<data1011>
+HTTP/1.1 200 OK\r
+Server: Microsoft-IIS/5.0\r
+Content-Type: text/html; charset=iso-8859-1\r
+Content-Length: 34\r
+\r
+This is not the real page either!
+</data1011>
+
+<datacheck>
+HTTP/1.1 401 Authentication please!\r
+Content-Length: 20\r
+WWW-Authenticate: Digest realm="loonie", nonce="314156592"\r
+WWW-Authenticate: Basic\r
+\r
+HTTP/1.1 200 Things are fine in server land\r
+Server: Microsoft-IIS/5.0\r
+Content-Length: 4\r
+\r
+moo
+</datacheck>
+
+</reply>
+
+# Client-side
+<client>
+<server>
+http
+</server>
+<features>
+crypto
+</features>
+ <name>
+HTTP with --anyauth and connection re-use
+ </name>
+ <command>
+http://%HOSTIP:%HTTPPORT/1418 -u testuser:testpass --anyauth http://%HOSTIP:%HTTPPORT/14180003
+</command>
+</client>
+
+# Verify data after the test has been "shot"
+<verify>
+<strip>
+^User-Agent:.*
+</strip>
+<protocol>
+GET /1418 HTTP/1.1\r
+Host: %HOSTIP:%HTTPPORT\r
+Accept: */*\r
+\r
+GET /1418 HTTP/1.1\r
+Authorization: Digest username="testuser", realm="loonie", nonce="314156592", uri="/1418", response="986238b7e0077754944c966f56d9bc77"\r
+Host: %HOSTIP:%HTTPPORT\r
+Accept: */*\r
+\r
+GET /14180003 HTTP/1.1\r
+Authorization: Digest username="testuser", realm="loonie", nonce="314156592", uri="/14180003", response="1c6390a67bac3283a9b023402f3b3540"\r
+Host: %HOSTIP:%HTTPPORT\r
+Accept: */*\r
+\r
+[DISCONNECT]
+</protocol>
+</verify>
+</testcase>
diff --git a/tests/data/test1419 b/tests/data/test1419
new file mode 100644 (file)
index 0000000..f29ce44
--- /dev/null
@@ -0,0 +1,69 @@
+<testcase>
+<info>
+<keywords>
+HTTP
+HTTP GET
+HTTP NTLM auth
+connection re-use
+</keywords>
+</info>
+# Server-side
+<reply>
+<servercmd>
+connection-monitor
+</servercmd>
+
+<data>
+HTTP/1.1 200 fine!\r
+Content-Length: 20\r
+\r
+Feel free to get it
+</data>
+
+<data3>
+HTTP/1.1 200 OK\r
+Server: Another one/1.0\r
+Content-Length: 4\r
+\r
+boo
+</data3>
+
+<datacheck>
+HTTP/1.1 200 fine!\r
+Content-Length: 20\r
+\r
+Feel free to get it
+</datacheck>
+</reply>
+
+# Client-side
+<client>
+<server>
+http
+</server>
+ <name>
+HTTP with --anyauth (but no auth!) and connection re-use
+ </name>
+ <command>
+http://%HOSTIP:%HTTPPORT/1419 --anyauth http://%HOSTIP:%HTTPPORT/14190003
+</command>
+</client>
+
+# Verify data after the test has been "shot"
+<verify>
+<strip>
+^User-Agent:.*
+</strip>
+<protocol>
+GET /1419 HTTP/1.1\r
+Host: %HOSTIP:%HTTPPORT\r
+Accept: */*\r
+\r
+GET /14190003 HTTP/1.1\r
+Host: %HOSTIP:%HTTPPORT\r
+Accept: */*\r
+\r
+[DISCONNECT]
+</protocol>
+</verify>
+</testcase>