HttpMessageHandler HttpMessageHandler HttpMessageHandler HttpMessageHandler Class

定義

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

備註

有各種可用的 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 -A 底部是什麼在處理 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.

建構函式

HttpMessageHandler() HttpMessageHandler() HttpMessageHandler() HttpMessageHandler()

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

方法

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

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

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

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

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

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

建立目前 Object 的淺層複本 (Shallow Copy)。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)

適用於