]> sjero.net Git - wget/blobdiff - src/http.c
Fix #22242: Option to allow auths before challenged.
[wget] / src / http.c
index 3a0481a2be3d3a8ca5103c909cb356b449cb1e8e..6cc46616e9ef39685d6fd2bb08a923c0f64c2a9b 100644 (file)
@@ -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