如安在ASP.NET Core中利用HttpClientFactory(2)

    internal class DefaultHttpClientFactory : IHttpClientFactory, IHttpMessageHandlerFactory     {         public HttpClient CreateClient(string name)         {             if (name == null)             {                 throw new ArgumentNullException("name");             }             HttpMessageHandler handler = CreateHandler(name);             HttpClient httpClient = new HttpClient(handler, disposeHandler: false);             HttpClientFactoryOptions httpClientFactoryOptions = _optionsMonitor.Get(name);             for (int i = 0; i < httpClientFactoryOptions.HttpClientActions.Count; i++)             {                 httpClientFactoryOptions.HttpClientActions[i](httpClient);             }             return httpClient;         }         public HttpMessageHandler CreateHandler(string name)         {             if (name == null)             {                 throw new ArgumentNullException("name");             }             ActiveHandlerTrackingEntry value = _activeHandlers.GetOrAdd(name, _entryFactory).Value;             StartHandlerEntryTimer(value);             return value.Handler;         }     }

译文链接:https://www.infoworld.com/article/3276007/how-to-work-with-httpclientfactory-in-aspnet-core.html

以上就是如安在ASP.NET Core中利用HttpClientFactory的具体内容,更多关于ASP.NET Core利用HttpClientFactory的资料请存眷剧本之家其它相关文章!

您大概感乐趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wsjfzx.html