[Enhancement] Add ability to be able to create both managed and native HttpCLient handlers in shared code
- Dominant language
- C#
- Stars
- 23.3k
- Forks
- 2k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 290
Description
## Summary
In iOS and Android head projects, there is a project property setting to switch between using the managed HttpClient handlers and the native http client handlers for the platform, i.e. [NSUrlSessionHandler (iOS)](https://docs.microsoft.com/en-us/xamarin/cross-platform/macios/http-stack) or [AndroidClientHandler (Android).](https://docs.microsoft.com/en-us/xamarin/android/app-fundamentals/http-stack?tabs=macos). In shared code if someone needs to add auth credentials, for instance for NTLM auth and wants to use the native handler ([current managed HttpClientHandler on iOS has a bug that breaks NTLM auth](https://github.com/xamarin/xamarin-macios/issues/7770)), there is no way to create an HttpClient passing in a native handler without setting up a dependency service to create the HttpClient in the platform project such that a NSUrlSessionHandler/AndroidClientHandler can be passed in to the HttpClient constructor.
## API Changes
Perhaps a FormsHttpClientHandler class can be created that would choose which http client handler to use based on the http client implementation selected in the iOS/Android project properties?
## Intended Use Case
This would be useful to anyone who has to set properties on the HttpClientHandler before passing it into the HttpClient constructor, but wants to be able to do so from shared code and use whatever handler is set in the native project properties.
Contributor guide
Research direction
Start by tracing shared-code HttpClient construction and the platform handler selection described for NSUrlSessionHandler and AndroidClientHandler. Review the proposed FormsHttpClientHandler entry point and determine how it would honor the iOS and Android project settings while allowing handler properties to be configured from shared code. Done means both managed and native handlers can be selected and passed to HttpClient without a platform dependency service.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, csharp, ios
- Domain
- mobile
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100