diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2018-10-22 14:56:53 +0100 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2018-11-28 15:30:17 +0000 |
commit | 74c6e08e1d5a42a601985b8f42dded685537c59a (patch) | |
tree | 359239f736a6403278769c429c628e4463c302c2 /src/transports/http.c | |
parent | 496da38c531c3d2e1e682902eb6bf6dce4534c5a (diff) | |
download | libgit2-74c6e08e1d5a42a601985b8f42dded685537c59a.tar.gz |
http transport: provide proxy credentials
Diffstat (limited to 'src/transports/http.c')
-rw-r--r-- | src/transports/http.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/transports/http.c b/src/transports/http.c index 44b03d766..5619f7a7f 100644 --- a/src/transports/http.c +++ b/src/transports/http.c @@ -37,6 +37,9 @@ static const char *receive_pack_service_url = "/git-receive-pack"; static const char *get_verb = "GET"; static const char *post_verb = "POST"; +#define AUTH_HEADER_SERVER "Authorization" +#define AUTH_HEADER_PROXY "Proxy-Authorization" + #define SERVER_TYPE_REMOTE "remote" #define SERVER_TYPE_PROXY "proxy" @@ -179,7 +182,10 @@ static int auth_context_match( return 0; } -static int apply_credentials(git_buf *buf, http_server *server) +static int apply_credentials( + git_buf *buf, + http_server *server, + const char *header_name) { git_cred *cred = server->cred; git_http_auth_context *context; @@ -205,7 +211,7 @@ static int apply_credentials(git_buf *buf, http_server *server) if (!context) return 0; - return context->next_token(buf, context, cred); + return context->next_token(buf, context, header_name, cred); } static int gen_request( @@ -253,8 +259,9 @@ static int gen_request( git_buf_printf(buf, "%s\r\n", t->owner->custom_headers.strings[i]); } - /* Apply credentials to the request */ - if (apply_credentials(buf, &t->server) < 0) + /* Apply proxy and server credentials to the request */ + if (apply_credentials(buf, &t->proxy, AUTH_HEADER_PROXY) < 0 || + apply_credentials(buf, &t->server, AUTH_HEADER_SERVER) < 0) return -1; git_buf_puts(buf, "\r\n"); |