Exemplo n.º 1
0
 public void Set(ProxyConfig proxyConfig)
 {
     Host               = proxyConfig?.Host;
     Port               = proxyConfig?.Port ?? 80;
     Username           = proxyConfig?.Username;
     Password           = proxyConfig?.Password;
     BypassProxyOnLocal = proxyConfig?.BypassProxyOnLocal ?? false;
 }
Exemplo n.º 2
0
        private static HttpClientHandler CreateClientHandler(ProxyConfig proxyConfig = null)
        {
            HttpClientHandler clientHandler = new HttpClientHandler
            {
                PreAuthenticate       = false,
                UseDefaultCredentials = true,
                UseProxy = false
            };

            if (string.IsNullOrWhiteSpace(proxyConfig?.Host))
            {
                return(clientHandler);
            }
            WebProxy proxy = proxyConfig.CreateWebProxy();

            clientHandler.UseProxy = true;
            clientHandler.Proxy    = proxy;
            clientHandler.UseDefaultCredentials = proxy.UseDefaultCredentials;
            clientHandler.PreAuthenticate       = proxy.UseDefaultCredentials;

            return(clientHandler);
        }
Exemplo n.º 3
0
        public SpotifyWebClient(ProxyConfig proxyConfig = null)
        {
            HttpClientHandler clientHandler = CreateClientHandler(proxyConfig);

            _client = new HttpClient(clientHandler);
        }