mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-07 03:25:56 +00:00
SecureTransport: use the curl stream if available
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.
This commit is contained in:
parent
8443f492dd
commit
58ca8c7e1f
@ -14,6 +14,7 @@
|
|||||||
#include "git2/transport.h"
|
#include "git2/transport.h"
|
||||||
|
|
||||||
#include "socket_stream.h"
|
#include "socket_stream.h"
|
||||||
|
#include "curl_stream.h"
|
||||||
|
|
||||||
int stransport_error(OSStatus ret)
|
int stransport_error(OSStatus ret)
|
||||||
{
|
{
|
||||||
@ -115,6 +116,13 @@ int stransport_certificate(git_cert **out, git_stream *stream)
|
|||||||
return 0;
|
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
|
* 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
|
* 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));
|
st = git__calloc(1, sizeof(stransport_stream));
|
||||||
GITERR_CHECK_ALLOC(st);
|
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);
|
git__free(st);
|
||||||
return error;
|
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.version = GIT_STREAM_VERSION;
|
||||||
st->parent.encrypted = 1;
|
st->parent.encrypted = 1;
|
||||||
|
st->parent.proxy_support = git_stream_supports_proxy(st->io);
|
||||||
st->parent.connect = stransport_connect;
|
st->parent.connect = stransport_connect;
|
||||||
st->parent.certificate = stransport_certificate;
|
st->parent.certificate = stransport_certificate;
|
||||||
|
st->parent.set_proxy = stransport_set_proxy;
|
||||||
st->parent.read = stransport_read;
|
st->parent.read = stransport_read;
|
||||||
st->parent.write = stransport_write;
|
st->parent.write = stransport_write;
|
||||||
st->parent.close = stransport_close;
|
st->parent.close = stransport_close;
|
||||||
|
Loading…
Reference in New Issue
Block a user