Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable/Skip CompressionHandler when NSUrlSessionHandler is used as final handler. #482

Closed
peombwa opened this issue May 24, 2019 · 5 comments · Fixed by microsoftgraph/msgraph-sdk-dotnet-core#13
Assignees

Comments

@peombwa
Copy link
Member

peombwa commented May 24, 2019

Issue

NSUrlSessionHandler - Xamarin.iOS - handles decompression out of the box and doesn't provide an option to turn it off. This throws a System.IO.IOException: Corrupted data ReadInternal exception when our CompressionHandler is used alongside NSUrlSessionHandler as described in issue #413.

Workaround

The current work around involves creating a new pipeline without the CompressionHandler.

#if __IOS__
            var innerHandler = new NSUrlSessionHandler { AllowAutoRedirect = false };
            var handlers = GraphClientFactory.CreateDefaultHandlers(authProvider);
            // Remove CompressionHandler from pipeline when using NSUrlSessionHandler.
            handlers.Remove(handlers.FirstOrDefault((h) => h.GetType().Equals(typeof(CompressionHandler)))); // We need to provide a method to remove handlers by type. 
            var pipeline = GraphClientFactory.CreatePipeline(handlers , innerHandler);
            httpProvider = new HttpProvider(pipeline, true, new Serializer());
@peombwa
Copy link
Member Author

peombwa commented Jun 19, 2019

@peombwa peombwa closed this as completed Jun 19, 2019
@tipa
Copy link

tipa commented Jun 20, 2019

It looks like it still throws an System.IO.IOException: Corrupted data ReadInternal on iOS when using Microsoft.Graph.Core v1.16.0-preview.2 & Microsoft.Graph v1.15.0

@peombwa
Copy link
Member Author

peombwa commented Jun 20, 2019

Thanks for the feedback. I'll try and repro it on my end. Are you using a custom HttpProvider by any chance?

@tipa
Copy link

tipa commented Jun 20, 2019

No, I was calling the new GraphServiceClient(baseUrl, authenticationProvider) constructor without using the httpProvider parameter

@peombwa
Copy link
Member Author

peombwa commented Jun 21, 2019

@tipa, I have been able to repro the exception and we've released https://www.nuget.org/packages/Microsoft.Graph.Core/1.16.0-preview.3 to fix it. Our CompressionHandler was still present in the middleware pipeline, and this fix skips it when creating a new middleware pipeline on Xamarin.iOS.

@ghost ghost locked as resolved and limited conversation to collaborators Feb 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
2 participants