HttpMessageHandler Class (System.Net.Http) (original) (raw)

Definition

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

A base type for HTTP message handlers.

public ref class HttpMessageHandler abstract : IDisposable
public abstract class HttpMessageHandler : IDisposable
type HttpMessageHandler = class
    interface IDisposable
Public MustInherit Class HttpMessageHandler
Implements IDisposable

Inheritance

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.

Applies to