File tree Expand file tree Collapse file tree 2 files changed +20
-8
lines changed Expand file tree Collapse file tree 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()
206206
207207#if ! NET46
208208 // 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 )
210210 {
211211 httpSubtransportRegistration = GlobalSettings . RegisterDefaultSmartSubtransport < ManagedHttpSmartSubtransport > ( "http" ) ;
212212 httpsSubtransportRegistration = GlobalSettings . RegisterDefaultSmartSubtransport < ManagedHttpSmartSubtransport > ( "https" ) ;
Original file line number Diff line number Diff line change @@ -22,6 +22,10 @@ public static class GlobalSettings
2222 private static bool nativeLibraryPathLocked ;
2323 private static string nativeLibraryDefaultPath ;
2424
25+ #if ! NET46
26+ private static bool useManagedHttpSmartSubtransport ;
27+ #endif
28+
2529 internal class SmartSubtransportData
2630 {
2731 internal bool isCustom ;
@@ -79,13 +83,11 @@ private static string GetExecutingAssemblyDirectory()
7983 /// Returns information related to the current LibGit2Sharp
8084 /// library.
8185 /// </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
8991
9092 private static SmartSubtransportData GetOrCreateSmartSubtransportData ( string scheme )
9193 {
@@ -541,5 +543,15 @@ public static string GetUserAgent()
541543 {
542544 return Proxy . git_libgit2_opts_get_user_agent ( ) ;
543545 }
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
544556 }
545557}
You can’t perform that action at this time.
0 commit comments