X-Git-Url: http://sjero.net/git/?p=wget;a=blobdiff_plain;f=src%2Fhttp.c;h=6cc46616e9ef39685d6fd2bb08a923c0f64c2a9b;hp=3a0481a2be3d3a8ca5103c909cb356b449cb1e8e;hb=4c1a59ea4807d3d27a41d82e7ab37b6ded92b355;hpb=70d762c4a43f912baa8c2df012afb0319acce043 diff --git a/src/http.c b/src/http.c index 3a0481a2..6cc46616 100644 --- a/src/http.c +++ b/src/http.c @@ -389,27 +389,35 @@ static struct hash_table *basic_authed_hosts; * it the username, password. A temporary measure until we can get * proper authentication in place. */ -static int +static bool maybe_send_basic_creds (const char *hostname, const char *user, const char *passwd, struct request *req) { - int did_challenge = 0; + bool do_challenge = false; - if (basic_authed_hosts + if (opt.auth_without_challenge) + { + DEBUGP(("Auth-without-challenge set, sending Basic credentials.\n")); + do_challenge = true; + } + else if (basic_authed_hosts && hash_table_contains(basic_authed_hosts, hostname)) { DEBUGP(("Found `%s' in basic_authed_hosts.\n", hostname)); - request_set_header (req, "Authorization", - basic_authentication_encode (user, passwd), - rel_value); - did_challenge = 1; + do_challenge = true; } else { DEBUGP(("Host `%s' has not issued a general basic challenge.\n", hostname)); } - return did_challenge; + if (do_challenge) + { + request_set_header (req, "Authorization", + basic_authentication_encode (user, passwd), + rel_value); + } + return do_challenge; } static void