public LinkPreviewService()
        {
            _client = new InternalHttpClient();

            //following https://developers.whatismybrowser.com/learn/browser-detection/user-agents/user-agent-best-practices
            var    assembly           = this.GetType().Assembly;
            string libUserAgentString = $"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36 Edg/97.0.1072.55 {assembly.GetName().Name}/{assembly.GetName().Version.ToString()}";

            _configWithCompression = new HttpClientConfiguration()
            {
                AcceptHeader          = "text/html",
                CustomUserAgentString = libUserAgentString,
                AllowRedirect         = false,
                UseCookies            = false,
                UseCompression        = true,
                Timeout = TimeSpan.FromSeconds(30)
            };

            _configWithOutCompression = new HttpClientConfiguration()
            {
                AcceptHeader          = "text/html",
                CustomUserAgentString = libUserAgentString,
                AllowRedirect         = false,
                UseCookies            = false,
                UseCompression        = false,
                Timeout = TimeSpan.FromSeconds(30)
            };

            _httpClientInstance = _client.GetStaticClient(_configWithCompression);
        }
        public HttpClient GetStaticClient(HttpClientConfiguration configuration)
        {
            if (_httpClientInstance == null)
            {
                var handler = new HttpClientHandler()
                {
                    AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate,
                    AllowAutoRedirect      = configuration.AllowRedirect,
                    UseCookies             = configuration.UseCookies
                };

                _httpClientInstance = new HttpClient(handler);

                if (configuration.ModifiedSince.HasValue)
                {
                    _httpClientInstance.DefaultRequestHeaders.IfModifiedSince = new DateTimeOffset(configuration.ModifiedSince.Value);
                }

                if (configuration.UseCompression)
                {
                    _httpClientInstance.DefaultRequestHeaders.AcceptEncoding.Add(new StringWithQualityHeaderValue("gzip"));
                    _httpClientInstance.DefaultRequestHeaders.AcceptEncoding.Add(new StringWithQualityHeaderValue("deflate"));
                }

                _httpClientInstance.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(configuration.AcceptHeader));
                _httpClientInstance.DefaultRequestHeaders.AcceptCharset.Add(new StringWithQualityHeaderValue(configuration.AcceptCharsetHeader));
                _httpClientInstance.Timeout = configuration.Timeout;


                if (string.IsNullOrEmpty(configuration.CustomUserAgentString))
                {
                    var assembly = this.GetType().Assembly;

                    _httpClientInstance.DefaultRequestHeaders.UserAgent.Add(
                        new ProductInfoHeaderValue(string.IsNullOrEmpty(configuration.DefaultUserAgent) ? assembly.GetName().Name : configuration.DefaultUserAgent,
                                                   string.IsNullOrEmpty(configuration.UserAgentVersion) ? assembly.GetName().Version.ToString() : configuration.UserAgentVersion));
                }
                else
                {
                    _httpClientInstance.DefaultRequestHeaders.Add("user-agent", configuration.CustomUserAgentString);
                }
            }

            return(_httpClientInstance);
        }