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

HttpHandlerResource has a HttpClientHandler property which is not available when using NSUrlSessionHandler on the Mac #7298

Open
mrward opened this issue Sep 13, 2018 · 2 comments
Labels
Area:HttpCommunication Functionality:SDK The NuGet client packages published to nuget.org Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. Type:DCR Design Change Request
Milestone

Comments

@mrward
Copy link
Member

mrward commented Sep 13, 2018

Details about Problem

The HttpHandlerResource has a HttpClientHandler property. A native HttpMessageHandler, which can be used by HttpClient, does not have to be a HttpClientHandler derived class. With Xamarin.Mac the native handler is NSUrlSessionHandler which derives from HttpMessageHandler. The NSUrlSessionHandler cannot be used with the HttpHandlerResourceV3 and a null value cannot be passed since there is a null check.

Searching the code it looks like the only place where this is used is in the DownloadResourcePluginProvider class where it is used to pass the HttpClientHandler.Proxy to the GetCredentialsRequestHandler. Is there another way we can handle this without requiring a HttpClientHandler as part of the HttpHandlerResource?

For now I can create a dummy HttpClientHandler - however if NuGet starts using the HttpClientHandler property for other things then this will likely not work if Visual Studio for Mac is using the NSUrlSessionHandler. Visual Studio for Mac can implement its own version of the HttpHandlerResourceV3Provider but having HttpHandlerResourceV3 require a HttpClientHandler is problematic here.

@jainaashish
Copy link
Contributor

I could imagine that HttpHandlerResource can just work with a HttpMessageHandler parameter where a implementation of this interface like HttpHandlerResourceV3 could easily pass any of the NuGet specific HttpMessageHandler implementation like ProxyAuthenticationHandler or HttpSourceAuthenticationHandler which always have an underline reference to HttpClientHandler.

But I don't think we'll be able to change anything here in near future so working with a dummy HttpClientHandler looks fine to me. We'll keep in mind while increasing the scope of consuming more properties from HttpClientHandler in this space.

@dtivel for reference.

@jainaashish jainaashish added this to the Backlog milestone Sep 19, 2018
@jainaashish jainaashish added the Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. label Sep 19, 2018
@mrward
Copy link
Member Author

mrward commented Sep 19, 2018

Just FYI, on the VS Mac side I have a custom ProxyAuthenticationHandler class, based on the NuGet one, a custom HttpSourceAuthenticationHandler, both of which are used by a VS Mac specific HttpHandlerResourceV3Provider. The custom HttpSourceAuthenticationHandler uses an IHttpClientHandler interface so things like credentials can be set on both the NSUrlSessionHandler and Mono's HttpClientHandler. There may well be a better way to do this.

@zivkan zivkan added the Functionality:SDK The NuGet client packages published to nuget.org label Feb 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area:HttpCommunication Functionality:SDK The NuGet client packages published to nuget.org Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. Type:DCR Design Change Request
Projects
None yet
Development

No branches or pull requests

6 participants