Exemplo n.º 1
0
        public async Task <bool> IsAvailable(HttpProxy proxy)
        {
            if (proxy == null)
            {
                return(false);
            }

            var httpClient = _httpClientFactory.CreateClient($"PROXY_{proxy.Uri}");

            httpClient.Timeout = new TimeSpan(0, 0, 3);
            try
            {
                var msg      = new HttpRequestMessage(HttpMethod.Head, _options.ProxyTestUrl);
                var response = await httpClient.SendAsync(msg);

                return(response.IsSuccessStatusCode);
            }
            catch (Exception)
            {
                _logger.LogWarning($"Proxy {proxy.Uri} is not available");
                return(false);
            }
        }
Exemplo n.º 2
0
 public ReturnProxyTask(IProxyPool pool, HttpProxy httpProxy)
 {
     _pool      = pool;
     _httpProxy = httpProxy;
 }