Skip to content
This repository has been archived by the owner on Jul 9, 2024. It is now read-only.

Fixes errors in NetFramework for http/2 scenarions #238

Merged
merged 1 commit into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,13 @@ public void GetDefaultHttpMessageHandlerSetsUpProxy()
var defaultHandler = KiotaClientFactory.GetDefaultHttpMessageHandler(proxy);
// Assert
Assert.NotNull(defaultHandler);
#if NETFRAMEWORK
Assert.IsType<WinHttpHandler>(defaultHandler);
Assert.Equal(proxy, ((WinHttpHandler)defaultHandler).Proxy);
#else
Assert.IsType<HttpClientHandler>(defaultHandler);
Assert.Equal(proxy, ((HttpClientHandler)defaultHandler).Proxy);
#endif

}
}
Expand Down
7 changes: 7 additions & 0 deletions src/KiotaClientFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,14 @@ public static IList<DelegatingHandler> CreateDefaultHandlers()
/// <returns/>
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
}
}
}
10 changes: 6 additions & 4 deletions src/Microsoft.Kiota.Http.HttpClientLibrary.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
<AssemblyTitle>Kiota Http Library for dotnet</AssemblyTitle>
<Authors>Microsoft</Authors>
<!-- NET 5 target to be removed on next major version-->
<TargetFrameworks>netstandard2.0;netstandard2.1;net5.0;net6.0;net8.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard2.1;net5.0;net6.0;net8.0;net462</TargetFrameworks>
baywet marked this conversation as resolved.
Show resolved Hide resolved
<LangVersion>latest</LangVersion>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<PackageIconUrl>http://go.microsoft.com/fwlink/?LinkID=288890</PackageIconUrl>
<RepositoryUrl>https://github.com/microsoft/kiota-http-dotnet</RepositoryUrl>
<PackageProjectUrl>https://aka.ms/kiota/docs</PackageProjectUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<Deterministic>true</Deterministic>
<VersionPrefix>1.3.10</VersionPrefix>
<VersionPrefix>1.3.11</VersionPrefix>
<VersionSuffix></VersionSuffix>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<!-- Enable this line once we go live to prevent breaking changes -->
Expand Down Expand Up @@ -48,11 +48,13 @@
</ItemGroup>

<!-- NET 5 target to be removed on next major version-->
<ItemGroup Condition="'$(TargetFramework)' == 'net5.0' or '$(TargetFramework)'== 'netStandard2.0' or '$(TargetFramework)' == 'netStandard2.1'">
<ItemGroup Condition="'$(TargetFramework)' == 'net5.0' or '$(TargetFramework)'== 'netStandard2.0' or '$(TargetFramework)' == 'netStandard2.1' or '$(TargetFramework)' == 'net462'">
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="[6.0,9.0)" />
<PackageReference Include="System.Text.Json" Version="[6.0,9.0)" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
<PackageReference Include="System.Net.Http.WinHttpHandler" Version="[6.0,9.0)" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Kiota.Generated\KiotaGenerated.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
</ItemGroup>
Expand Down