--- transfer.c.173	2003-10-06 14:07:47.752001600 -0700
+++ transfer.c	2003-10-06 14:08:35.961323200 -0700
@@ -534,17 +534,6 @@
                 data->info.httpcode = k->httpcode;
                 data->info.httpversion = k->httpversion;
 
-                /* 404 -> URL not found! */
-                if (data->set.http_fail_on_error &&
-                    (k->httpcode >= 400)) {
-                  /* If we have been told to fail hard on HTTP-errors,
-                     here is the check for that: */
-                  /* serious error, go home! */
-                  failf (data, "The requested URL returned error: %d",
-                         k->httpcode);
-                  return CURLE_HTTP_RETURNED_ERROR;
-                }
-
                 if(k->httpversion == 10)
                   /* Default action for HTTP/1.0 must be to close, unless
                      we get one of those fancy headers that tell us the
@@ -566,8 +555,25 @@
                   conn->size=0;
                   conn->maxdownload=0;
                   break;
+		case 401:
+		    /* this is a normal part of --ntlm authentication, so
+		     * let it go. */
+		    if (data->state.authwant == CURLAUTH_NTLM)
+		      break;
+		    /* Otherwise fall through to the default.  Some other piece
+		     * of code determines if authentication is really failing,
+		     * and deals with it.  Not very pretty, but it works. */
                 default:
-                  /* nothing */
+		  /* 404 -> URL not found! */
+		  if (data->set.http_fail_on_error &&
+                     (k->httpcode >= 400)) {
+                    /* If we have been told to fail hard on HTTP-errors,
+                       here is the check for that: */
+                    /* serious error, go home! */
+                    failf (data, "The requested URL returned error: %d",
+                           k->httpcode);
+                    return CURLE_HTTP_RETURNED_ERROR;
+                  }
                   break;
                 }
               }
@@ -773,8 +779,16 @@
                   
                   if(CURLNTLM_BAD != ntlm)
                     conn->newurl = strdup(data->change.url); /* clone string */
-                  else
-                    infof(data, "Authentication problem. Ignoring this.\n");
+                  else {
+		      /* If --fail was specified, we need to return an error */
+		      if (data->set.http_fail_on_error) {
+			failf (data, "The requested URL returned error: %d",
+			       k->httpcode);
+			return CURLE_HTTP_RETURNED_ERROR;
+		      }
+		      else
+			infof(data, "Authentication problem. Ignoring this.\n");
+                  }
                 }
                 else
                   if(data->state.authwant & CURLAUTH_NTLM)

