HttpMessageHandler Class

Definition

A base type for HTTP message handlers.

public abstract class HttpMessageHandler : IDisposable
Inheritance
HttpMessageHandler
Derived
Implements

Remarks

There are various HTTP message handlers that can be used. These include the following.

  1. DelegatingHandler - A class used to plug a handler into a handler chain.

  2. HttpMessageHandler - A simple class to derive from that supports the most common requirements for most applications.

  3. HttpClientHandler - A class that operates at the bottom of the handler chain that actually handles the HTTP transport operations.

  4. WebRequestHandler - A specialty class that operates at the bottom of the handler chain class that handles HTTP transport operations with options that are specific to the System.Net.HttpWebRequest object.

If developers derive classes from HttpMessageHandler and override the SendAsync method, they must make sure that SendAsync can get called concurrently by different threads.

This is necessary since methods on HttpClient can be called concurrently and need a guarantee of thread safety. So if a handler is assigned to an HttpClient instance, the SendAsync method of the handler may get called concurrently by the HttpClient instance and needs to be thread safe.

Constructors

HttpMessageHandler()

Initializes a new instance of the HttpMessageHandler class.

Methods

Dispose()

Releases the unmanaged resources and disposes of the managed resources used by the HttpMessageHandler.

Dispose(Boolean)

Releases the unmanaged resources used by the HttpMessageHandler and optionally disposes of the managed resources.

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
Send(HttpRequestMessage, CancellationToken)

When overridden in a derived class, sends an HTTP request with the specified request and cancellation token. Otherwise, throws a NotSupportedException.

SendAsync(HttpRequestMessage, CancellationToken)

Send an HTTP request as an asynchronous operation.

ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to

Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0