コード例 #1
0
 public HttpClientWrapper(HttpClientConfiguration httpClientConfig)
 {
     this.client = new HttpClient()
     {
         Timeout = httpClientConfig.Timeout
     };
 }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HttpClientWrapper"/> class.
        /// </summary>
        public HttpClientWrapper()
        {
            HttpClientConfiguration httpClientConfig = new HttpClientConfiguration();

            this.statusCodesToRetry = httpClientConfig.StatusCodesToRetry
                                      .Where(val => Enum.IsDefined(typeof(HttpStatusCode), val))
                                      .Select(val => (HttpStatusCode)val).ToImmutableList();

            this.requestMethodsToRetry = httpClientConfig.RequestMethodsToRetry
                                         .Select(method => new HttpMethod(method.ToString())).ToList();

            this.numberOfRetries = httpClientConfig.NumberOfRetries;
            this.backoffFactor   = httpClientConfig.BackoffFactor;
            this.retryInterval   = httpClientConfig.RetryInterval;
            this.backoffMax      = httpClientConfig.BackoffMax;
            this.client          = this.GetDefaultHttpClient();
        }