diff options
author | Junio C Hamano <gitster@pobox.com> | 2012-04-27 13:57:49 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2012-04-27 13:57:49 -0700 |
commit | 157a4767a56e37def5e156b60f03ee220208d8fb (patch) | |
tree | 6ec9c8cf5c2cc3c0a34354e4832d70056a2c5930 /http.c | |
parent | 010b260e6f23b8964ef53b989e1c1baa8973edbe (diff) | |
parent | 6f4c347ca1d3102d77e2dd36b6bc8ab12de6045b (diff) |
Merge branch 'cb/http-multi-curl-auth'
Fixes http authentication breakage when we keep multiple HTTP requests in
flight using curl-multi.
By Jeff King (3) and Clemens Buchacher (1)
* cb/http-multi-curl-auth:
http: use newer curl options for setting credentials
http: clean up leak in init_curl_http_auth
fix http auth with multiple curl handles
http auth fails with multiple curl handles
Diffstat (limited to 'http.c')
-rw-r--r-- | http.c | 21 |
1 files changed, 16 insertions, 5 deletions
@@ -210,14 +210,23 @@ static int http_options(const char *var, const char *value, void *cb) static void init_curl_http_auth(CURL *result) { - if (http_auth.username) { - struct strbuf up = STRBUF_INIT; - credential_fill(&http_auth); + if (!http_auth.username) + return; + + credential_fill(&http_auth); + +#if LIBCURL_VERSION_NUM >= 0x071301 + curl_easy_setopt(result, CURLOPT_USERNAME, http_auth.username); + curl_easy_setopt(result, CURLOPT_PASSWORD, http_auth.password); +#else + { + static struct strbuf up = STRBUF_INIT; + strbuf_reset(&up); strbuf_addf(&up, "%s:%s", http_auth.username, http_auth.password); - curl_easy_setopt(result, CURLOPT_USERPWD, - strbuf_detach(&up, NULL)); + curl_easy_setopt(result, CURLOPT_USERPWD, up.buf); } +#endif } static int has_cert_password(void) @@ -494,6 +503,8 @@ struct active_request_slot *get_active_slot(void) curl_easy_setopt(slot->curl, CURLOPT_POSTFIELDS, NULL); curl_easy_setopt(slot->curl, CURLOPT_UPLOAD, 0); curl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1); + if (http_auth.password) + init_curl_http_auth(slot->curl); return slot; } |