Class HttpClientFactory
The default implementation of the HTTP client factory.
Implements
Inherited Members
Namespace: Google.Apis.Http
Assembly: Google.Apis.Core.dll
Syntax
public class HttpClientFactory : IHttpClientFactory
Constructors
HttpClientFactory()
Creates a new instance of Http
Declaration
public HttpClientFactory()
HttpClientFactory(IWebProxy)
Creates a new instance of Http
Declaration
protected HttpClientFactory(IWebProxy proxy)
Parameters
Type | Name | Description |
---|---|---|
IWeb |
proxy | The proxy to set on HTTP clients created by this factory. May be null, in which case no proxy will be used. |
Properties
Proxy
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.
Declaration
public IWebProxy Proxy { get; }
Property Value
Type | Description |
---|---|
IWeb |
Methods
CreateClientHandler()
Create a Http
Declaration
protected virtual HttpClientHandler CreateClientHandler()
Returns
Type | Description |
---|---|
Http |
A suitable Http |
Remarks
When overriding this method, please observe the following:
- Allow
Auto and AutomaticRedirect Decompression 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 Http
Client for each call to this method.Handler - This method may be called once, or more than once, when initializing a single client service.
CreateHandler(CreateHttpClientArgs)
Creates a HTTP message handler. Override this method to mock a message handler.
Declaration
protected virtual HttpMessageHandler CreateHandler(CreateHttpClientArgs args)
Parameters
Type | Name | Description |
---|---|---|
Create |
args |
Returns
Type | Description |
---|---|
Http |
CreateHttpClient(CreateHttpClientArgs)
Creates a new configurable HTTP client.
Declaration
public ConfigurableHttpClient CreateHttpClient(CreateHttpClientArgs args)
Parameters
Type | Name | Description |
---|---|---|
Create |
args |
Returns
Type | Description |
---|---|
Configurable |
ForProxy(IWebProxy)
Creates a new instance of Http
Declaration
public static HttpClientFactory ForProxy(IWebProxy proxy)
Parameters
Type | Name | Description |
---|---|---|
IWeb |
proxy | The proxy to set on HTTP clients created by this factory. May be null, in which case no proxy will be used. |
Returns
Type | Description |
---|---|
Http |