public void Dispose() { Handler.Dispose(); _server.Dispose(); _testMongoDb.Dispose(); SmtpServer.Dispose(); }
public void Dispose() { // TODO: I don't like this, but in the time scope we need to put it off _connection?.StopAsync().Wait(); _connection?.DisposeAsync().Wait(); _httpMessageHandler?.Dispose(); }
public AsyncClient( string auth, int timeout, ProductInfoHeaderValue userAgent, HttpMessageHandler httpMessageHandler = null ) { _httpMessageHandler = httpMessageHandler ?? new HttpClientHandler(); try { _httpClient = new HttpClient(_httpMessageHandler) { DefaultRequestHeaders = { Authorization = new AuthenticationHeaderValue("Basic", auth), Accept = { new MediaTypeWithQualityHeaderValue("application/json") }, UserAgent = { userAgent } }, Timeout = TimeSpan.FromMilliseconds(timeout) }; } catch { _httpClient?.Dispose(); _httpMessageHandler.Dispose(); throw; } }
/// <summary> /// Disposes the underlying HttpClient and HttpMessageHandler, setting both properties to null. /// This FlurlClient can still be reused, but those underlying objects will be re-created as needed. Previously set headers, etc, will be lost. /// </summary> public void Dispose() { _httpMessageHandler?.Dispose(); _httpClient?.Dispose(); _httpMessageHandler = null; _httpClient = null; }
protected override void Dispose(bool disposing) { base.Dispose(disposing); if (disposing) { _innerHandler.Dispose(); } }
/// <summary> /// Disposes the underlying HttpClient and HttpMessageHandler, setting both properties to null. /// This FlurlClient can still be reused, but those underlying objects will be re-created as needed. Previously set headers, etc, will be lost. /// </summary> public void Dispose() { _httpMessageHandler?.Dispose(); _httpClient?.Dispose(); _httpMessageHandler = null; _httpClient = null; Cookies = new Dictionary <string, Cookie>(); }
protected virtual void Dispose(bool disposing) { if (disposing) { _httpClient?.Dispose(); _httpMessageHandler?.Dispose(); } }
/// <summary> /// Implementation of the <see cref="IDisposable"/> pattern for derived classes to use /// </summary> /// <param name="disposing">True if calling from <see cref="Dispose()"/> or the finalizer.</param> protected virtual void Dispose(bool disposing) { if (disposing) { roothandler?.Dispose(); roothandler = null; client?.Dispose(); client = null; } }
/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting /// unmanaged resources. /// </summary> /// <remarks> /// Since this class is <see langword="sealed"/>, the standard <see /// cref="IDisposable.Dispose"/> pattern is not required. Also, <see /// cref="GC.SuppressFinalize"/> is not needed. /// </remarks> public void Dispose() { if (_disposed) { return; } _handler?.Dispose(); _disposed = true; }
private bool disposedValue; // To detect redundant calls protected virtual void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { IsConnected = false; messageHandler.Dispose(); } disposedValue = true; } }
/// <summary> /// Disposes the current instance. /// </summary> /// <remarks> /// This will dispose the underlying <see cref="HttpClientHandler"/>, /// so it can only be called after it is no longer in use. /// </remarks> protected virtual void Dispose(bool disposing) { if (!_disposed) { if (disposing) { // TODO: This has high potential to cause coding defects. See if we can do better, // perhaps do something like `Microsoft.Extensions.Http.LifetimeTrackingHttpMessageHandler`. _handler.Dispose(); } _disposed = true; } }
public void Dispose() { if (!string.IsNullOrEmpty(json)) { json = null; } if (httpClient != null) { httpClient.Dispose(); handler.Dispose(); _serializer = null; } }
public void Dispose() { if (_messageHandler != null) { _messageHandler.Dispose(); _messageHandler = null; } if (_httpClient != null) { _httpClient.Dispose(); _httpClient = null; } }
protected virtual void Dispose(bool disposing) { if (Disposed) { return; } if (disposing) { LastHttpClient?.Dispose(); _httpMessageHandler.Dispose(); } Disposed = true; }
/// <summary> /// Dispose of the underlying HttpClient. /// </summary> /// <param name="disposing"></param> private void Dispose(bool disposing) { if (_disposed) { return; } if (disposing) { _httpClient.Dispose(); _httpMessageHandler.Dispose(); } _disposed = true; }
protected virtual void Dispose(bool disposing) { if (_disposed) { return; } if (disposing) { _httpClient.Dispose(); _httpMessageHandler?.Dispose(); } _disposed = true; }
private bool disposedValue; // To detect redundant calls protected virtual void Dispose(bool disposing) { logger.Debug("Disposing SonarQubeService..."); if (!disposedValue) { logger.Debug("SonarQubeService was not disposed, continuing with dispose..."); if (disposing) { IsConnected = false; SonarQubeVersion = null; messageHandler.Dispose(); } disposedValue = true; } }
public async Task Shutdown(bool keepDb = false) { StoppingTime.Start(); _kestrelTestServer.Dispose(); HttpMessageHandler.Dispose(); HttpClient.Dispose(); await Node.StopAsync().WithTimeout(TimeSpan.FromSeconds(20)).ConfigureAwait(false); if (!keepDb) { TryDeleteDirectory(DbPath); } StoppingTime.Stop(); RunningTime.Stop(); }
/// <summary> /// Releases all associated resources. /// </summary> /// <param name="disposing">Pass <c>true</c> if we're disposing, <c>false</c> if we're finalizing.</param> protected void Dispose(bool disposing) { if (disposing) { if (client != null) { client.Dispose(); client = null; } if (handler != null && disposeHandler) { handler.Dispose(); handler = null; } } }
public static void Teardown() { _iPackageHandler = null; _iRequestHandler = null; _iAttributionHandler = null; _logger = null; _httpMessageHandler?.Dispose(); _httpMessageHandler = null; _packageHandlerBackoffStrategy = null; _sdkClickHandlerBackoffStrategy = null; _timerInterval = DefaultTimerInterval; _timerStart = DefaultTimerStart; _sessionInterval = DefaultSessionInterval; _subsessionInterval = DefaultSubsessionInterval; _maxDelayStart = DefaultMaxDelayStart; _baseUrl = Constants.BASE_URL; }
private bool disposedValue = false; // To detect redundant calls protected virtual void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { Config.Updated -= HandleConfigUpdateEvent; if (HttpClient != null && !skipClientDispose) { HttpClient.Dispose(); } if (Handler != null) { Handler.Dispose(); } } disposedValue = true; } }
/// <summary> /// Constructor for minFraud web service client. /// </summary> /// <param name="accountId">Your MaxMind account ID.</param> /// <param name="licenseKey">Your MaxMind license key.</param> /// <param name="locales">A list of locale codes to use for name property.</param> /// <param name="host">The host to use when connecting to the web service.</param> /// <param name="timeout">The timeout to use for the request.</param> /// <param name="httpMessageHandler">Handler to use in request. For unit testing only.</param> public WebServiceClient( int accountId, string licenseKey, IEnumerable <string>?locales = null, string host = "minfraud.maxmind.com", TimeSpan?timeout = null, HttpMessageHandler?httpMessageHandler = null ) { _locales = locales == null ? new List <string> { "en" } : new List <string>(locales); _httpMessageHandler = httpMessageHandler ?? new HttpClientHandler(); try { _httpClient = new HttpClient(httpMessageHandler ?? new HttpClientHandler()) { BaseAddress = new UriBuilder("https", host, -1, BasePath).Uri, DefaultRequestHeaders = { Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String( Encoding.ASCII.GetBytes( $"{accountId}:{licenseKey}"))), Accept = { new MediaTypeWithQualityHeaderValue("application/json") }, UserAgent = { new ProductInfoHeaderValue("minFraud-api-dotnet", Version) } } }; if (timeout != null) { _httpClient.Timeout = timeout.Value; } } catch { _httpClient?.Dispose(); _httpMessageHandler.Dispose(); throw; } }
/// <summary> /// Disposes the current instance. /// </summary> /// <remarks> /// This will dispose the underlying <see cref="HttpClientHandler"/>, /// so it can only be called after it is no longer in use. /// </remarks> protected virtual void Dispose(bool disposing) { if (!_disposed) { if (disposing) { // TODO: This has high potential to cause coding defects. See if we can do better, // perhaps do something like `Microsoft.Extensions.Http.LifetimeTrackingHttpMessageHandler`. _normalHandler.Dispose(); var currentUpgradableHandler = Volatile.Read(ref _upgradableHandler); if (currentUpgradableHandler != null) { if (Interlocked.CompareExchange(ref _upgradableHandler, null, currentUpgradableHandler) == currentUpgradableHandler) { } } } _disposed = true; } }
protected override void SetProxy(IWebProxyExt proxy) { proxy = proxy ?? WebProxyExt.None; if (Equals(_webProxy, proxy)) { return; } switch (proxy.Type) { case ProxyType.None: case ProxyType.Http: case ProxyType.Https: { _handler?.Dispose(); _handler = CreateDefaultHandler(_webProxy); break; } case ProxyType.Socks5: { _handler?.Dispose(); _handler = new ProxyClientHandler <Socks5>(new ProxySettings { Port = proxy.Port, Host = proxy.Host, Credentials = proxy.Credentials as NetworkCredential }); break; } default: throw new ArgumentOutOfRangeException(nameof(proxy.Type), proxy.Type, null); } _webProxy = proxy; _httpClient?.Dispose(); SetHttpClient(); }
public void Dispose() { HttpClient?.Dispose(); _httpMessageHandler?.Dispose(); }
public override void Dispose() { _handler.Dispose(); _httpClient.Dispose(); }
/// <inheritdoc /> public void Dispose() { _handler.Dispose(); }
public void Dispose() { _httpClient?.Dispose(); _handler?.Dispose(); }
public void Dispose() { _handler?.Dispose(); _host?.Dispose(); _server?.Dispose(); }
public void Dispose() { _messageHandler.Dispose(); }