示例#1
0
        public HttpClientUtility(TimeSpan timeout, int retryCount, Socks5ProxyOptions socks5ProxyOptions = null)
        {
            socks5ProxyOptions = socks5ProxyOptions ?? new Socks5ProxyOptions();

            Timeout    = timeout;
            RetryCount = retryCount;
            var handler = new HttpClientHandler
            {
                AutomaticDecompression = DecompressionMethods.GZip
            };

            if (socks5ProxyOptions.UseSocks5Proxy)
            {
                handler.Proxy = new HttpToSocks5Proxy(socks5ProxyOptions.HostName, socks5ProxyOptions.Port);
            }

            ServicePointManager.ServerCertificateValidationCallback = CheckValidationResult;
            _httpClient = new System.Net.Http.HttpClient(handler)
            {
                Timeout = Timeout
            };
        }
示例#2
0
 public HttpClientUtility(TimeSpan timeout, Socks5ProxyOptions socks5ProxyOptions = null) : this(timeout, 3, socks5ProxyOptions)
 {
 }
示例#3
0
 public HttpClientUtility(Socks5ProxyOptions socks5ProxyOptions = null) : this(TimeSpan.FromSeconds(8), 3, socks5ProxyOptions)
 {
 }