Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RestClient" /> class
        /// </summary>
        /// <param name="baseAddress"></param>
        /// <param name="options"></param>
        public RestClient(Uri baseAddress, RestClientOptions options = null)
        {
            _baseAddress = baseAddress ?? throw new ArgumentNullException(nameof(baseAddress));

            var o = options ?? RestClientOptions.Default;

            _options = o;

            _httpClient = CreateClient(o);
        }
Пример #2
0
        private static HttpClient CreateClient(RestClientOptions options)
        {
            var handler = new HttpClientHandler();

            if (handler.SupportsAutomaticDecompression)
            {
                handler.AutomaticDecompression = options.DecompressionMethods;
            }

            return(new HttpClient(handler)
            {
                Timeout = options.Timeout
            });
        }