HTTP Client Factory
This factory is a .NET Framework substitute for the .NET 6 IHttpClientFactory. It aims to provide HttpClient instances resilient against DNS staleness timeouts by rotating client instances without managing the underlying HttpClientHandler instance.
Usage
HTTP Client Factory can be accessed through a static Instance property. To obtain an instance of HttpClient call the CreateClient(string) method with a name of the client.
HttpClient client = HttpClientFactory.Instance.CreateClient("backend");
Note
Never cache instances received through HTTPClientFactory
Choosing a name
For optimal performance and socket management use one name for a single server or domain.
Default configuration
Automatic compression
Clients obtained via the HTTP Client Factory automatically set the Accept-Encoding header to gzip/deflate and handle decompression of content automatically.
HTTP Proxy support
Clients returned by HTTP Client Factory support system defined HTTP proxy in Editor, Android, and iOS. It also supports SSL proxying in development builds. For detailed information about proxy support see HTTP Proxy support.
Custom HttpRequestHandler
The factory allows for providing a custom HttpMessageHandler instance for a named client by using the SetCustomHandler method.