Example #1
0
        protected override async Task <HttpResponseMessage> SendAsync(HttpRequestMessage message, CancellationToken token)
        {
            if (token.CanBeCanceled)
            {
                using (var newTokenSource = CancellationTokenSource.CreateLinkedTokenSource(token))
                {
                    newTokenSource.CancelAfter(DotNettyClientOptions.DefaultTimeout);
#pragma warning disable CA1062 // 验证公共方法的参数
                    return(await InternalExecuteAsync(message, DotNettyHttpRequestExecutor.GetProxyUri(message.RequestUri, _options.Proxy), newTokenSource.Token).ConfigureAwait(false));

#pragma warning restore CA1062 // 验证公共方法的参数
                }
            }
            else
            {
                return(await InternalExecuteAsync(message, DotNettyHttpRequestExecutor.GetProxyUri(message.RequestUri, _options.Proxy), token).ConfigureAwait(false));
            }
        }
Example #2
0
 public HttpDotNettyClientHandler(IDotNettyClientOptions options)
 {
     _options        = options ?? throw new ArgumentNullException(nameof(options));
     RequestExecutor = new DotNettyHttpRequestExecutor(options);
 }