diff options
author | Matt Burke <spraints@gmail.com> | 2015-09-08 13:38:22 -0400 |
---|---|---|
committer | Matt Burke <spraints@gmail.com> | 2015-09-08 14:04:59 -0400 |
commit | 80ee25434d076b87d1a34e2dee467600013ae4ee (patch) | |
tree | 72b6a4d972c1bc683e1a8a31a1e59f21ca99ead3 | |
parent | 276f6aa08d4cb35ad647b24bfa254b99af89e076 (diff) | |
download | libgit2-80ee25434d076b87d1a34e2dee467600013ae4ee.tar.gz |
Teach winhttp about the extra headers
-rw-r--r-- | src/transports/winhttp.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/transports/winhttp.c b/src/transports/winhttp.c index 0c43c4b0b..d28762db1 100644 --- a/src/transports/winhttp.c +++ b/src/transports/winhttp.c @@ -409,6 +409,23 @@ static int winhttp_stream_connect(winhttp_stream *s) } } + if (t->owner->custom_headers) { + for (i = 0; i < t->owner->custom_headers->count; i++) { + git_buf_clear(&buf); + git_buf_puts(&buf, t->owner->custom_headers->strings[i]); + if (git__utf8_to_16(ct, MAX_CONTENT_TYPE_LEN, git_buf_cstr(&buf)) < 0) { + giterr_set(GITERR_OS, "Failed to convert custom header to wide characters"); + goto on_error; + } + + if (!WinHttpAddRequestHeaders(s->request, ct, (ULONG)-1L, + WINHTTP_ADDREQ_FLAG_ADD | WINHTTP_ADDREQ_FLAG_REPLACE)) { + giterr_set(GITERR_OS, "Failed to add a header to the request"); + goto on_error; + } + } + } + /* If requested, disable certificate validation */ if (t->connection_data.use_ssl) { int flags; |