3
3
using System . Linq ;
4
4
using System . Net ;
5
5
using System . Net . Http ;
6
- using System . Net . Security ;
7
6
using System . Security . Authentication ;
8
- using System . Security . Cryptography . X509Certificates ;
9
7
10
8
namespace LibGit2Sharp . Core
11
9
{
@@ -49,7 +47,12 @@ private class ManagedHttpSmartSubtransportStream : SmartSubtransportStream
49
47
{
50
48
private static int MAX_REDIRECTS = 7 ;
51
49
52
- private static readonly HttpClientHandler httpClientHandler ;
50
+ #if NETCOREAPP
51
+ private static readonly SocketsHttpHandler httpHandler ;
52
+ #else
53
+ private static readonly HttpClientHandler httpHandler ;
54
+ #endif
55
+
53
56
private static readonly CredentialCache credentialCache ;
54
57
55
58
private MemoryStream postBuffer = new MemoryStream ( ) ;
@@ -58,14 +61,18 @@ private class ManagedHttpSmartSubtransportStream : SmartSubtransportStream
58
61
59
62
static ManagedHttpSmartSubtransportStream ( )
60
63
{
61
- httpClientHandler = new HttpClientHandler ( ) ;
62
-
63
- httpClientHandler . SslProtocols |= SslProtocols . Tls12 ;
64
+ #if NETCOREAPP
65
+ httpHandler = new SocketsHttpHandler ( ) ;
66
+ httpHandler . PooledConnectionLifetime = TimeSpan . FromMinutes ( 5 ) ;
67
+ #else
68
+ httpHandler = new HttpClientHandler ( ) ;
69
+ httpHandler . SslProtocols |= SslProtocols . Tls12 ;
70
+ #endif
64
71
65
- httpClientHandler . AllowAutoRedirect = false ;
72
+ httpHandler . AllowAutoRedirect = false ;
66
73
67
74
credentialCache = new CredentialCache ( ) ;
68
- httpClientHandler . Credentials = credentialCache ;
75
+ httpHandler . Credentials = credentialCache ;
69
76
}
70
77
71
78
public ManagedHttpSmartSubtransportStream ( ManagedHttpSmartSubtransport parent , string endpointUrl , bool isPost , string contentType )
@@ -150,7 +157,7 @@ private HttpResponseMessage GetResponseWithRedirects()
150
157
151
158
for ( retries = 0 ; ; retries ++ )
152
159
{
153
- using ( var httpClient = CreateHttpClient ( httpClientHandler ) )
160
+ using ( var httpClient = CreateHttpClient ( httpHandler ) )
154
161
{
155
162
var request = CreateRequest ( url , IsPost ) ;
156
163
0 commit comments