public BearerTokenAgentHttpMessageHandler(ITokenManager tokenManager, ICancellationManager cancellationMananger,
                                           IHttpMessageInvokerFactory httpMessageInvokerFactory)
 {
     _tokenManager         = tokenManager;
     _cancellationMananger = cancellationMananger;
     _httpMessageInvoker   = httpMessageInvokerFactory.CreateHttpMessageInvoker();
 }
Beispiel #2
0
        private HttpClient GetHttpClient(ITokenManager tokenManager, IHttpMessageInvokerFactory httpMessageInvokerFactory)
        {
            var handler = new BearerTokenAgentHttpMessageHandler(
                tokenManager, _cancellationMananger, httpMessageInvokerFactory);

            return(new HttpClient(handler));
        }
Beispiel #3
0
        public virtual async Task InitAsync()
        {
            IHttpMessageInvokerFactory invokerFactory = null;

            if (TestWebHost.HostByTestHost)
            {
                var hostBuilder = TestWebHost.CreateHostBuilder(System.Array.Empty <string>(), UseTestServer);
                ServerHost = await hostBuilder.StartAsync();

                if (UseTestServer)
                {
                    invokerFactory = new TestHttpMessageInvokerFactory(ServerHost.GetTestClient());
                }
            }

            invokerFactory ??= new SimpleHttpMessageInvokerFactory();

            HttpRequestGlobalOptions.DefaultConnectionLimit           = 10;
            HttpRequestGlobalOptions.DefaultHttpMessageInvokerFactory = invokerFactory;
        }
 public static IHttpRequest UseInvokerFactory(this IHttpRequest request, IHttpMessageInvokerFactory messageInvokerFactory)
 {
     request.ExecutionOptions.MessageInvokerFactory = messageInvokerFactory;
     return(request);
 }