diff --git a/CHANGELOG.md b/CHANGELOG.md index e216fa0..cf26714 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.3.11] - 2024-04-19 + +## Changed + +- Fixes default handler for NET framework to unlock HTTP/2 scenarios (https://github.com/microsoft/kiota-http-dotnet/issues/237) + ## [1.3.10] - 2024-04-19 ## Changed diff --git a/Microsoft.Kiota.Http.HttpClientLibrary.Tests/KiotaClientFactoryTests.cs b/Microsoft.Kiota.Http.HttpClientLibrary.Tests/KiotaClientFactoryTests.cs index d1d4ead..c70b786 100644 --- a/Microsoft.Kiota.Http.HttpClientLibrary.Tests/KiotaClientFactoryTests.cs +++ b/Microsoft.Kiota.Http.HttpClientLibrary.Tests/KiotaClientFactoryTests.cs @@ -73,8 +73,13 @@ public void GetDefaultHttpMessageHandlerSetsUpProxy() var defaultHandler = KiotaClientFactory.GetDefaultHttpMessageHandler(proxy); // Assert Assert.NotNull(defaultHandler); +#if NETFRAMEWORK + Assert.IsType(defaultHandler); + Assert.Equal(proxy, ((WinHttpHandler)defaultHandler).Proxy); +#else Assert.IsType(defaultHandler); Assert.Equal(proxy, ((HttpClientHandler)defaultHandler).Proxy); +#endif } } diff --git a/src/KiotaClientFactory.cs b/src/KiotaClientFactory.cs index 48686a0..5dd9498 100644 --- a/src/KiotaClientFactory.cs +++ b/src/KiotaClientFactory.cs @@ -83,7 +83,14 @@ public static IList CreateDefaultHandlers() /// public static HttpMessageHandler GetDefaultHttpMessageHandler(IWebProxy? proxy = null) { +#if NETFRAMEWORK + // 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 }; +#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 51a2982..99406a3 100644 --- a/src/Microsoft.Kiota.Http.HttpClientLibrary.csproj +++ b/src/Microsoft.Kiota.Http.HttpClientLibrary.csproj @@ -7,7 +7,7 @@ Kiota Http Library for dotnet Microsoft - netstandard2.0;netstandard2.1;net5.0;net6.0;net8.0 + netstandard2.0;netstandard2.1;net5.0;net6.0;net8.0;net462 latest true http://go.microsoft.com/fwlink/?LinkID=288890 @@ -15,7 +15,7 @@ https://aka.ms/kiota/docs true true - 1.3.10 + 1.3.11 true @@ -48,11 +48,13 @@ - + - + + +