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);
            }
        }
Beispiel #2
0
 public ReturnProxyTask(IProxyPool pool, HttpProxy httpProxy)
 {
     _pool      = pool;
     _httpProxy = httpProxy;
 }