Exemplo n.º 1
0
        protected virtual void Dispose(bool disposing)
        {
            if (Disposed)
            {
                return;
            }

            if (disposing)
            {
                LastHttpClient?.Dispose();
                _httpMessageHandler.Dispose();
            }

            Disposed = true;
        }
Exemplo n.º 2
0
        private async Task RunHttpsAvailabilityTest(HttpClientConfiguration configuration, string hostname, int basePort)
        {
            try
            {
                var clientConfiguration = new HttpClientConfiguration(
                    useHttps: true,
                    configuration.SecurityRole,
                    configuration.Timeout,
                    configuration.VerificationMode,
                    configuration.SupplyClientCertificate
                    );
                HttpMessageHandler messageHandler = null;
                HttpClient         httpsClient    = null;
                await ValidateReachability(hostname, basePort, fallbackOnProtocolError : false, clientFactory : _ =>
                {
                    messageHandler = _httpMessageHandlerFactory(clientConfiguration);
                    httpsClient    = CreateHttpClient(messageHandler, configuration.Timeout);
                    return(httpsClient, isHttps : true, isNewCreated : true); // the return value is ignored as this async task is not awaited
                }, cancellationToken : CancellationToken.None);

                lock (HttpClientLock)
                {
                    var isEqual = LastHttpClient?.Equals(httpsClient).ToString() ?? "Null";
                    Log.Info(msg => msg("GetHttpClient created new HttpClient", unencryptedTags: new Tags
                    {
                        { "debug.delay.newHttpClient", isEqual },
                        { "debug.delay.method", "Reachability" }
                    })); // we expect this not to be equal ever

                    LastHttpClient    = httpsClient;
                    LastHttpClientKey = new HttpClientConfiguration(
                        useHttps: true,
                        configuration.SecurityRole,
                        configuration.Timeout,
                        configuration.VerificationMode,
                        configuration.SupplyClientCertificate);
                    _httpMessageHandler = messageHandler;
                }
            }