On 21/06/14 20:35, Daniel Stenberg wrote:
On Tue, 17 Jun 2014, Frank Meier wrote:

In our Application we normally do requests without HTTP keepalive (CURLOPT_FRESH_CONNECT and CURLOPT_FORBID_REUSE set to 1).

Now when we use NTLM this does not work anymore with this settings. I expected that libcurl would use the same connection for the NTLM authentication (type1) request and the following "real" (type3) request and then would drop the connection.

Yes, this is sort of a known issue. At least I know about it.

NTLM needs to do multiple requests over the same connection but due to lack "state awareness", the CURLOPT_FORBID_REUSE will simply close connections after a request even if it was the first one in a NTLM-series.

Feel free to take a stab at fixing this!

Hi again

I finally got around to write a patch for this issue. My solution is to ignore the forbid reuse flag in case the NTLM authentication handshake is in progress, according to the NTLM state flag.

cheers Frank
diff --git a/lib/url.c b/lib/url.c
index e43b19d..a342f18 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -5859,7 +5859,8 @@ CURLcode Curl_done(struct connectdata **connp,
   }
 
   /* if data->set.reuse_forbid is TRUE, it means the libcurl client has
-     forced us to close this no matter what we think.
+     forced us to close this connection. This is ignored for requests taking
+     place in a NTLM authentication handshake
 
      if conn->bits.close is TRUE, it means that the connection should be
      closed in spite of all our efforts to be nice, due to protocol
@@ -5871,7 +5872,10 @@ CURLcode Curl_done(struct connectdata **connp,
      we can add code that keep track of if we really must close it here or not,
      but currently we have no such detail knowledge.
   */
-  if(data->set.reuse_forbid || conn->bits.close || premature) {
+
+  if((data->set.reuse_forbid && !(conn->ntlm.state == NTLMSTATE_TYPE2 ||
+      conn->proxyntlm.state == NTLMSTATE_TYPE2))
+      || conn->bits.close || premature) {
     CURLcode res2 = Curl_disconnect(conn, premature); /* close connection */
 
     /* If we had an error already, make sure we return that one. But
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Reply via email to