1 implementation of IHttpClientFactory
Microsoft.Extensions.Http (1)
DefaultHttpClientFactory.cs (1)
19internal class DefaultHttpClientFactory : IHttpClientFactory, IHttpMessageHandlerFactory
161 references to IHttpClientFactory
Aspire.EndToEnd.Tests (1)
tests\Shared\WorkloadTesting\AspireProject.cs (1)
493return services.BuildServiceProvider().GetRequiredService<IHttpClientFactory>().CreateClient();
Aspire.Hosting.Testing (2)
DistributedApplicationHostingTestingExtensions.cs (2)
26var clientFactory = app.Services.GetRequiredService<IHttpClientFactory>();
Aspire.Hosting.Testing.Tests (3)
DistributedApplicationHttpClientExtensionsForTests.cs (3)
10private static readonly Lazy<IHttpClientFactory> s_httpClientFactory = new(CreateHttpClientFactoryWithResilience); 19private static IHttpClientFactory CreateHttpClientFactoryWithResilience() 28return services.BuildServiceProvider().GetRequiredService<IHttpClientFactory>();
Aspire.Hosting.Tests (3)
tests\Aspire.Hosting.Testing.Tests\DistributedApplicationHttpClientExtensionsForTests.cs (3)
10private static readonly Lazy<IHttpClientFactory> s_httpClientFactory = new(CreateHttpClientFactoryWithResilience); 19private static IHttpClientFactory CreateHttpClientFactoryWithResilience() 28return services.BuildServiceProvider().GetRequiredService<IHttpClientFactory>();
Aspire.Keycloak.Authentication (2)
AspireKeycloakExtensions.cs (2)
87.Configure<IConfiguration, IHttpClientFactory, IHostEnvironment>((options, configuration, httpClientFactory, hostEnvironment) => 166.Configure<IConfiguration, IHttpClientFactory, IHostEnvironment>((options, configuration, httpClientFactory, hostEnvironment) =>
Aspire.Playground.Tests (2)
Infrastructure\DistributedApplicationExtensions.cs (2)
200var httpClientFactory = services.GetRequiredService<IHttpClientFactory>();
Aspire.Workload.Tests (1)
tests\Shared\WorkloadTesting\AspireProject.cs (1)
493return services.BuildServiceProvider().GetRequiredService<IHttpClientFactory>().CreateClient();
HeaderPropagationSample (1)
Startup.cs (1)
50public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IHttpClientFactory clientFactory)
Microsoft.AspNetCore.HeaderPropagation.Tests (4)
HeaderPropagationIntegrationTest.cs (4)
45var client = context.RequestServices.GetRequiredService<IHttpClientFactory>().CreateClient("test"); 89var client = serviceProvider.GetRequiredService<IHttpClientFactory>().CreateClient("test"); 241private readonly IHttpClientFactory _httpClientFactory; 243public SimpleMiddleware(RequestDelegate next, IHttpClientFactory httpClientFactory)
Microsoft.Extensions.Http (72)
DependencyInjection\HttpClientBuilderExtensions.cs (10)
384IHttpClientFactory httpClientFactory = s.GetRequiredService<IHttpClientFactory>(); 448IHttpClientFactory httpClientFactory = s.GetRequiredService<IHttpClientFactory>(); 492IHttpClientFactory httpClientFactory = s.GetRequiredService<IHttpClientFactory>(); 541IHttpClientFactory httpClientFactory = s.GetRequiredService<IHttpClientFactory>(); 599/// The default implementation of <see cref="IHttpClientFactory"/> will pool the <see cref="HttpMessageHandler"/> 659/// A named client resolved from DI as a keyed service will behave similarly to a client you would create with <see cref="IHttpClientFactory.CreateClient(string)"/>. This
DependencyInjection\HttpClientFactoryServiceCollectionExtensions.cs (42)
17/// Extension methods to configure an <see cref="IServiceCollection"/> for <see cref="IHttpClientFactory"/>. 22/// Adds the <see cref="IHttpClientFactory"/> and related services to the <see cref="IServiceCollection"/>. 41services.TryAddSingleton<IHttpClientFactory>(serviceProvider => serviceProvider.GetRequiredService<DefaultHttpClientFactory>()); 68return s.GetRequiredService<IHttpClientFactory>().CreateClient(string.Empty); 93/// Adds the <see cref="IHttpClientFactory"/> and related services to the <see cref="IServiceCollection"/> and configures 102/// <see cref="IHttpClientFactory.CreateClient(string)"/> and providing the matching name. 119/// Adds the <see cref="IHttpClientFactory"/> and related services to the <see cref="IServiceCollection"/> and configures 129/// <see cref="IHttpClientFactory.CreateClient(string)"/> and providing the matching name. 149/// Adds the <see cref="IHttpClientFactory"/> and related services to the <see cref="IServiceCollection"/> and configures 159/// <see cref="IHttpClientFactory.CreateClient(string)"/> and providing the matching name. 179/// Adds the <see cref="IHttpClientFactory"/> and related services to the <see cref="IServiceCollection"/> and configures 192/// <see cref="IHttpClientFactory.CreateClient(string)"/> and providing the matching name. 215/// Adds the <see cref="IHttpClientFactory"/> and related services to the <see cref="IServiceCollection"/> and configures 232/// <see cref="IHttpClientFactory.CreateClient(string)"/> and providing the matching name. 256/// Adds the <see cref="IHttpClientFactory"/> and related services to the <see cref="IServiceCollection"/> and configures 269/// <see cref="IHttpClientFactory.CreateClient(string)"/> and providing the matching name. 295/// Adds the <see cref="IHttpClientFactory"/> and related services to the <see cref="IServiceCollection"/> and configures 312/// <see cref="IHttpClientFactory.CreateClient(string)"/> and providing the matching name. 339/// Adds the <see cref="IHttpClientFactory"/> and related services to the <see cref="IServiceCollection"/> and configures 353/// <see cref="IHttpClientFactory.CreateClient(string)"/> and providing the matching name. 378/// Adds the <see cref="IHttpClientFactory"/> and related services to the <see cref="IServiceCollection"/> and configures 392/// <see cref="IHttpClientFactory.CreateClient(string)"/> and providing the matching name. 417/// Adds the <see cref="IHttpClientFactory"/> and related services to the <see cref="IServiceCollection"/> and configures 435/// <see cref="IHttpClientFactory.CreateClient(string)"/> and providing the matching name. 461/// Adds the <see cref="IHttpClientFactory"/> and related services to the <see cref="IServiceCollection"/> and configures 479/// <see cref="IHttpClientFactory.CreateClient(string)"/> and providing the matching name. 505/// Adds the <see cref="IHttpClientFactory"/> and related services to the <see cref="IServiceCollection"/> and configures 519/// <see cref="IHttpClientFactory.CreateClient(string)"/> and providing the matching name. 547/// Adds the <see cref="IHttpClientFactory"/> and related services to the <see cref="IServiceCollection"/> and configures 561/// <see cref="IHttpClientFactory.CreateClient(string)"/> and providing the matching name. 589/// Adds the <see cref="IHttpClientFactory"/> and related services to the <see cref="IServiceCollection"/> and configures 607/// <see cref="IHttpClientFactory.CreateClient(string)"/> and providing the matching name. 636/// Adds the <see cref="IHttpClientFactory"/> and related services to the <see cref="IServiceCollection"/> and configures 654/// <see cref="IHttpClientFactory.CreateClient(string)"/> and providing the matching name. 683/// Adds the <see cref="IHttpClientFactory"/> and related services to the <see cref="IServiceCollection"/> and configures 699/// <see cref="IHttpClientFactory.CreateClient(string)"/> and providing the matching name. 719/// Adds the <see cref="IHttpClientFactory"/> and related services to the <see cref="IServiceCollection"/> and configures 736/// <see cref="IHttpClientFactory.CreateClient(string)"/> and providing the matching name. 762/// Adds the <see cref="IHttpClientFactory"/> and related services to the <see cref="IServiceCollection"/> and configures 778/// <see cref="IHttpClientFactory.CreateClient(string)"/> and providing the matching name. 798/// Adds the <see cref="IHttpClientFactory"/> and related services to the <see cref="IServiceCollection"/> and configures 815/// <see cref="IHttpClientFactory.CreateClient(string)"/> and providing the matching name.
DependencyInjection\HttpClientKeyedLifetime.cs (1)
66return serviceProvider.GetRequiredService<IHttpClientFactory>().CreateClient(name);
DependencyInjection\IHttpClientBuilder.cs (1)
9/// A builder for configuring named <see cref="HttpClient"/> instances returned by <see cref="IHttpClientFactory"/>.
DependencyInjection\ISocketsHttpHandlerBuilder.cs (1)
9/// <see cref="System.Net.Http.HttpClient"/> instances returned by <see cref="System.Net.Http.IHttpClientFactory"/>.
DependencyInjection\SocketsHttpHandlerBuilderExtensions.cs (1)
16/// <see cref="System.Net.Http.HttpClient"/> instances returned by <see cref="IHttpClientFactory"/>.
HttpClientFactoryExtensions.cs (3)
9/// Extensions methods for <see cref="IHttpClientFactory"/>. 16/// <param name="factory">The <see cref="IHttpClientFactory"/>.</param> 18public static HttpClient CreateClient(this IHttpClientFactory factory)
HttpClientFactoryOptions.cs (4)
14/// Provides options for configuring the default <see cref="IHttpClientFactory"/>. 42/// The default implementation of <see cref="IHttpClientFactory"/> will pool the <see cref="HttpMessageHandler"/> 80/// Gets or sets a value that determines whether the <see cref="IHttpClientFactory"/> will 91/// The <see cref="IHttpClientFactory"/> will (by default) create a dependency injection scope
HttpMessageHandlerBuilder.cs (3)
26/// The <see cref="Name"/> is set by the <see cref="IHttpClientFactory"/> infrastructure 68/// end of the chain. The resulting pipeline is used by <see cref="IHttpClientFactory"/> infrastructure to create <see cref="HttpClient"/> instances with customized message 69/// handlers. The resulting pipeline can also be accessed by using <see cref="IHttpMessageHandlerFactory"/> instead of <see cref="IHttpClientFactory"/>.
IHttpClientFactory.cs (3)
13/// A default <see cref="IHttpClientFactory"/> can be registered in an <see cref="IServiceCollection"/> 15/// The default <see cref="IHttpClientFactory"/> will be registered in the service collection as a singleton. 29/// <see cref="IHttpClientFactory"/> tracks and disposes resources used by the <see cref="HttpClient"/>.
ITypedHttpClientFactory.cs (1)
106/// An <see cref="HttpClient"/> created by the <see cref="IHttpClientFactory"/> for the named client
Logging\IHttpClientAsyncLogger.cs (1)
12/// An abstraction for asyncronous custom HTTP request logging for a named <see cref="HttpClient"/> instances returned by <see cref="IHttpClientFactory"/>.
Logging\IHttpClientLogger.cs (1)
10/// An abstraction for custom HTTP request logging for a named <see cref="HttpClient"/> instances returned by <see cref="IHttpClientFactory"/>.
Microsoft.Extensions.Http.Diagnostics (3)
Logging\HttpClientLoggingServiceCollectionExtensions.cs (3)
23/// Adds an <see cref="IHttpClientAsyncLogger" /> to emit logs for outgoing requests for all HTTP clients created with <see cref="IHttpClientFactory"/>. 52/// Adds an <see cref="IHttpClientAsyncLogger" /> to emit logs for outgoing requests for all HTTP clients created with <see cref="IHttpClientFactory"/>. 74/// Adds an <see cref="IHttpClientAsyncLogger" /> to emit logs for outgoing requests for all HTTP clients created with <see cref="IHttpClientFactory"/>.
Microsoft.Extensions.Http.Diagnostics.PerformanceTests (8)
HttpClientFactory.cs (8)
34.GetRequiredService<IHttpClientFactory>() 57.GetRequiredService<IHttpClientFactory>() 84.GetRequiredService<IHttpClientFactory>() 107.GetRequiredService<IHttpClientFactory>() 130.GetRequiredService<IHttpClientFactory>() 157.GetRequiredService<IHttpClientFactory>() 168.GetRequiredService<IHttpClientFactory>() 178.GetRequiredService<IHttpClientFactory>()
Microsoft.Extensions.Http.Diagnostics.Tests (19)
Latency\HttpClientLatencyTelemetryExtensionsTest.cs (1)
66using var httpClient = sp.GetRequiredService<IHttpClientFactory>().CreateClient();
Logging\AcceptanceTests.cs (14)
39using var httpClient = sp.GetRequiredService<IHttpClientFactory>().CreateClient(); 70using var httpClient = sp.GetRequiredService<IHttpClientFactory>().CreateClient(); 106using var httpClient = sp.GetRequiredService<IHttpClientFactory>().CreateClient("testClient"); 159using var namedClient1 = provider.GetRequiredService<IHttpClientFactory>().CreateClient("namedClient1"); 160using var namedClient2 = provider.GetRequiredService<IHttpClientFactory>().CreateClient("namedClient2"); 307using var httpClient = sp.GetRequiredService<IHttpClientFactory>().CreateClient(); 354using var httpClient = sp.GetRequiredService<IHttpClientFactory>().CreateClient(); 419using var httpClient = sp.GetRequiredService<IHttpClientFactory>().CreateClient("test"); 465var factory = provider.GetRequiredService<IHttpClientFactory>(); 590var client = provider.GetRequiredService<IHttpClientFactory>().CreateClient("test"); 616var client = provider.GetRequiredService<IHttpClientFactory>().CreateClient("normal"); 639var client = provider.GetRequiredService<IHttpClientFactory>().CreateClient("test"); 676.GetRequiredService<IHttpClientFactory>()
Logging\HttpClientLoggingExtensionsTest.cs (3)
307using var httpClient = provider.GetRequiredService<IHttpClientFactory>().CreateClient(); 390using var httpClient = provider.GetRequiredService<IHttpClientFactory>().CreateClient(); 403using var httpClient = sp.GetRequiredService<IHttpClientFactory>().CreateClient();
Logging\Internal\TestLoggingHandler.cs (1)
22var handlerType = typeof(IHttpClientFactory).Assembly.GetType("Microsoft.Extensions.Http.Logging.HttpClientLoggerHandler");
Microsoft.Extensions.Http.Polly (1)
PolicyHttpMessageHandler.cs (1)
22/// The documentation provided here is focused guidance for using Polly together with the <see cref="IHttpClientFactory"/>.
Microsoft.Extensions.Http.Polly.Tests (18)
DependencyInjection\PollyHttpClientBuilderExtensionsTest.cs (18)
52var factory = services.GetRequiredService<IHttpClientFactory>(); 87var factory = services.GetRequiredService<IHttpClientFactory>(); 125var factory = services.GetRequiredService<IHttpClientFactory>(); 166var factory = services.GetRequiredService<IHttpClientFactory>(); 210var factory = services.GetRequiredService<IHttpClientFactory>(); 263var factory = services.GetRequiredService<IHttpClientFactory>(); 308var factory = services.GetRequiredService<IHttpClientFactory>(); 352var factory = services.GetRequiredService<IHttpClientFactory>(); 422var factory = services.GetRequiredService<IHttpClientFactory>();
Microsoft.Extensions.Http.Resilience.PerformanceTests (8)
HedgingBenchmark.cs (2)
24var factory = serviceProvider.GetRequiredService<IHttpClientFactory>();
HttpResilienceBenchmark.cs (2)
37var factory = serviceProvider.GetRequiredService<IHttpClientFactory>();
RetryBenchmark.cs (2)
62var factory = services.BuildServiceProvider().GetRequiredService<IHttpClientFactory>();
StandardResilienceBenchmark.cs (2)
64var factory = services.BuildServiceProvider().GetRequiredService<IHttpClientFactory>();
Microsoft.Extensions.Http.Resilience.Tests (11)
Hedging\HedgingTests.cs (1)
345return _serviceProvider.GetRequiredService<IHttpClientFactory>().CreateClient(ClientId);
Hedging\StandardHedgingTests.cs (2)
336var clientFactory = provider.GetRequiredService<IHttpClientFactory>();
Resilience\HttpClientBuilderExtensionsTests.Resilience.cs (6)
79var client = serviceProvider.GetRequiredService<IHttpClientFactory>().CreateClient("client"); 132var client = clientBuilder.Services.BuildServiceProvider().GetRequiredService<IHttpClientFactory>().CreateClient("client"); 229var client = provider.GetRequiredService<IHttpClientFactory>().CreateClient("client"); 264var client = provider.GetRequiredService<IHttpClientFactory>().CreateClient("client"); 284var factory = serviceProvider.GetRequiredService<IHttpClientFactory>();
Resilience\HttpClientBuilderExtensionsTests.Standard.cs (2)
60return _serviceProvider.GetRequiredService<IHttpClientFactory>().CreateClient(name); 266using var client = builder.Services.BuildServiceProvider().GetRequiredService<IHttpClientFactory>().CreateClient("test");
Microsoft.Extensions.ServiceDiscovery.Tests (1)
ServiceEndpointResolverTests.cs (1)
62var client = services.GetRequiredService<IHttpClientFactory>().CreateClient("foo");
Stress.AppHost (1)
ResourceBuilderExtensions.cs (1)
62var httpClient = context.ServiceProvider.GetRequiredService<IHttpClientFactory>().CreateClient();