HttpMessageHandler HttpMessageHandler HttpMessageHandler HttpMessageHandler Class

Definition

HTTP 消息处理程序的基类。 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
HttpMessageHandlerHttpMessageHandlerHttpMessageHandlerHttpMessageHandler
Derived
Implements

Remarks

有各种可用的 HTTP 消息处理。There are various HTTP message handles that can be used. 这些包括以下内容。These include the following.

  1. DelegatingHandler 的用来处理程序链中插入一个处理程序类。DelegatingHandler - A class used to plug a handler into a handler chain.

  2. HttpMessageHandler -A 简单类进行派生,对于大多数应用程序支持的最常见的要求。HttpMessageHandler - A simple class to derive from that supports the most common requirements for most applications.

  3. HttpClientHandler 的在底部的实际处理的 HTTP 传输操作的处理程序链进行操作一个类。HttpClientHandler - A class that operates at the bottom of the handler chain that actually handles the HTTP transport operations.

  4. WebRequestHandler 的在底部的处理选项特定于 HTTP 传输操作的处理程序链类进行操作一个特殊类System.Net.HttpWebRequest对象。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.

如果开发人员派生类从HttpMessageHandler并重写SendAsync方法,它们必须确保SendAsync获取由不同的线程同时调用。If developers derive classes from HttpMessageHandler and override the SendAsync method, they must make sure that SendAsync can get called concurrently by different threads.

这是必需的方法上以来HttpClient可并发调用,需要保证线程安全。This is necessary since methods on HttpClient can be called concurrently and need a guarantee of thread safety. 因此,如果一个处理程序分配给HttpClient实例,SendAsync处理程序的方法可能会被同时通过调用HttpClient实例和需要是线程安全。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() HttpMessageHandler() HttpMessageHandler() HttpMessageHandler()

初始化 HttpMessageHandler 类的新实例。 Initializes a new instance of the HttpMessageHandler class.

Methods

Dispose() Dispose() Dispose() Dispose()

释放由 HttpMessageHandler 使用的非托管资源和托管资源。 Releases the unmanaged resources and disposes of the managed resources used by the HttpMessageHandler.

Dispose(Boolean) Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)

释放由 HttpMessageHandler 使用的非托管资源,并可根据需要释放托管资源。 Releases the unmanaged resources used by the HttpMessageHandler and optionally disposes of the managed resources.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

确定指定的对象是否等于当前对象。 Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

作为默认哈希函数。 Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

获取当前实例的 Type Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

创建当前 Object 的浅表副本。 Creates a shallow copy of the current Object.

(Inherited from Object)
SendAsync(HttpRequestMessage, CancellationToken) SendAsync(HttpRequestMessage, CancellationToken) SendAsync(HttpRequestMessage, CancellationToken) SendAsync(HttpRequestMessage, CancellationToken)

以异步操作发送 HTTP 请求。 Send an HTTP request as an asynchronous operation.

ToString() ToString() ToString() ToString()

返回表示当前对象的字符串。 Returns a string that represents the current object.

(Inherited from Object)

Applies to