Skip to content

Commit d9ee437

Browse files
author
Andrew Omondi
committed
fix: ensures valid handler is returned in browser scenarios
1 parent 0b6e132 commit d9ee437

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/Microsoft.Graph.Core/Microsoft.Graph.Core.csproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
- https://github.com/microsoftgraph/msgraph-sdk-dotnet-core/blob/main/CHANGELOG.md
3232
</PackageReleaseNotes>
3333
<!-- By default let the Maui targets be excluded to make contribution for external parties easier and dependabot updates. They can be enabled by adding `-p:IncludeMauiTargets=true` to the target build/restore command which is done in the CI.-->
34-
<TargetFrameworks>netstandard2.0;net462;$(MauiTargets)</TargetFrameworks>
34+
<TargetFrameworks>netstandard2.0;net462;net8.0-browser;$(MauiTargets)</TargetFrameworks>
3535
<PublishRepositoryUrl>true</PublishRepositoryUrl>
3636
<EmbedUntrackedSources>true</EmbedUntrackedSources>
3737
<Deterministic>true</Deterministic>
@@ -63,16 +63,16 @@
6363
</None>
6464
</ItemGroup>
6565
<ItemGroup>
66-
<PackageReference Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" Version="8.3.1" />
67-
<PackageReference Include="Microsoft.IdentityModel.Validators" Version="8.3.1" />
66+
<PackageReference Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" Version="8.6.1" />
67+
<PackageReference Include="Microsoft.IdentityModel.Validators" Version="8.6.1" />
6868
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
6969
<PackageReference Include="Microsoft.Kiota.Abstractions" Version="1.17.1" />
7070
<PackageReference Include="Microsoft.Kiota.Authentication.Azure" Version="1.17.1" />
7171
<PackageReference Include="Microsoft.Kiota.Serialization.Json" Version="1.17.1" />
72-
<PackageReference Include="Microsoft.Kiota.Serialization.Text" Version="1.16.4" />
73-
<PackageReference Include="Microsoft.Kiota.Serialization.Form" Version="1.16.4" />
72+
<PackageReference Include="Microsoft.Kiota.Serialization.Text" Version="1.17.1" />
73+
<PackageReference Include="Microsoft.Kiota.Serialization.Form" Version="1.17.1" />
7474
<PackageReference Include="Microsoft.Kiota.Http.HttpClientLibrary" Version="1.17.1" />
75-
<PackageReference Include="Microsoft.Kiota.Serialization.Multipart" Version="1.16.4" />
75+
<PackageReference Include="Microsoft.Kiota.Serialization.Multipart" Version="1.17.1" />
7676
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.13.2">
7777
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
7878
<PrivateAssets>all</PrivateAssets>

src/Microsoft.Graph.Core/Requests/GraphClientFactory.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ public static HttpClient Create(
9292
{
9393
finalHandler = GetNativePlatformHttpHandler(proxy);
9494
}
95+
#if !BROWSER
9596
else if ((finalHandler is HttpClientHandler) && (finalHandler as HttpClientHandler).Proxy == null && proxy != null)
9697
{
9798
(finalHandler as HttpClientHandler).Proxy = proxy;
@@ -100,7 +101,7 @@ public static HttpClient Create(
100101
{
101102
throw new ArgumentException(ErrorConstants.Messages.InvalidProxyArgument);
102103
}
103-
104+
#endif
104105
var pipelineWithFlags = CreatePipelineWithFeatureFlags(handlers, finalHandler);
105106
HttpClient client = new HttpClient(pipelineWithFlags.Pipeline, disposeHandler);
106107
client.SetFeatureFlag(pipelineWithFlags.FeatureFlags);
@@ -264,9 +265,11 @@ internal static HttpMessageHandler GetNativePlatformHttpHandler(IWebProxy proxy
264265
// https://github.com/dotnet/runtime/blob/main/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpHandler.cs#L575
265266
var proxyPolicy = proxy != null ? WindowsProxyUsePolicy.UseCustomProxy : WindowsProxyUsePolicy.UseWinHttpProxy;
266267
return new WinHttpHandler { Proxy = proxy, AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate , WindowsProxyUsePolicy = proxyPolicy, SendTimeout = Timeout.InfiniteTimeSpan, ReceiveDataTimeout = Timeout.InfiniteTimeSpan, ReceiveHeadersTimeout = Timeout.InfiniteTimeSpan };
267-
#elif NET6_0_OR_GREATER
268+
#elif NET6_0_OR_GREATER && !BROWSER
268269
//use resilient configs when we can https://learn.microsoft.com/en-us/aspnet/core/fundamentals/http-requests?view=aspnetcore-5.0#alternatives-to-ihttpclientfactory-1
269270
return new SocketsHttpHandler { Proxy = proxy, AllowAutoRedirect = false, AutomaticDecompression = DecompressionMethods.All, PooledConnectionLifetime = TimeSpan.FromMinutes(1)};
271+
#elif BROWSER
272+
return new HttpClientHandler { AllowAutoRedirect = false };
270273
#else
271274
return new HttpClientHandler { Proxy = proxy, AllowAutoRedirect = false, AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate };
272275
#endif

0 commit comments

Comments
 (0)