diff options
author | Carlos Martín Nieto <cmn@dwim.me> | 2015-06-24 17:27:16 +0200 |
---|---|---|
committer | Carlos Martín Nieto <cmn@dwim.me> | 2015-06-24 17:27:16 +0200 |
commit | 58ca8c7e1ff820b9deecbb1bbd34ad7408f47da9 (patch) | |
tree | e48ce889f19545186e3a887dea8955343ddd040e | |
parent | 8443f492dd53451c1c74f61c0e51ddb32c5e6ba0 (diff) | |
download | libgit2-58ca8c7e1ff820b9deecbb1bbd34ad7408f47da9.tar.gz |
SecureTransport: use the curl stream if availablecmn/curl-stream
If the libcurl stream is available, use that as the underlying stream
instead of the socket stream. This allows us to set a proxy for HTTPS
connections.
-rw-r--r-- | src/stransport_stream.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/stransport_stream.c b/src/stransport_stream.c index 34c38b22d..bbc2d32d6 100644 --- a/src/stransport_stream.c +++ b/src/stransport_stream.c @@ -14,6 +14,7 @@ #include "git2/transport.h" #include "socket_stream.h" +#include "curl_stream.h" int stransport_error(OSStatus ret) { @@ -115,6 +116,13 @@ int stransport_certificate(git_cert **out, git_stream *stream) return 0; } +int stransport_set_proxy(git_stream *stream, const char *proxy) +{ + stransport_stream *st = (stransport_stream *) stream; + + return git_stream_set_proxy(st->io, proxy); +} + /* * Contrary to typical network IO callbacks, Secure Transport write callback is * expected to write *all* passed data, not just as much as it can, and any @@ -233,7 +241,13 @@ int git_stransport_stream_new(git_stream **out, const char *host, const char *po st = git__calloc(1, sizeof(stransport_stream)); GITERR_CHECK_ALLOC(st); - if ((error = git_socket_stream_new(&st->io, host, port)) < 0){ +#ifdef GIT_CURL + error = git_curl_stream_new(&st->io, host, port); +#else + error = git_socket_stream_new(&st->io, host, port) +#endif + + if (error < 0){ git__free(st); return error; } @@ -256,8 +270,10 @@ int git_stransport_stream_new(git_stream **out, const char *host, const char *po st->parent.version = GIT_STREAM_VERSION; st->parent.encrypted = 1; + st->parent.proxy_support = git_stream_supports_proxy(st->io); st->parent.connect = stransport_connect; st->parent.certificate = stransport_certificate; + st->parent.set_proxy = stransport_set_proxy; st->parent.read = stransport_read; st->parent.write = stransport_write; st->parent.close = stransport_close; |