Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8443f49

Browse files
committed
curl: remove the encrypted param to the constructor
We do not want libcurl to perform the TLS negotiation for us, so we don't need to pass this option.
1 parent f97d5d0 commit 8443f49

File tree

4 files changed

+6
-14
lines changed

4 files changed

+6
-14
lines changed

src/curl_stream.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ static void curls_free(git_stream *stream)
195195
git__free(s);
196196
}
197197

198-
int git_curl_stream_new(git_stream **out, const char *host, const char *port, int encrypted)
198+
int git_curl_stream_new(git_stream **out, const char *host, const char *port)
199199
{
200200
curl_stream *st;
201201
CURL *handle;
@@ -213,15 +213,7 @@ int git_curl_stream_new(git_stream **out, const char *host, const char *port, in
213213
if ((error = git__strtol32(&iport, port, NULL, 10)) < 0)
214214
return error;
215215

216-
if (encrypted) {
217-
git_buf buf = GIT_BUF_INIT;
218-
git_buf_printf(&buf, "https://%s", host);
219-
curl_easy_setopt(handle, CURLOPT_URL, buf.ptr);
220-
git_buf_free(&buf);
221-
} else {
222-
curl_easy_setopt(handle, CURLOPT_URL, host);
223-
}
224-
216+
curl_easy_setopt(handle, CURLOPT_URL, host);
225217
curl_easy_setopt(handle, CURLOPT_ERRORBUFFER, st->curl_error);
226218
curl_easy_setopt(handle, CURLOPT_PORT, iport);
227219
curl_easy_setopt(handle, CURLOPT_CONNECT_ONLY, 1);
@@ -232,7 +224,7 @@ int git_curl_stream_new(git_stream **out, const char *host, const char *port, in
232224
/* curl_easy_setopt(handle, CURLOPT_VERBOSE, 1); */
233225

234226
st->parent.version = GIT_STREAM_VERSION;
235-
st->parent.encrypted = encrypted;
227+
st->parent.encrypted = 0; /* we don't encrypt ourselves */
236228
st->parent.proxy_support = 1;
237229
st->parent.connect = curls_connect;
238230
st->parent.certificate = curls_certificate;

src/curl_stream.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99

1010
#include "git2/sys/stream.h"
1111

12-
extern int git_curl_stream_new(git_stream **out, const char *host, const char *port, bool encrypted);
12+
extern int git_curl_stream_new(git_stream **out, const char *host, const char *port);
1313

1414
#endif

src/openssl_stream.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ int git_openssl_stream_new(git_stream **out, const char *host, const char *port)
427427
GITERR_CHECK_ALLOC(st);
428428

429429
#ifdef GIT_CURL
430-
error = git_curl_stream_new(&st->io, host, port, false);
430+
error = git_curl_stream_new(&st->io, host, port);
431431
#else
432432
error = git_socket_stream_new(&st->io, host, port)
433433
#endif

src/transports/http.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ static int http_connect(http_subtransport *t)
551551
error = git_tls_stream_new(&t->io, t->connection_data.host, t->connection_data.port);
552552
} else {
553553
#ifdef GIT_CURL
554-
error = git_curl_stream_new(&t->io, t->connection_data.host, t->connection_data.port, false);
554+
error = git_curl_stream_new(&t->io, t->connection_data.host, t->connection_data.port);
555555
#else
556556
error = git_socket_stream_new(&t->io, t->connection_data.host, t->connection_data.port);
557557
#endif

0 commit comments

Comments
 (0)