File tree 2 files changed +20
-8
lines changed 2 files changed +20
-8
lines changed Original file line number Diff line number Diff line change @@ -206,7 +206,7 @@ private static void InitializeNativeLibrary()
206
206
207
207
#if ! NET46
208
208
// Configure the .NET HTTP(S) mechanism on the first initialization of the library in the current process.
209
- if ( initCounter == 1 )
209
+ if ( initCounter == 1 && GlobalSettings . ManagedHttpSmartSubtransportEnabled )
210
210
{
211
211
httpSubtransportRegistration = GlobalSettings . RegisterDefaultSmartSubtransport < ManagedHttpSmartSubtransport > ( "http" ) ;
212
212
httpsSubtransportRegistration = GlobalSettings . RegisterDefaultSmartSubtransport < ManagedHttpSmartSubtransport > ( "https" ) ;
Original file line number Diff line number Diff line change @@ -22,6 +22,10 @@ public static class GlobalSettings
22
22
private static bool nativeLibraryPathLocked ;
23
23
private static string nativeLibraryDefaultPath ;
24
24
25
+ #if ! NET46
26
+ private static bool useManagedHttpSmartSubtransport ;
27
+ #endif
28
+
25
29
internal class SmartSubtransportData
26
30
{
27
31
internal bool isCustom ;
@@ -79,13 +83,11 @@ private static string GetExecutingAssemblyDirectory()
79
83
/// Returns information related to the current LibGit2Sharp
80
84
/// library.
81
85
/// </summary>
82
- public static Version Version
83
- {
84
- get
85
- {
86
- return version . Value ;
87
- }
88
- }
86
+ public static Version Version => version . Value ;
87
+
88
+ #if ! NET46
89
+ internal static bool ManagedHttpSmartSubtransportEnabled => RuntimeInformation . IsOSPlatform ( OSPlatform . Linux ) || useManagedHttpSmartSubtransport ;
90
+ #endif
89
91
90
92
private static SmartSubtransportData GetOrCreateSmartSubtransportData ( string scheme )
91
93
{
@@ -541,5 +543,15 @@ public static string GetUserAgent()
541
543
{
542
544
return Proxy . git_libgit2_opts_get_user_agent ( ) ;
543
545
}
546
+
547
+ #if ! NET46
548
+ /// <summary>
549
+ /// Enables the managed http implementation. This is enabled autmatically on Linux, so this method is only needed when running on Windows or macOS.
550
+ /// </summary>
551
+ public static void UseManagedHttpSmartSubtransport ( )
552
+ {
553
+ useManagedHttpSmartSubtransport = true ;
554
+ }
555
+ #endif
544
556
}
545
557
}
You can’t perform that action at this time.
0 commit comments