CURLHTTP* renamed to CURLAUTH* and NEGOTIATE is now GSSNEGOTIATE as there's
authorDaniel Stenberg <daniel@haxx.se>
Thu, 12 Jun 2003 17:34:27 +0000 (17:34 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 12 Jun 2003 17:34:27 +0000 (17:34 +0000)
a "plain" Negotiate as well.

include/curl/curl.h
lib/http.c
lib/transfer.c
lib/url.c
lib/urldata.h

index 0d590d6..7ae5560 100644 (file)
@@ -214,11 +214,11 @@ typedef enum {
 } curl_proxytype;
 
 typedef enum {
-  CURLHTTP_BASIC  =    0, /* default */
-  CURLHTTP_DIGEST =    1, /* Digest */
-  CURLHTTP_NEGOTIATE = 2, /* Negotiate */
-  CURLHTTP_NTLM =      3, /* NTLM */
-  CURLHTTP_LAST           /* never to be used */
+  CURLAUTH_BASIC  =       0, /* default */
+  CURLAUTH_DIGEST =       1, /* Digest */
+  CURLAUTH_GSSNEGOTIATE = 2, /* GSS-Negotiate */
+  CURLAUTH_NTLM =         3, /* NTLM */
+  CURLAUTH_LASTKNOWN      /* never to be used */
 } curl_httpauth;
 
 /* this was the error code 50 in 7.7.3 and a few earlier versions, this
index b06de06..2c1bb29 100644 (file)
@@ -709,7 +709,7 @@ CURLcode Curl_http(struct connectdata *conn)
     if(result)
       return result;
   }
-  else if(!data->set.httpdigest && /* not if Digest is enabled */
+  else if((data->set.httpauth == CURLAUTH_BASIC) && /* if Basic is desired */
           conn->bits.user_passwd &&
           !checkheaders(data, "Authorization:")) {
     char *authorization;
index 8d59653..890af24 100644 (file)
@@ -727,7 +727,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
            else if (Curl_compareheader(k->p, "WWW-Authenticate:",
                                         "GSS-Negotiate") &&
                     (401 == k->httpcode) &&
-                    data->set.httpnegotiate) {
+                    (data->set.httpauth == CURLAUTH_GSSNEGOTIATE)) {
              int neg;
 
              neg = Curl_input_negotiate(conn,
@@ -742,8 +742,8 @@ CURLcode Curl_readwrite(struct connectdata *conn,
             else if(Curl_compareheader(k->p,
                                        "WWW-Authenticate:", "NTLM") &&
                     (401 == k->httpcode) &&
-                    data->set.httpntlm /* NTLM authentication is 
-                                          activated */) {
+                    (data->set.httpauth == CURLAUTH_NTLM)
+                    /* NTLM authentication is activated */) {
               CURLntlm ntlm =
                 Curl_input_ntlm(conn, k->p+strlen("WWW-Authenticate:"));
 
@@ -753,10 +753,11 @@ CURLcode Curl_readwrite(struct connectdata *conn,
                 infof(data, "Authentication problem. Ignoring this.\n");
             }
 #endif
-            else if(checkprefix("WWW-Authenticate:", k->p) &&
+            else if(Curl_compareheader(k->p,
+                                       "WWW-Authenticate:", "Digest") &&
                     (401 == k->httpcode) &&
-                    data->set.httpdigest /* Digest authentication is 
-                                            activated */) {
+                    (data->set.httpauth == CURLAUTH_DIGEST)
+                    /* Digest authentication is activated */) {
               CURLdigest dig = CURLDIGEST_BAD;
 
               if(data->state.digest.nonce)
index f02eec0..397d1d4 100644 (file)
--- a/lib/url.c
+++ b/lib/url.c
@@ -851,36 +851,24 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option, ...)
   {
     curl_httpauth auth = va_arg(param, long);
     switch(auth) {
-    case CURLHTTP_BASIC:
-      /* default */
-      data->set.httpdigest = FALSE;
-      data->set.httpnegotiate = FALSE;
-      data->set.httpntlm = FALSE;      
+    case CURLAUTH_BASIC:
+    case CURLAUTH_DIGEST:
+      data->set.httpauth = auth;      
       break;
-    case CURLHTTP_DIGEST:
-      /* Enable HTTP Digest authentication */
-      data->set.httpdigest = TRUE;
-      data->set.httpnegotiate = FALSE;
-      data->set.httpntlm = FALSE;      
-      break;
-    case CURLHTTP_NTLM:
+    case CURLAUTH_NTLM:
       /* Enable HTTP NTLM authentication */
 #ifdef USE_SSLEAY
       /* We can only support NTLM if OpenSSL is present, as we need their
          crypto package for it */
-      data->set.httpdigest = FALSE;
-      data->set.httpnegotiate = FALSE;
-      data->set.httpntlm = TRUE;      
+      data->set.httpauth = auth;
       break;
 #else
       /* fall-through */
 #endif
-    case CURLHTTP_NEGOTIATE:
+    case CURLAUTH_GSSNEGOTIATE:
 #ifdef GSSAPI
       /* Enable HTTP Negotaiate authentication */
-      data->set.httpdigest = FALSE;
-      data->set.httpnegotiate = TRUE;
-      data->set.httpntlm = FALSE;      
+      data->set.httpauth = auth;
       break;
 #else
       /* fall-through */
index a03e12d..c1e5979 100644 (file)
@@ -705,9 +705,9 @@ struct UserDefined {
   char *set_proxy;   /* proxy to use */
   long use_port;     /* which port to use (when not using default) */
   char *userpwd;     /* <user:password>, if used */
-  bool httpdigest;    /* if HTTP Digest authentication is enabled */
-  bool httpnegotiate; /* if HTTP Negotiate authentication is enabled */
-  bool httpntlm;      /* if HTTP NTLM authentication is enabled */
+
+  curl_httpauth httpauth; /* what kind of HTTP authentication to use */
+
   char *set_range;   /* range, if used. See README for detailed specification
                         on this syntax. */
   long followlocation; /* as in HTTP Location: */