Unverified Commit 03ac24b1 by Patrick Steinhardt Committed by GitHub

Merge pull request #5387 from pks-t/pks/transport-http-custom-headers

transports: http: fix custom headers not being applied
parents 65ac33ae 46228d86
...@@ -346,6 +346,7 @@ static int generate_request( ...@@ -346,6 +346,7 @@ static int generate_request(
request->credentials = transport->server.cred; request->credentials = transport->server.cred;
request->proxy = use_proxy ? &transport->proxy.url : NULL; request->proxy = use_proxy ? &transport->proxy.url : NULL;
request->proxy_credentials = transport->proxy.cred; request->proxy_credentials = transport->proxy.cred;
request->custom_headers = &transport->owner->custom_headers;
if (stream->service->method == GIT_HTTP_METHOD_POST) { if (stream->service->method == GIT_HTTP_METHOD_POST) {
request->chunked = stream->service->chunked; request->chunked = stream->service->chunked;
......
...@@ -392,6 +392,21 @@ void test_online_clone__credentials(void) ...@@ -392,6 +392,21 @@ void test_online_clone__credentials(void)
cl_fixture_cleanup("./foo"); cl_fixture_cleanup("./foo");
} }
void test_online_clone__credentials_via_custom_headers(void)
{
const char *creds = "libgit3:libgit3";
git_buf auth = GIT_BUF_INIT;
cl_git_pass(git_buf_puts(&auth, "Authorization: Basic "));
cl_git_pass(git_buf_encode_base64(&auth, creds, strlen(creds)));
g_options.fetch_opts.custom_headers.count = 1;
g_options.fetch_opts.custom_headers.strings = &auth.ptr;
cl_git_pass(git_clone(&g_repo, "https://bitbucket.org/libgit2/testgitrepository.git", "./foo", &g_options));
git_buf_dispose(&auth);
}
void test_online_clone__bitbucket_style(void) void test_online_clone__bitbucket_style(void)
{ {
git_credential_userpass_payload user_pass = { git_credential_userpass_payload user_pass = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment