internal static IWebProxy GetDefaultWebProxyFor(String url, IEnvProxy envProxy) { Uri uri = new Uri(url); IWebProxy result; if (envProxy.TryGetProxyFor(uri, out result) && result.GetProxy(uri) != uri) { return(result); } #if NO_SYSTEMWEBPROXY return(null); #else result = WebRequest.GetSystemWebProxy(); Uri address = result.GetProxy(uri); if (address == uri) { return(null); } return(new WebProxy(address) { Credentials = CredentialCache.DefaultCredentials, BypassProxyOnLocal = true }); #endif }
internal static HttpWebRequest PrepareWebRequest(string url, IEnvProxy envProxy) { var request = (HttpWebRequest)HttpWebRequest.Create(url); request.UserAgent = PaketBootstrapperUserAgent; request.UseDefaultCredentials = true; request.Proxy = GetDefaultWebProxyFor(url, envProxy); request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate; return(request); }
public DefaultProxyProvider() { FileSystemProxy = new FileSystemProxy(); EnvProxy = new EnvProxy(); WebRequestProxy = new WebRequestProxy(EnvProxy); }
public WebRequestProxy(IEnvProxy envProxy) { Client = new WebClient(); this.envProxy = envProxy; }
internal static void PrepareWebClient(WebClient client, string url, IEnvProxy envProxy) { client.Headers.Add("user-agent", PaketBootstrapperUserAgent); client.UseDefaultCredentials = true; client.Proxy = GetDefaultWebProxyFor(url, envProxy); }