Ejemplo n.º 1
0
        public WebClient(HttpClient client, IContentBuilder builder)
        {
            _builder = builder.CheckNull(nameof(builder));
            _client  = client;

            Culture = CultureInfo.CurrentCulture;
        }
Ejemplo n.º 2
0
        public WebClient(IAppLogger logger, string url, IContentBuilder builder)
        {
            _logger  = logger;
            _url     = url;
            _builder = builder.CheckNull(nameof(builder));

#if NETCOREAPP2_1 || NETCOREAPP2_2 || NETCOREAPP3_1
            _handler = new SocketsHttpHandler();
            _client  = new HttpClient(_handler);
#else
            _client = new HttpClient();

            if (!string.IsNullOrWhiteSpace(url))
            {
                var uri = new Uri(_url);
                _servicePoint = ServicePointManager.FindServicePoint(uri);
            }
#endif

            ConnectionsLimit       = 1024;
            MaxIdleTime            = 300000; // 5 мин
            ConnectionLeaseTimeout = 0;      // закрываем соединение сразу после выполнения запроса

            Culture = CultureInfo.CurrentCulture;
        }