Пример #1
0
		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;
				}
			}
		}
Пример #2
0
        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;
                }
            }
        }