internal static HttpHandlerResourceV3 CreateResource(PackageSource packageSource, ICredentialService credentialService, bool nonInteractive = false) { var sourceUri = packageSource.SourceUri; var settings = new HttpClientSettings { AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate, SourceAuthenticationRequired = false, NonInteractive = nonInteractive }; var rootHandler = HttpClientProvider.CreateHttpMessageHandler(sourceUri, settings); // HTTP handler pipeline can be injected here, around the client handler HttpMessageHandler messageHandler = new MonoDevelopServerWarningLogHandler(rootHandler); var innerHandler = messageHandler; messageHandler = new StsAuthenticationHandler(packageSource, TokenStore.Instance) { InnerHandler = messageHandler }; innerHandler = messageHandler; var credentialsHandler = GetHttpCredentialsHandler(rootHandler); messageHandler = new NuGetHttpSourceAuthenticationHandler(packageSource, credentialsHandler, credentialService) { InnerHandler = innerHandler }; // Have to pass a dummy HttpClientProvider since it may not be used by a native implementation, such as on the Mac. // It looks like the only place this is used in NuGet is with the DownloadResourcePluginProvider in order to pass the // HttpClientHandler's Proxy to the GetCredentialsRequestHandler. There is no plugin support yet in MonoDevelop but // this may be a problem in the future. Possibly a custom DownloadResourcePluginProvider would be required or possibly // a HttpClientProvider created with just its Proxy property set based on the current proxy for that url. var clientHandler = GetOrCreateHttpClientHandler(rootHandler); // Get the proxy from NuGet's ProxyCache which has support for proxy information define in the NuGet.Config file. var proxy = ProxyCache.Instance.GetUserConfiguredProxy(); if (proxy != null) { clientHandler.Proxy = proxy; } var resource = new HttpHandlerResourceV3(clientHandler, messageHandler); return(resource); }