diff --git a/FastGithub.Http/HttpClientFactory.cs b/FastGithub.Http/HttpClientFactory.cs index 54fbaae..c8e53d6 100644 --- a/FastGithub.Http/HttpClientFactory.cs +++ b/FastGithub.Http/HttpClientFactory.cs @@ -75,7 +75,7 @@ namespace FastGithub.Http private void OnLifetimeHttpHandlerDeactivate(LifetimeHttpHandler lifetimeHttpHandler) { // 切换激活状态的记录的实例 - var domainConfig = ((HttpClientHandler)lifetimeHttpHandler.InnerHandler!).DomainConfig; + var domainConfig = lifetimeHttpHandler.DomainConfig; this.httpHandlerLazyCache[domainConfig] = this.CreateLifetimeHttpHandlerLazy(domainConfig); this.httpHandlerCleaner.Add(lifetimeHttpHandler); } diff --git a/FastGithub.Http/LifetimeHttpHandler.cs b/FastGithub.Http/LifetimeHttpHandler.cs index 3bd6699..8edf8f4 100644 --- a/FastGithub.Http/LifetimeHttpHandler.cs +++ b/FastGithub.Http/LifetimeHttpHandler.cs @@ -1,4 +1,5 @@ -using System; +using FastGithub.Configuration; +using System; using System.Net.Http; using System.Threading; @@ -11,15 +12,21 @@ namespace FastGithub.Http { private readonly Timer timer; + /// + /// 获取域名配置 + /// + public DomainConfig DomainConfig { get; } + /// /// 具有生命周期的HttpHandler /// /// HttpHandler /// 拦截器的生命周期 /// 失效回调 - public LifetimeHttpHandler(HttpMessageHandler handler, TimeSpan lifeTime, Action deactivateAction) + public LifetimeHttpHandler(HttpClientHandler handler, TimeSpan lifeTime, Action deactivateAction) : base(handler) { + this.DomainConfig = handler.DomainConfig; this.timer = new Timer(this.OnTimerCallback, deactivateAction, lifeTime, Timeout.InfiniteTimeSpan); }