@@ -515,18 +515,18 @@ static int curl_empty_auth_enabled(void)
return 0;
}
-static void init_curl_http_auth(CURL *result)
+static void init_curl_http_auth(struct active_request_slot *slot)
{
if (!http_auth.username || !*http_auth.username) {
if (curl_empty_auth_enabled())
- curl_easy_setopt(result, CURLOPT_USERPWD, ":");
+ curl_easy_setopt(slot->curl, CURLOPT_USERPWD, ":");
return;
}
credential_fill(&http_auth);
- curl_easy_setopt(result, CURLOPT_USERNAME, http_auth.username);
- curl_easy_setopt(result, CURLOPT_PASSWORD, http_auth.password);
+ curl_easy_setopt(slot->curl, CURLOPT_USERNAME, http_auth.username);
+ curl_easy_setopt(slot->curl, CURLOPT_PASSWORD, http_auth.password);
}
/* *var must be free-able */
@@ -901,9 +901,6 @@ static CURL *get_curl_handle(void)
#endif
}
- if (http_proactive_auth)
- init_curl_http_auth(result);
-
if (getenv("GIT_SSL_VERSION"))
ssl_version = getenv("GIT_SSL_VERSION");
if (ssl_version && *ssl_version) {
@@ -1260,6 +1257,7 @@ struct active_request_slot *get_active_slot(int no_pragma_header)
struct active_request_slot *slot = active_queue_head;
struct active_request_slot *newslot;
+ int proactive_auth = 0;
int num_transfers;
/* Wait for a slot to open up if the queue is full */
@@ -1282,6 +1280,9 @@ struct active_request_slot *get_active_slot(int no_pragma_header)
slot = active_queue_head;
if (!slot) {
active_queue_head = newslot;
+
+ /* Auth first slot if asked for proactive auth */
+ proactive_auth = http_proactive_auth;
} else {
while (slot->next != NULL)
slot = slot->next;
@@ -1336,8 +1337,9 @@ struct active_request_slot *get_active_slot(int no_pragma_header)
curl_easy_setopt(slot->curl, CURLOPT_IPRESOLVE, git_curl_ipresolve);
curl_easy_setopt(slot->curl, CURLOPT_HTTPAUTH, http_auth_methods);
- if (http_auth.password || curl_empty_auth_enabled())
- init_curl_http_auth(slot->curl);
+
+ if (http_auth.password || curl_empty_auth_enabled() || proactive_auth)
+ init_curl_http_auth(slot);
return slot;
}