diff --git a/CHANGELOG.md b/CHANGELOG.md index 6161fec..1b83185 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.4.1] - 2024-05-07 + +## Changed + +- Use `SocketsHttpHandler` with `EnableMultipleHttp2Connections` as default HTTP message handler. + ## [1.4.0] ## Added diff --git a/Microsoft.Kiota.Http.HttpClientLibrary.Tests/KiotaClientFactoryTests.cs b/Microsoft.Kiota.Http.HttpClientLibrary.Tests/KiotaClientFactoryTests.cs index ff402ea..72c6812 100644 --- a/Microsoft.Kiota.Http.HttpClientLibrary.Tests/KiotaClientFactoryTests.cs +++ b/Microsoft.Kiota.Http.HttpClientLibrary.Tests/KiotaClientFactoryTests.cs @@ -68,6 +68,22 @@ public void ChainHandlersCollectionAndGetFirstLinkWithMultipleHandlersSetsFinalH Assert.IsType(innerHandler.InnerHandler); } + [Fact] + public void GetDefaultHttpMessageHandlerEnablesMultipleHttp2Connections() + { + // Act + var defaultHandler = KiotaClientFactory.GetDefaultHttpMessageHandler(); + // Assert + Assert.NotNull(defaultHandler); +#if NETFRAMEWORK + Assert.IsType(defaultHandler); + Assert.True(((WinHttpHandler)defaultHandler).EnableMultipleHttp2Connections); +#else + Assert.IsType(defaultHandler); + Assert.True(((SocketsHttpHandler)defaultHandler).EnableMultipleHttp2Connections); +#endif + } + [Fact] public void GetDefaultHttpMessageHandlerSetsUpProxy() { @@ -81,10 +97,9 @@ public void GetDefaultHttpMessageHandlerSetsUpProxy() Assert.IsType(defaultHandler); Assert.Equal(proxy, ((WinHttpHandler)defaultHandler).Proxy); #else - Assert.IsType(defaultHandler); - Assert.Equal(proxy, ((HttpClientHandler)defaultHandler).Proxy); + Assert.IsType(defaultHandler); + Assert.Equal(proxy, ((SocketsHttpHandler)defaultHandler).Proxy); #endif - } [Fact] diff --git a/src/KiotaClientFactory.cs b/src/KiotaClientFactory.cs index f1a9a4c..0439561 100644 --- a/src/KiotaClientFactory.cs +++ b/src/KiotaClientFactory.cs @@ -104,7 +104,9 @@ public static HttpMessageHandler GetDefaultHttpMessageHandler(IWebProxy? proxy = // If custom proxy is passed, the WindowsProxyUsePolicy will need updating // https://github.com/dotnet/runtime/blob/main/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpHandler.cs#L575 var proxyPolicy = proxy != null ? WindowsProxyUsePolicy.UseCustomProxy : WindowsProxyUsePolicy.UseWinHttpProxy; - return new WinHttpHandler { Proxy = proxy, AutomaticDecompression = DecompressionMethods.None , WindowsProxyUsePolicy = proxyPolicy, SendTimeout = System.Threading.Timeout.InfiniteTimeSpan, ReceiveDataTimeout = System.Threading.Timeout.InfiniteTimeSpan, ReceiveHeadersTimeout = System.Threading.Timeout.InfiniteTimeSpan }; + return new WinHttpHandler { Proxy = proxy, AutomaticDecompression = DecompressionMethods.None, WindowsProxyUsePolicy = proxyPolicy, SendTimeout = System.Threading.Timeout.InfiniteTimeSpan, ReceiveDataTimeout = System.Threading.Timeout.InfiniteTimeSpan, ReceiveHeadersTimeout = System.Threading.Timeout.InfiniteTimeSpan, EnableMultipleHttp2Connections = true }; +#elif NET5_0_OR_GREATER + return new SocketsHttpHandler { Proxy = proxy, AllowAutoRedirect = false, EnableMultipleHttp2Connections = true }; #else return new HttpClientHandler { Proxy = proxy, AllowAutoRedirect = false }; #endif diff --git a/src/Microsoft.Kiota.Http.HttpClientLibrary.csproj b/src/Microsoft.Kiota.Http.HttpClientLibrary.csproj index 6da462c..e62ba44 100644 --- a/src/Microsoft.Kiota.Http.HttpClientLibrary.csproj +++ b/src/Microsoft.Kiota.Http.HttpClientLibrary.csproj @@ -15,7 +15,7 @@ https://aka.ms/kiota/docs true true - 1.4.0 + 1.4.1 true