aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/curl/curl.h10
-rw-r--r--lib/http.c2
-rw-r--r--lib/transfer.c13
-rw-r--r--lib/url.c26
-rw-r--r--lib/urldata.h6
5 files changed, 23 insertions, 34 deletions
diff --git a/include/curl/curl.h b/include/curl/curl.h
index 0d590d6ab..7ae5560c2 100644
--- a/include/curl/curl.h
+++ b/include/curl/curl.h
@@ -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
diff --git a/lib/http.c b/lib/http.c
index b06de06a8..2c1bb292f 100644
--- a/lib/http.c
+++ b/lib/http.c
@@ -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;
diff --git a/lib/transfer.c b/lib/transfer.c
index 8d59653c5..890af24e8 100644
--- a/lib/transfer.c
+++ b/lib/transfer.c
@@ -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)
diff --git a/lib/url.c b/lib/url.c
index f02eec0cc..397d1d452 100644
--- 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 */
diff --git a/lib/urldata.h b/lib/urldata.h
index a03e12d26..c1e597971 100644
--- a/lib/urldata.h
+++ b/lib/urldata.h
@@ -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: */