From 39c5213153b9decb5e38c420bc94f99ad939963d Mon Sep 17 00:00:00 2001 From: ghelyar <3225358+ghelyar@users.noreply.github.com> Date: Mon, 6 May 2024 18:40:24 +0100 Subject: [PATCH 1/5] Use SocketsHttpHandler and EnableMultipleHttp2Connections as default final handler --- .../KiotaClientFactoryTests.cs | 23 ++++++++++++++++--- src/KiotaClientFactory.cs | 4 +++- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/Microsoft.Kiota.Http.HttpClientLibrary.Tests/KiotaClientFactoryTests.cs b/Microsoft.Kiota.Http.HttpClientLibrary.Tests/KiotaClientFactoryTests.cs index ff402ea..f3180b4 100644 --- a/Microsoft.Kiota.Http.HttpClientLibrary.Tests/KiotaClientFactoryTests.cs +++ b/Microsoft.Kiota.Http.HttpClientLibrary.Tests/KiotaClientFactoryTests.cs @@ -68,6 +68,24 @@ public void ChainHandlersCollectionAndGetFirstLinkWithMultipleHandlersSetsFinalH Assert.IsType(innerHandler.InnerHandler); } + [Fact] + public void GetDefaultHttpMessageHandlerEnablesMultipleHttp2Connections() + { + // Arrange + var proxy = new WebProxy("http://localhost:8888", false); + // Act + var defaultHandler = KiotaClientFactory.GetDefaultHttpMessageHandler(proxy); + // 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 +99,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 From b8bd946e892d29c43d0337cdfb4f7111acb46e52 Mon Sep 17 00:00:00 2001 From: ghelyar <3225358+ghelyar@users.noreply.github.com> Date: Tue, 7 May 2024 10:31:46 +0100 Subject: [PATCH 2/5] remove unnecessary arrange from test --- .../KiotaClientFactoryTests.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Microsoft.Kiota.Http.HttpClientLibrary.Tests/KiotaClientFactoryTests.cs b/Microsoft.Kiota.Http.HttpClientLibrary.Tests/KiotaClientFactoryTests.cs index f3180b4..72c6812 100644 --- a/Microsoft.Kiota.Http.HttpClientLibrary.Tests/KiotaClientFactoryTests.cs +++ b/Microsoft.Kiota.Http.HttpClientLibrary.Tests/KiotaClientFactoryTests.cs @@ -71,10 +71,8 @@ public void ChainHandlersCollectionAndGetFirstLinkWithMultipleHandlersSetsFinalH [Fact] public void GetDefaultHttpMessageHandlerEnablesMultipleHttp2Connections() { - // Arrange - var proxy = new WebProxy("http://localhost:8888", false); // Act - var defaultHandler = KiotaClientFactory.GetDefaultHttpMessageHandler(proxy); + var defaultHandler = KiotaClientFactory.GetDefaultHttpMessageHandler(); // Assert Assert.NotNull(defaultHandler); #if NETFRAMEWORK From 8e24a934893747f1829b0acb96dc6e7529f0e1f7 Mon Sep 17 00:00:00 2001 From: ghelyar <3225358+ghelyar@users.noreply.github.com> Date: Tue, 7 May 2024 16:49:01 +0100 Subject: [PATCH 3/5] update version number to 1.4.1 with changelog --- src/Microsoft.Kiota.Http.HttpClientLibrary.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 33a7832ffc04723f23303fda565884beda19852c Mon Sep 17 00:00:00 2001 From: ghelyar <3225358+ghelyar@users.noreply.github.com> Date: Tue, 7 May 2024 16:49:17 +0100 Subject: [PATCH 4/5] changelog --- CHANGELOG.md | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6161fec..977dfdd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,16 +7,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -## [1.4.0] - -## Added - -- KiotaClientFactory `create()` overload that accepts a list of handlers. - +## [1.4.1] - 2024-05-07 + +## Changed + +- Use `SocketsHttpHandler` with `EnableMultipleHttp2Connections` as default HTTP message handler. + +## [1.4.0] + +## Added + +- KiotaClientFactory `create()` overload that accepts a list of handlers. + ## [1.3.12] - 2024-04-22 - UriReplacementHandler improvements to be added to middleware pipeline by default and respects options set in the HttpRequestMessage (https://github.com/microsoft/kiota-http-dotnet/issues/242) -- Adds `ConfigureAwait(false)` calls to async calls (https://github.com/microsoft/kiota-http-dotnet/issues/240). +- Adds `ConfigureAwait(false)` calls to async calls (https://github.com/microsoft/kiota-http-dotnet/issues/240). ## [1.3.11] - 2024-04-19 @@ -28,7 +34,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Changed -- Have made System.* dependencies only be included on Net Standard's TFM & net 5 (https://github.com/microsoft/kiota-http-dotnet/issues/230) +- Have made System.\* dependencies only be included on Net Standard's TFM & net 5 (https://github.com/microsoft/kiota-http-dotnet/issues/230) ## [1.3.9] - 2024-04-17 From 285203c0733b509134700040d1fd23876e460f5d Mon Sep 17 00:00:00 2001 From: ghelyar <3225358+ghelyar@users.noreply.github.com> Date: Tue, 7 May 2024 16:57:09 +0100 Subject: [PATCH 5/5] revert unintentional changes to other lines of changelog --- CHANGELOG.md | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 977dfdd..1b83185 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,22 +7,22 @@ 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 - -- KiotaClientFactory `create()` overload that accepts a list of handlers. - +## [1.4.1] - 2024-05-07 + +## Changed + +- Use `SocketsHttpHandler` with `EnableMultipleHttp2Connections` as default HTTP message handler. + +## [1.4.0] + +## Added + +- KiotaClientFactory `create()` overload that accepts a list of handlers. + ## [1.3.12] - 2024-04-22 - UriReplacementHandler improvements to be added to middleware pipeline by default and respects options set in the HttpRequestMessage (https://github.com/microsoft/kiota-http-dotnet/issues/242) -- Adds `ConfigureAwait(false)` calls to async calls (https://github.com/microsoft/kiota-http-dotnet/issues/240). +- Adds `ConfigureAwait(false)` calls to async calls (https://github.com/microsoft/kiota-http-dotnet/issues/240). ## [1.3.11] - 2024-04-19 @@ -34,7 +34,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Changed -- Have made System.\* dependencies only be included on Net Standard's TFM & net 5 (https://github.com/microsoft/kiota-http-dotnet/issues/230) +- Have made System.* dependencies only be included on Net Standard's TFM & net 5 (https://github.com/microsoft/kiota-http-dotnet/issues/230) ## [1.3.9] - 2024-04-17