Repository: PowerShell/PowerShell
File: src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/WebRequestSession.cs (C#)

Code before:
                handler.Proxy = Proxy;
            }

            if (Certificates is not null)
            {
                handler.ClientCertificates.AddRange(Certificates);
            }

            if (_skipCertificateCheck)
            {
                handler.ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator;
                handler.ClientCertificateOptions = ClientCertificateOption.Manual;
            }

            handler.AllowAutoRedirect = _allowAutoRedirect;
            if (_allowAutoRedirect && MaximumRedirection > 0)
            {
                handler.MaxAutomaticRedirections = MaximumRedirection;
            }

            handler.SslProtocols = (SslProtocols)_sslProtocol;

            // Check timeout setting (in seconds instead of milliseconds as in HttpWebRequest)
            return new HttpClient(handler)
            {
                Timeout = _timeoutSec is 0 ? TimeSpan.FromMilliseconds(Timeout.Infinite) : TimeSpan.FromSeconds(_timeoutSec)
            };
        }

        private void SetClassVar<T>(ref T oldValue, T newValue) where T : class?
        {
            if (oldValue != newValue)
            {
                ResetClient();
                oldValue = newValue;
            }
        }

        private void SetStructVar<T>(ref T oldValue, T newValue) where T : struct
        {
            if (!oldValue.Equals(newValue))
            {
                ResetClient();
                oldValue = newValue;
            }
        }

        private void ResetClient()
        {
            if (_client is not null)
            {

Review comment (suggestion):
```suggestion
                Timeout = _connectTimeoutSec > 0 ? TimeSpan.FromSeconds(_connectTimeoutSec) : Timeout.InfiniteTimeSpan
```

Code after:
                handler.Proxy = Proxy;
            }

            if (Certificates is not null)
            {
                handler.ClientCertificates.AddRange(Certificates);
            }

            if (_skipCertificateCheck)
            {
                handler.ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator;
                handler.ClientCertificateOptions = ClientCertificateOption.Manual;
            }

            handler.AllowAutoRedirect = _allowAutoRedirect;
            if (_allowAutoRedirect && MaximumRedirection > 0)
            {
                handler.MaxAutomaticRedirections = MaximumRedirection;
            }

            handler.SslProtocols = (SslProtocols)_sslProtocol;

            // Check timeout setting (in seconds instead of milliseconds as in HttpWebRequest)
            return new HttpClient(handler)
            {
                Timeout = _connectionTimeout
            };
        }

        private void SetClassVar<T>(ref T oldValue, T newValue) where T : class?
        {
            if (oldValue != newValue)
            {
                ResetClient();
                oldValue = newValue;
            }
        }

        private void SetStructVar<T>(ref T oldValue, T newValue) where T : struct
        {
            if (!oldValue.Equals(newValue))
            {
                ResetClient();
                oldValue = newValue;
            }
        }

        private void ResetClient()
        {
            if (_client is not null)
            {