using System; using System.Net.Http; using System.Threading; using System.Threading.Tasks; namespace FastGithub.ReverseProxy { /// /// YARP的HttpClient /// class HttpClient : HttpMessageInvoker { private readonly TlsSniPattern tlsSniPattern; private readonly bool tlsIgnoreNameMismatch; /// /// YARP的HttpClient /// /// /// /// public HttpClient( HttpMessageHandler handler, TlsSniPattern tlsSniPattern, bool tlsIgnoreNameMismatch, bool disposeHandler = false) : base(handler, disposeHandler) { this.tlsSniPattern = tlsSniPattern; this.tlsIgnoreNameMismatch = tlsIgnoreNameMismatch; } /// /// 发送数据 /// /// /// /// public override Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) { request.SetRequestContext(new RequestContext { Host = request.RequestUri?.Host, IsHttps = request.RequestUri?.Scheme == Uri.UriSchemeHttps, TlsSniPattern = this.tlsSniPattern, TlsIgnoreNameMismatch = this.tlsIgnoreNameMismatch }); return base.SendAsync(request, cancellationToken); } } }