From 56dab605f1f1010d7a97b29532d294ad5a6a83a9 Mon Sep 17 00:00:00 2001
From: Daniel Stenberg <daniel@haxx.se>
Date: Mon, 11 May 2009 08:55:58 +0000
Subject: [PATCH] - I fixed the problem with doing NTLM, POST and then
 following a 302 redirect,   as reported by Ebenezer Ikonne (on curl-users)
 and Laurent Rabret (on   curl-library). The transfer was mistakenly marked to
 get more data to send   but since it didn't actually have that, it just hung
 there...

---
 CHANGES             |  6 ++++++
 RELEASE-NOTES       |  3 ++-
 TODO-RELEASE        |  2 --
 lib/http.c          |  2 ++
 tests/data/DISABLED |  2 +-
 tests/data/test1100 | 16 ++++++++++++----
 6 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/CHANGES b/CHANGES
index adcd4fce36..671d3b3065 100644
--- a/CHANGES
+++ b/CHANGES
@@ -6,6 +6,12 @@
 
                                   Changelog
 
+Daniel Stenberg (11 May 2009)
+- I fixed the problem with doing NTLM, POST and then following a 302 redirect,
+  as reported by Ebenezer Ikonne (on curl-users) and Laurent Rabret (on
+  curl-library). The transfer was mistakenly marked to get more data to send
+  but since it didn't actually have that, it just hung there...
+
 Daniel Stenberg (10 May 2009)
 - Andre Guibert de Bruet correctly pointed out an over-alloc with one wasted
   byte in the digest code.
diff --git a/RELEASE-NOTES b/RELEASE-NOTES
index 06292b1fb7..adb37e04b7 100644
--- a/RELEASE-NOTES
+++ b/RELEASE-NOTES
@@ -44,6 +44,7 @@ This release includes the following bugfixes:
  o fixed roff mistakes in man pages
  o use SOCKS proxy with the multi interface
  o fixed the Curl_getoff_all_pipelines SIGSEGV 
+ o POST, NTLM and following a redirect hang
 
 This release includes the following known bugs:
 
@@ -57,6 +58,6 @@ advice from friends like these:
  Kamil Dudka, Jim Freeman, Daniel Johnson, Toshio Kuratomi, Martin Storsjo,
  Pramod Sharma, Gisle Vanem, Lenaic Lefever, Rainer Koenig, Sven Wegener,
  Tim Chen, Constantine Sapuntzakis, David McCreedy, Michael Smith,
- Colin Watson
+ Colin Watson, Ebenezer Ikonne, Laurent Rabret
 
         Thanks! (and sorry if I forgot to mention someone)
diff --git a/TODO-RELEASE b/TODO-RELEASE
index 4555f277fc..d034014199 100644
--- a/TODO-RELEASE
+++ b/TODO-RELEASE
@@ -12,8 +12,6 @@ To be addressed in 7.19.5 (planned release: May 2009)
 
 236 - timeout in milliseconds doesn't seem to work
 
-237 - Redirection failing with NTLM authentication
-
 239 -
 
 To be addressed in 7.19.6 (planned release: July 2009)
diff --git a/lib/http.c b/lib/http.c
index a31e0f879b..9c020396c1 100644
--- a/lib/http.c
+++ b/lib/http.c
@@ -369,6 +369,8 @@ CURLcode Curl_http_perhapsrewind(struct connectdata *conn)
     case HTTPREQ_POST:
       if(data->set.postfieldsize != -1)
         expectsend = data->set.postfieldsize;
+      else if(data->set.postfields)
+        expectsend = (curl_off_t)strlen(data->set.postfields);
       break;
     case HTTPREQ_PUT:
       if(data->set.infilesize != -1)
diff --git a/tests/data/DISABLED b/tests/data/DISABLED
index 251b45b1a4..0e3c19ba27 100644
--- a/tests/data/DISABLED
+++ b/tests/data/DISABLED
@@ -4,4 +4,4 @@
 # per line.
 # Lines starting with '#' letters are treated as comments.
 563
-1100
+
diff --git a/tests/data/test1100 b/tests/data/test1100
index 7644aa2f4b..40d9f641ec 100644
--- a/tests/data/test1100
+++ b/tests/data/test1100
@@ -10,7 +10,7 @@ HTTP NTLM auth
 <reply>
 
 <data>
-HTTP/1.1 200 Thanks for this, but we want to redir you! swsclose
+HTTP/1.1 200 Thanks for this! swsclose
 Content-Length: 25
 
 This is the final page !
@@ -48,9 +48,13 @@ WWW-Authenticate: NTLM TlRMTVNTUAACAAAAAgACADAAAAAGgoEAc51AYVDgyNcAAAAAAAAAAG4Ab
 HTTP/1.1 302 Thanks for this, but we want to redir you!
 Server: Microsoft-IIS/5.0
 Content-Type: text/html; charset=iso-8859-1
+Location: /1100
 Content-Length: 34
 
-This is not the real page either!
+HTTP/1.1 200 Thanks for this! swsclose
+Content-Length: 25
+
+This is the final page !
 </datacheck>
 
 </reply>
@@ -81,7 +85,7 @@ http://%HOSTIP:%HTTPPORT/1100 -u testuser:testpass --ntlm -L -d "stuff to send a
 <strippart>
 s/^(Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAA).*/$1/
 </strippart>
-<protocol nonewline="yes">
+<protocol>
 POST /1100 HTTP/1.1
 Authorization: NTLM TlRMTVNTUAABAAAABoIIAAAAAAAAAAAAAAAAAAAAAAA=
 User-Agent: curl/7.10.6-pre1 (i686-pc-linux-gnu) libcurl/7.10.6-pre1 OpenSSL/0.9.7a ipv6 zlib/1.1.3
@@ -98,7 +102,11 @@ Accept: */*
 Content-Length: 18
 Content-Type: application/x-www-form-urlencoded
 
-stuff to send away
+stuff to send awayGET /1100 HTTP/1.1
+User-Agent: curl/7.19.5-CVS (i686-pc-linux-gnu) libcurl/7.19.5-CVS GnuTLS/2.6.6 zlib/1.2.3.3 c-ares/1.6.1-CVS libidn/1.14 libssh2/1.1
+Host: %HOSTIP:%HTTPPORT
+Accept: */*
+
 </protocol>
 </verify>
 </testcase>
-- 
GitLab