aboutsummaryrefslogtreecommitdiff
path: root/lib/http.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2004-01-09 14:03:06 +0000
committerDaniel Stenberg <daniel@haxx.se>2004-01-09 14:03:06 +0000
commit44031f32a149e9d4097b77c1e998db03887d209c (patch)
tree0f35af18be77f09427d89592c476282ec6361551 /lib/http.c
parent723722110847cd081e74fbb134adbf8c7abd86c2 (diff)
added one assert and a few comments describing how the auth stuff works
Diffstat (limited to 'lib/http.c')
-rw-r--r--lib/http.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/lib/http.c b/lib/http.c
index a992fd421..6002ad977 100644
--- a/lib/http.c
+++ b/lib/http.c
@@ -158,11 +158,19 @@ static CURLcode Curl_output_basic_proxy(struct connectdata *conn)
return CURLE_OK;
}
+/*
+ * Curl_http_auth_act() checks what authentication methods that are available
+ * and decides which one (if any) to use. It will set 'newurl' if an auth
+ * metod was picked.
+ */
+
void Curl_http_auth_act(struct connectdata *conn)
{
struct SessionHandle *data = conn->data;
if(data->state.authavail) {
+ /* The order of these checks is highly relevant, as this will be the order
+ of preference in case of the existance of multiple accepted types. */
if(data->state.authavail & CURLAUTH_GSSNEGOTIATE)
data->state.authwant = CURLAUTH_GSSNEGOTIATE;
else if(data->state.authavail & CURLAUTH_DIGEST)
@@ -341,6 +349,15 @@ CURLcode Curl_http_auth(struct connectdata *conn,
while(*start && isspace((int)*start))
start++;
+ /*
+ * Here we check if we want the specific single authentiction (using ==) and
+ * if we do, we initiate usage of it.
+ *
+ * If the provided authentication is wanted as one out of several accepted
+ * types (using &), we OR this authenticaion type to the authavail
+ * variable.
+ */
+
#ifdef HAVE_GSSAPI
if (checkprefix("GSS-Negotiate", start) ||
checkprefix("Negotiate", start)) {
@@ -1013,14 +1030,15 @@ CURLcode Curl_http_done(struct connectdata *conn)
void Curl_http_auth_stage(struct SessionHandle *data,
int stage)
{
- if(stage == 401)
- data->state.authwant = data->set.httpauth;
- else if(stage == 407)
- data->state.authwant = data->set.proxyauth;
- else
- return; /* bad input stage */
+ curlassert((stage == 401) || (stage == 407));
+
+ /* We set none, one or more bits for which authentication types we accept
+ for this stage. */
+ data->state.authwant = (stage == 401)?
+ data->set.httpauth:data->set.proxyauth;
+
data->state.authstage = stage;
- data->state.authavail = CURLAUTH_NONE;
+ data->state.authavail = CURLAUTH_NONE; /* no type available yet */
}
CURLcode Curl_http(struct connectdata *conn)