public class HttpClientFactory : IHttpClientFactory
The default implementation of the HTTP client factory.
Implements
IHttpClientFactoryNamespace
Google.Apis.HttpAssembly
Google.Apis.Core.dll
Constructors
HttpClientFactory()
public HttpClientFactory()
Creates a new instance of HttpClientFactory.
HttpClientFactory(IWebProxy)
protected HttpClientFactory(IWebProxy proxy)
Creates a new instance of HttpClientFactory that will set the given proxy on HTTP clients created by this factory.
Name | Description |
proxy | IWebProxy The proxy to set on HTTP clients created by this factory. May be null, in which case no proxy will be used. |
Properties
Proxy
public IWebProxy Proxy { get; }
Gets the proxy to use when creating HTTP clients, if any. May be null, in which case, no proxy will be set for HTTP clients created by this factory.
Type | Description |
IWebProxy |
Methods
CreateClientHandler()
protected virtual HttpClientHandler CreateClientHandler()
Create a HttpClientHandler for use when communicating with the server. Please read the remarks closely before overriding this method.
Type | Description |
HttpClientHandler | A suitable HttpClientHandler. |
When overriding this method, please observe the following:
- AllowAutoRedirect and AutomaticDecompression of the returned instance are configured after this method returns. Configuring these within this method will have no effect.
- Proxy is set in this method to Proxy if Proxy value is not null. You may override that behaviour.
- Return a new instance of an HttpClientHandler for each call to this method.
- This method may be called once, or more than once, when initializing a single client service.
CreateHandler(CreateHttpClientArgs)
protected virtual HttpMessageHandler CreateHandler(CreateHttpClientArgs args)
Creates a HTTP message handler. Override this method to mock a message handler.
Name | Description |
args | CreateHttpClientArgs |
Type | Description |
HttpMessageHandler |
CreateHttpClient(CreateHttpClientArgs)
public ConfigurableHttpClient CreateHttpClient(CreateHttpClientArgs args)
Creates a new configurable HTTP client.
Name | Description |
args | CreateHttpClientArgs |
Type | Description |
ConfigurableHttpClient |
ForProxy(IWebProxy)
public static HttpClientFactory ForProxy(IWebProxy proxy)
Creates a new instance of HttpClientFactory that will set the given proxy on HTTP clients created by this factory.
Name | Description |
proxy | IWebProxy The proxy to set on HTTP clients created by this factory. May be null, in which case no proxy will be used. |
Type | Description |
HttpClientFactory |