Class CachingHttpClientFactory
The CachingHttpClientFactory class constructs instances of HttpClient capable of communicating with an identified service. The factory delivers HttpClient instances from a cache if one has already been constructed for a particular service.
Implements
Inherited Members
Namespace: EPiServer.Social.Common.Rest
Assembly: EPiServer.Social.Common.Rest.dll
Version: 1.5.4Syntax
public class CachingHttpClientFactory : DelegatingHttpClientFactory, IHttpClientFactory
Remarks
HttpClient instances are reentrant and threadsafe. Pull clients from the cache to prevent socket consumption issues upon frequent access.
Constructors
CachingHttpClientFactory(String, Int32, DelegatingHandler[])
Constructor
Declaration
public CachingHttpClientFactory(string serviceBaseAddress, int timeout, params DelegatingHandler[] messageHandler)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | serviceBaseAddress | Base address for the service to be targeted |
| System.Int32 | timeout | Gets or sets the number of milliseconds to wait before the request times out |
| System.Net.Http.DelegatingHandler[] | messageHandler | a delegating HTTP handler capable of processing Http messages |
Methods
Create()
Creates an instance of HttpClient targeting the service address identified for this factory. If a client for this service has previously been requested, a cached instance will be returned.
Declaration
public override HttpClient Create()
Returns
| Type | Description |
|---|---|
| System.Net.Http.HttpClient |