diff options
author | Patrick Steinhardt <ps@pks.im> | 2020-02-07 11:36:36 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-07 11:36:36 +0100 |
commit | 03ac24b1195e1ffb69a242eb77acce903812f032 (patch) | |
tree | dd255c42b9a4b5d08c6c366458cb899a800590a9 | |
parent | 65ac33aeb165a41ebc83836a25b97755d6deee58 (diff) | |
parent | 46228d86f876f0602cff5b08af8531b758bdf6ac (diff) | |
download | libgit2-03ac24b1195e1ffb69a242eb77acce903812f032.tar.gz |
Merge pull request #5387 from pks-t/pks/transport-http-custom-headers
transports: http: fix custom headers not being applied
-rw-r--r-- | src/transports/http.c | 1 | ||||
-rw-r--r-- | tests/online/clone.c | 15 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/transports/http.c b/src/transports/http.c index 294bab5dc..66731b0ce 100644 --- a/src/transports/http.c +++ b/src/transports/http.c @@ -346,6 +346,7 @@ static int generate_request( request->credentials = transport->server.cred; request->proxy = use_proxy ? &transport->proxy.url : NULL; request->proxy_credentials = transport->proxy.cred; + request->custom_headers = &transport->owner->custom_headers; if (stream->service->method == GIT_HTTP_METHOD_POST) { request->chunked = stream->service->chunked; diff --git a/tests/online/clone.c b/tests/online/clone.c index f780f1371..034d0c2e8 100644 --- a/tests/online/clone.c +++ b/tests/online/clone.c @@ -392,6 +392,21 @@ void test_online_clone__credentials(void) 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) { git_credential_userpass_payload user_pass = { |