diff --git a/CHANGELOG.md b/CHANGELOG.md
index eb26b3c75..a4d1b2f95 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,12 @@ and this project does adheres to [Semantic Versioning](https://semver.org/spec/v
## [Unreleased]
+## [3.1.14] - 2024-07-23
+
+### Changed
+
+- Obsoletes custom decompression handler in favor of native client capabilities at https://github.com/microsoft/kiota-dotnet/pull/303
+
## [3.1.12] - 2024-07-03
### Changed
diff --git a/src/Microsoft.Graph.Core/Microsoft.Graph.Core.csproj b/src/Microsoft.Graph.Core/Microsoft.Graph.Core.csproj
index 25ddaab7d..35a265cc1 100644
--- a/src/Microsoft.Graph.Core/Microsoft.Graph.Core.csproj
+++ b/src/Microsoft.Graph.Core/Microsoft.Graph.Core.csproj
@@ -21,7 +21,7 @@
35MSSharedLib1024.snk
true
- 3.1.13
+ 3.1.14
@@ -38,7 +38,7 @@
True
README.md
NU5048;NETSDK1202
- true
+ true
@@ -62,15 +62,15 @@
-
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/src/Microsoft.Graph.Core/Requests/GraphClientFactory.cs b/src/Microsoft.Graph.Core/Requests/GraphClientFactory.cs
index 67c4a6d2b..8c03a1320 100644
--- a/src/Microsoft.Graph.Core/Requests/GraphClientFactory.cs
+++ b/src/Microsoft.Graph.Core/Requests/GraphClientFactory.cs
@@ -117,9 +117,6 @@ public static IList CreateDefaultHandlers(GraphClientOptions
var handlers = KiotaClientFactory.CreateDefaultHandlers();
handlers.Add(new GraphTelemetryHandler(graphClientOptions));// add the telemetry handler last.
- // TODO remove this once https://github.com/microsoft/kiota/issues/598 is closed.
- handlers.Insert(0, new CompressionHandler());
-
return handlers;
}
@@ -173,20 +170,6 @@ internal static (HttpMessageHandler Pipeline, FeatureFlag FeatureFlags) CreatePi
throw new ArgumentNullException(nameof(handlers), "DelegatingHandler array contains null item.");
}
-#if IOS || MACOS || MACCATALYST
-#if IOS || MACCATALYST
- // Skip CompressionHandler since NSUrlSessionHandler automatically handles decompression on iOS and macOS and it can't be turned off.
- // See issue https://github.com/microsoftgraph/msgraph-sdk-dotnet/issues/481 for more details.
- if (finalHandler.GetType().Equals(typeof(NSUrlSessionHandler)) && handler.GetType().Equals(typeof(CompressionHandler)))
-#elif MACOS
- if (finalHandler.GetType().Equals(typeof(Foundation.NSUrlSessionHandler)) && handler.GetType().Equals(typeof(CompressionHandler)))
-#endif
- {
- // Skip chaining of CompressionHandler.
- continue;
- }
-#endif
-
// Check for duplicate handler by type.
if (!existingHandlerTypes.Add(handler.GetType()))
{
@@ -220,17 +203,17 @@ internal static HttpMessageHandler GetNativePlatformHttpHandler(IWebProxy proxy
#elif MACOS
return new Foundation.NSUrlSessionHandler { AllowAutoRedirect = false };
#elif ANDROID
- return new Xamarin.Android.Net.AndroidMessageHandler { Proxy = proxy, AllowAutoRedirect = false, AutomaticDecompression = DecompressionMethods.None };
+ return new Xamarin.Android.Net.AndroidMessageHandler { Proxy = proxy, AllowAutoRedirect = false, AutomaticDecompression = DecompressionMethods.All };
#elif 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 = Timeout.InfiniteTimeSpan, ReceiveDataTimeout = Timeout.InfiniteTimeSpan, ReceiveHeadersTimeout = Timeout.InfiniteTimeSpan };
+ return new WinHttpHandler { Proxy = proxy, AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate , WindowsProxyUsePolicy = proxyPolicy, SendTimeout = Timeout.InfiniteTimeSpan, ReceiveDataTimeout = Timeout.InfiniteTimeSpan, ReceiveHeadersTimeout = Timeout.InfiniteTimeSpan };
#elif NET6_0_OR_GREATER
//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
- return new SocketsHttpHandler { Proxy = proxy, AllowAutoRedirect = false, AutomaticDecompression = DecompressionMethods.None, PooledConnectionLifetime = TimeSpan.FromMinutes(1)};
+ return new SocketsHttpHandler { Proxy = proxy, AllowAutoRedirect = false, AutomaticDecompression = DecompressionMethods.All, PooledConnectionLifetime = TimeSpan.FromMinutes(1)};
#else
- return new HttpClientHandler { Proxy = proxy, AllowAutoRedirect = false, AutomaticDecompression = DecompressionMethods.None };
+ return new HttpClientHandler { Proxy = proxy, AllowAutoRedirect = false, AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate };
#endif
}
@@ -241,14 +224,16 @@ internal static HttpMessageHandler GetNativePlatformHttpHandler(IWebProxy proxy
/// Delegating handler feature flag.
private static FeatureFlag GetHandlerFeatureFlag(DelegatingHandler delegatingHandler)
{
- if (delegatingHandler is CompressionHandler)
- return FeatureFlag.CompressionHandler;
- else if (delegatingHandler is RetryHandler)
- return FeatureFlag.RetryHandler;
- else if (delegatingHandler is RedirectHandler)
- return FeatureFlag.RedirectHandler;
- else
- return FeatureFlag.None;
+ return delegatingHandler switch
+ {
+ // Type or member is obsolete
+#pragma warning disable CS0618 // Type or member is obsolete
+ CompressionHandler => FeatureFlag.CompressionHandler,
+#pragma warning restore CS0618 // Type or member is obsolete
+ RetryHandler => FeatureFlag.RetryHandler,
+ RedirectHandler => FeatureFlag.RedirectHandler,
+ _ => FeatureFlag.None
+ };
}
private static Uri DetermineBaseAddress(string nationalCloud, string version)
diff --git a/tests/Microsoft.Graph.DotnetCore.Core.Test/Requests/GraphClientFactoryTests.cs b/tests/Microsoft.Graph.DotnetCore.Core.Test/Requests/GraphClientFactoryTests.cs
index b1777d2c9..449ac2cac 100644
--- a/tests/Microsoft.Graph.DotnetCore.Core.Test/Requests/GraphClientFactoryTests.cs
+++ b/tests/Microsoft.Graph.DotnetCore.Core.Test/Requests/GraphClientFactoryTests.cs
@@ -69,8 +69,7 @@ public void Should_CreatePipeline_Without_CompressionHandler()
[Fact]
public void Should_CreatePipeline_Without_HttpMessageHandlerInput()
{
- using CompressionHandler compressionHandler = (CompressionHandler)GraphClientFactory.CreatePipeline(handlers, new MockRedirectHandler());
- using UriReplacementHandler uriReplacementHandler = (UriReplacementHandler)compressionHandler.InnerHandler;
+ using UriReplacementHandler uriReplacementHandler = (UriReplacementHandler)GraphClientFactory.CreatePipeline(handlers, new MockRedirectHandler());
using RetryHandler retryHandler = (RetryHandler)uriReplacementHandler.InnerHandler;
using RedirectHandler redirectHandler = (RedirectHandler)retryHandler.InnerHandler;
using ParametersNameDecodingHandler odataQueryHandler = (ParametersNameDecodingHandler)redirectHandler.InnerHandler;
@@ -83,14 +82,12 @@ public void Should_CreatePipeline_Without_HttpMessageHandlerInput()
Assert.NotNull(userAgentHandler);
Assert.NotNull(headersInspectionHandler);
Assert.NotNull(odataQueryHandler);
- Assert.NotNull(compressionHandler);
Assert.NotNull(retryHandler);
Assert.NotNull(redirectHandler);
Assert.NotNull(innerMost);
Assert.IsType(telemetryHandler);
Assert.IsType(odataQueryHandler);
Assert.IsType(headersInspectionHandler);
- Assert.IsType(compressionHandler);
Assert.IsType(userAgentHandler);
Assert.IsType(retryHandler);
Assert.IsType(redirectHandler);
@@ -101,8 +98,7 @@ public void Should_CreatePipeline_Without_HttpMessageHandlerInput()
[Fact]
public void CreatePipelineWithHttpMessageHandlerInput()
{
- using CompressionHandler compressionHandler = (CompressionHandler)GraphClientFactory.CreatePipeline(handlers, new MockRedirectHandler());
- using UriReplacementHandler uriReplacementHandler = (UriReplacementHandler)compressionHandler.InnerHandler;
+ using UriReplacementHandler uriReplacementHandler = (UriReplacementHandler)GraphClientFactory.CreatePipeline(handlers, new MockRedirectHandler());
using RetryHandler retryHandler = (RetryHandler)uriReplacementHandler.InnerHandler;
using RedirectHandler redirectHandler = (RedirectHandler)retryHandler.InnerHandler;
using ParametersNameDecodingHandler odataQueryHandler = (ParametersNameDecodingHandler)redirectHandler.InnerHandler;
@@ -115,14 +111,12 @@ public void CreatePipelineWithHttpMessageHandlerInput()
Assert.NotNull(userAgentHandler);
Assert.NotNull(headersInspectionHandler);
Assert.NotNull(odataQueryHandler);
- Assert.NotNull(compressionHandler);
Assert.NotNull(retryHandler);
Assert.NotNull(redirectHandler);
Assert.NotNull(innerMost);
Assert.IsType(telemetryHandler);
Assert.IsType(odataQueryHandler);
Assert.IsType(headersInspectionHandler);
- Assert.IsType(compressionHandler);
Assert.IsType(retryHandler);
Assert.IsType(userAgentHandler);
Assert.IsType(redirectHandler);
@@ -143,11 +137,11 @@ public void CreatePipelineWithoutPipeline()
public void CreatePipeline_Should_Throw_Exception_With_Duplicate_Handlers()
{
var handlers = GraphClientFactory.CreateDefaultHandlers();
- handlers.Add(new CompressionHandler());
+ handlers.Add(new GraphTelemetryHandler());
ArgumentException exception = Assert.Throws(() => GraphClientFactory.CreatePipeline(handlers));
- Assert.Contains($"{typeof(CompressionHandler)} has a duplicate handler.", exception.Message);
+ Assert.Contains($"{typeof(GraphTelemetryHandler)} has a duplicate handler.", exception.Message);
}
[Fact]
@@ -281,7 +275,7 @@ public void CreateClient_WithInnerHandlerReference()
[Fact]
public void CreatePipelineWithFeatureFlags_Should_Set_FeatureFlag_For_Default_Handlers()
{
- FeatureFlag expectedFlag = FeatureFlag.CompressionHandler | FeatureFlag.RetryHandler | FeatureFlag.RedirectHandler;
+ FeatureFlag expectedFlag = FeatureFlag.RetryHandler | FeatureFlag.RedirectHandler;
string expectedFlagHeaderValue = Enum.Format(typeof(FeatureFlag), expectedFlag, "x");
var handlers = GraphClientFactory.CreateDefaultHandlers();
var pipelineWithHandlers = GraphClientFactory.CreatePipelineWithFeatureFlags(handlers);
@@ -293,7 +287,7 @@ public void CreatePipelineWithFeatureFlags_Should_Set_FeatureFlag_For_Default_Ha
[Fact]
public void CreatePipelineWithFeatureFlags_Should_Set_FeatureFlag_For_Speficied_Handlers()
{
- FeatureFlag expectedFlag = FeatureFlag.CompressionHandler | FeatureFlag.RetryHandler;
+ FeatureFlag expectedFlag = FeatureFlag.RetryHandler;
var handlers = GraphClientFactory.CreateDefaultHandlers();
//Exclude the redirect handler for this test
handlers = handlers.Where(handler => !handler.GetType().Equals(typeof(RedirectHandler))).ToList();