コード例 #1
0
        public static HttpClient Create(HttpClientHandler requestHandler, LoggingHandler loggingHandler,
                                        TimeoutHandler timeoutHandler, NoPollyRetryHandler retryHandler)
        {
            retryHandler.InnerHandler   = requestHandler;
            timeoutHandler.InnerHandler = retryHandler;
            loggingHandler.InnerHandler = timeoutHandler;


            return(new HttpClient(loggingHandler));
        }
コード例 #2
0
        public void Run()
        {
            var requestHandler      = new HttpClientHandler();
            var loggingHandler      = new LoggingHandler();
            var timeoutHandler      = new TimeoutHandler();
            var retryHandler        = new RetryHandler();
            var noPollyRetryHandler = new NoPollyRetryHandler();

            //order of any additional handlers here is important.
            var httpClient             = HttpClientFactory.Create(requestHandler, loggingHandler, timeoutHandler, noPollyRetryHandler);
            HttpResponseMessage result = httpClient.GetAsync("https://appulate.com/admin22").GetAwaiter().GetResult();
        }