HttpMessageHandler 類別

定義

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
繼承
HttpMessageHandler
衍生
實作

備註

您可以使用各種不同的 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-衍生自的簡單類別, 可支援大部分應用程式最常見的需求。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-在處理常式鏈類別的底部運作的特殊類別, 可使用System.Net.HttpWebRequest物件特有的選項來處理 HTTP 傳輸作業。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.

建構函式

HttpMessageHandler()

初始化 HttpMessageHandler 類別的新執行個體。Initializes a new instance of the HttpMessageHandler class.

方法

Dispose()

釋放 Unmanaged 資源,並處置 HttpMessageHandler 所使用的 Managed 資源。Releases the unmanaged resources and disposes of the managed resources used by the HttpMessageHandler.

Dispose(Boolean)

釋放 HttpMessageHandler 所使用的 Unmanaged 資源,並選擇性處置 Managed 資源。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.

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(繼承來源 Object)
GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(繼承來源 Object)
SendAsync(HttpRequestMessage, CancellationToken)

以非同步作業的方式,傳送 HTTP 要求。Send an HTTP request as an asynchronous operation.

ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)

適用於