Index: transfer.c
===================================================================
--- transfer.c	(revision 2)
+++ transfer.c	(working copy)
@@ -806,6 +806,35 @@
                 }
               }
             }
+            else if(checkprefix("Proxy-authenticate:", k->p) &&
+                    (407 == k->httpcode)) {
+              /*
+               * This proxy requires authentication
+               */
+              char *start = k->p+strlen("Proxy-authenticate:");
+
+              /* pass all white spaces */
+              while(*start && isspace((int)*start))
+                start++;
+#ifdef USE_SSLEAY
+            /* NTLM support requires the SSL crypto libs */
+              if(checkprefix("NTLM", start)) {
+                if(data->state.authwant == CURLAUTH_NTLM) {
+                  /* NTLM authentication is activated */
+                  CURLntlm ntlm =
+                    Curl_input_ntlm(conn, TRUE, start);
+                  
+                  if(CURLNTLM_BAD != ntlm)
+                    conn->newurl = strdup(data->change.url); /* clone string */
+                  else
+                    infof(data, "Authentication problem. Ignoring this.\n");
+                }
+                else
+                  if(data->state.authwant & CURLAUTH_NTLM)
+                    data->state.authavail |= CURLAUTH_NTLM;
+              }
+#endif
+            }
             else if ((k->httpcode >= 300 && k->httpcode < 400) &&
                      checkprefix("Location:", k->p)) {
               if(data->set.http_follow_location) {
Index: url.c
===================================================================
--- url.c	(revision 2)
+++ url.c	(working copy)
@@ -108,6 +108,7 @@
 #include "content_encoding.h"
 #include "http_digest.h"
 #include "http_negotiate.h"
+#include "http_ntlm.h"
 
 /* And now for the protocols */
 #include "ftp.h"
@@ -2987,6 +2988,13 @@
         aprintf("Proxy-authorization: Basic %s\015\012", authorization);
       free(authorization);
     }
+#ifdef USE_SSLEAY
+    if(data->state.authwant == CURLAUTH_NTLM) {
+      result = Curl_output_ntlm(conn, TRUE);
+      if(result)
+        return result;
+    }
+#endif
   }
 
   /*************************************************************
