| | | 1 | | // Licensed to the .NET Foundation under one or more agreements. |
| | | 2 | | // The .NET Foundation licenses this file to you under the MIT license. |
| | | 3 | | |
| | | 4 | | using System; |
| | | 5 | | using System.Collections.Generic; |
| | | 6 | | using System.Text; |
| | | 7 | | using System.Threading; |
| | | 8 | | using System.Threading.Tasks; |
| | | 9 | | |
| | | 10 | | namespace System.Net.Http |
| | | 11 | | { |
| | | 12 | | public abstract class HttpMessageHandler : IDisposable |
| | | 13 | | { |
| | 0 | 14 | | protected HttpMessageHandler() |
| | 0 | 15 | | { |
| | 0 | 16 | | if (NetEventSource.Log.IsEnabled()) NetEventSource.Info(this); |
| | 0 | 17 | | } |
| | | 18 | | |
| | | 19 | | // We cannot add abstract member to a public class in order not to break already established contract of this cl |
| | | 20 | | // So we add virtual method, override it everywhere internally and provide proper implementation. |
| | | 21 | | // Unfortunately we cannot force everyone to implement so in such case we throw NSE. |
| | | 22 | | protected internal virtual HttpResponseMessage Send(HttpRequestMessage request, CancellationToken cancellationTo |
| | 0 | 23 | | { |
| | 0 | 24 | | throw new NotSupportedException(SR.Format(SR.net_http_missing_sync_implementation, GetType(), nameof(HttpMes |
| | | 25 | | } |
| | | 26 | | |
| | | 27 | | protected internal abstract Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken ca |
| | | 28 | | |
| | | 29 | | #region IDisposable Members |
| | | 30 | | |
| | | 31 | | protected virtual void Dispose(bool disposing) |
| | 0 | 32 | | { |
| | | 33 | | // Nothing to do in base class. |
| | 0 | 34 | | } |
| | | 35 | | |
| | | 36 | | public void Dispose() |
| | 0 | 37 | | { |
| | 0 | 38 | | Dispose(true); |
| | 0 | 39 | | GC.SuppressFinalize(this); |
| | 0 | 40 | | } |
| | | 41 | | #endregion |
| | | 42 | | } |
| | | 43 | | } |