summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2015-06-07 14:51:10 +0200
committerCarlos Martín Nieto <cmn@dwim.me>2015-06-24 17:26:36 +0200
commit8762d721f4cff582356a1591e220463c9ca1d389 (patch)
tree7c8fcc7cdcd986b80ea940d0b746ff7781aafccf
parent1376e784c63bc63492a9ba04d5e1f07654deba60 (diff)
downloadlibgit2-8762d721f4cff582356a1591e220463c9ca1d389.tar.gz
http: set the proxy if the stream supports it
Of the built-in ones, only cURL support it, but there's no reason a user-provided stream wouldn't support it.
-rw-r--r--src/transports/http.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/transports/http.c b/src/transports/http.c
index 8cf011f4c..be8faca16 100644
--- a/src/transports/http.c
+++ b/src/transports/http.c
@@ -10,6 +10,7 @@
#include "http_parser.h"
#include "buffer.h"
#include "netops.h"
+#include "remote.h"
#include "smart.h"
#include "auth.h"
#include "auth_negotiate.h"
@@ -533,6 +534,7 @@ static int write_chunk(git_stream *io, const char *buffer, size_t len)
static int http_connect(http_subtransport *t)
{
int error;
+ char *proxy_url;
if (t->connected &&
http_should_keep_alive(&t->parser) &&
@@ -560,6 +562,15 @@ static int http_connect(http_subtransport *t)
GITERR_CHECK_VERSION(t->io, GIT_STREAM_VERSION, "git_stream");
+ if (git_stream_supports_proxy(t->io) &&
+ !git_remote__get_http_proxy(t->owner->owner, !!t->connection_data.use_ssl, &proxy_url)) {
+ error = git_stream_set_proxy(t->io, proxy_url);
+ git__free(proxy_url);
+
+ if (error < 0)
+ return error;
+ }
+
error = git_stream_connect(t->io);
#if defined(GIT_OPENSSL) || defined(GIT_SECURE_TRANSPORT) || defined(GIT_CURL)