public void Set(ProxyConfig proxyConfig) { Host = proxyConfig?.Host; Port = proxyConfig?.Port ?? 80; Username = proxyConfig?.Username; Password = proxyConfig?.Password; BypassProxyOnLocal = proxyConfig?.BypassProxyOnLocal ?? false; }
private static HttpClientHandler CreateClientHandler(ProxyConfig proxyConfig = null) { HttpClientHandler clientHandler = new HttpClientHandler { PreAuthenticate = false, UseDefaultCredentials = true, UseProxy = false }; if (!string.IsNullOrWhiteSpace(proxyConfig?.Host)) { WebProxy proxy = proxyConfig.CreateWebProxy(); clientHandler.UseProxy = true; clientHandler.Proxy = proxy; clientHandler.UseDefaultCredentials = proxy.UseDefaultCredentials; clientHandler.PreAuthenticate = proxy.UseDefaultCredentials; } return(clientHandler); }
public SpotifyWebClient(ProxyConfig proxyConfig = null) { HttpClientHandler clientHandler = CreateClientHandler(proxyConfig); _client = new HttpClient(clientHandler); }