Merge branch 'cb/http-multi-curl-auth' into maint
HTTP transport that requires authentication did not work correctly when multiple connections are used simultaneously. 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
This commit is contained in:
commit
c968338042
21
http.c
21
http.c
@ -210,14 +210,23 @@ static int http_options(const char *var, const char *value, void *cb)
|
|||||||
|
|
||||||
static void init_curl_http_auth(CURL *result)
|
static void init_curl_http_auth(CURL *result)
|
||||||
{
|
{
|
||||||
if (http_auth.username) {
|
if (!http_auth.username)
|
||||||
struct strbuf up = STRBUF_INIT;
|
return;
|
||||||
credential_fill(&http_auth);
|
|
||||||
|
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",
|
strbuf_addf(&up, "%s:%s",
|
||||||
http_auth.username, http_auth.password);
|
http_auth.username, http_auth.password);
|
||||||
curl_easy_setopt(result, CURLOPT_USERPWD,
|
curl_easy_setopt(result, CURLOPT_USERPWD, up.buf);
|
||||||
strbuf_detach(&up, NULL));
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static int has_cert_password(void)
|
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_POSTFIELDS, NULL);
|
||||||
curl_easy_setopt(slot->curl, CURLOPT_UPLOAD, 0);
|
curl_easy_setopt(slot->curl, CURLOPT_UPLOAD, 0);
|
||||||
curl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1);
|
curl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1);
|
||||||
|
if (http_auth.password)
|
||||||
|
init_curl_http_auth(slot->curl);
|
||||||
|
|
||||||
return slot;
|
return slot;
|
||||||
}
|
}
|
||||||
|
@ -13,17 +13,22 @@ LIB_HTTPD_PORT=${LIB_HTTPD_PORT-'5550'}
|
|||||||
start_httpd
|
start_httpd
|
||||||
|
|
||||||
test_expect_success 'setup repository' '
|
test_expect_success 'setup repository' '
|
||||||
echo content >file &&
|
echo content1 >file &&
|
||||||
git add file &&
|
git add file &&
|
||||||
git commit -m one
|
git commit -m one
|
||||||
|
echo content2 >file &&
|
||||||
|
git add file &&
|
||||||
|
git commit -m two
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'create http-accessible bare repository' '
|
test_expect_success 'create http-accessible bare repository with loose objects' '
|
||||||
mkdir "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
|
cp -a .git "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
|
||||||
(cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
|
(cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
|
||||||
git --bare init &&
|
git config core.bare true &&
|
||||||
|
mkdir -p hooks &&
|
||||||
echo "exec git update-server-info" >hooks/post-update &&
|
echo "exec git update-server-info" >hooks/post-update &&
|
||||||
chmod +x hooks/post-update
|
chmod +x hooks/post-update &&
|
||||||
|
hooks/post-update
|
||||||
) &&
|
) &&
|
||||||
git remote add public "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
|
git remote add public "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
|
||||||
git push public master:master
|
git push public master:master
|
||||||
|
Loading…
Reference in New Issue
Block a user