private static void ApplyProxy (HttpWebRequest webRequest, string uri) { if (proxyFactory == null) { proxyFactory = new LibProxy.ProxyFactory (); } string[] proxies = proxyFactory.GetProxies (uri); foreach (string proxy in proxies) { Uri proxyUri = new Uri (proxy); string scheme = proxyUri.Scheme; if (scheme == "direct") { break; } else if (scheme == "http" || scheme == "https") { WebProxy webProxy = new WebProxy (); if (UseAuthentication ()) { ICredentials credentials = new NetworkCredential (GetAuthUser (), GetAuthPass ()); webProxy.Credentials = credentials; } webProxy.Address = proxyUri; webRequest.Proxy = webProxy; break; } } }
private static void ApplyProxy(HttpWebRequest webRequest, string uri) { ProxyFactory pf = new LibProxy.ProxyFactory(); string[] proxies = pf.GetProxies(uri); foreach (string proxy in proxies) { Uri proxyUri = new Uri(proxy); string scheme = proxyUri.Scheme; if (scheme == "direct") { break; } else if (scheme == "http" || scheme == "https") { WebProxy webProxy = new WebProxy(); if (UseAuthentication()) { ICredentials credentials = new NetworkCredential(GetAuthUser(), GetAuthPass()); webProxy.Credentials = credentials; } webProxy.Address = proxyUri; webRequest.Proxy = webProxy; break; } } }