IHttpClientService
Overview
public WebSearchServiceBase(string url)
{
_client = ServiceHelper.GetService<IHttpClientService>();
}
internal virtual IHttpClientService Client
{
get
{
if (!_clientInitialized)
{
_clientInitialized = true;
_client.SetHandler(new HttpClientHandler
{
AllowAutoRedirect = true,
#if !NETCOREAPP
AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate
#else
AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate | DecompressionMethods.Brotli
#endif
});
var apiKey = GetApiKey();
if (!String.IsNullOrEmpty(apiKey) && !String.IsNullOrEmpty(this.Authentication))
{
_client.AddDefaultHeader(this.Authentication, apiKey);
}
}
return _client;
}
}
private bool _clientInitialized;
private IHttpClientService _client;
Default Implementation
Last updated
