コード例 #1
0
 public void Set(ProxyConfig proxyConfig)
 {
     Host               = proxyConfig?.Host;
     Port               = proxyConfig?.Port ?? 80;
     Username           = proxyConfig?.Username;
     Password           = proxyConfig?.Password;
     BypassProxyOnLocal = proxyConfig?.BypassProxyOnLocal ?? false;
 }
コード例 #2
0
        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);
        }
コード例 #3
0
        public SpotifyWebClient(ProxyConfig proxyConfig = null)
        {
            HttpClientHandler clientHandler = CreateClientHandler(proxyConfig);

            _client = new HttpClient(clientHandler);
        }