HttpMessageHandler Třída

Definice

Základní typ pro obslužné rutiny zpráv 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
Dědičnost
HttpMessageHandler
Odvozené
Implementuje

Poznámky

Existují různé obslužné rutiny zpráv HTTP, které je možné použít.There are various HTTP message handlers that can be used. Mezi ně patří následující:These include the following.

  1. DelegatingHandler – Třída použitá pro připojení obslužné rutiny do řetězce obslužné rutiny.DelegatingHandler - A class used to plug a handler into a handler chain.

  2. HttpMessageHandler – Jednoduchá třída odvozená od, která podporuje nejběžnější požadavky pro většinu aplikací.HttpMessageHandler - A simple class to derive from that supports the most common requirements for most applications.

  3. HttpClientHandler – Třída, která pracuje na konci řetězce obslužné rutiny, který ve skutečnosti zpracovává operace přenosu HTTP.HttpClientHandler - A class that operates at the bottom of the handler chain that actually handles the HTTP transport operations.

  4. WebRequestHandler – Speciální třída, která pracuje na konci třídy řetězu obslužné rutiny, která zpracovává operace přenosu HTTP s možnostmi, které jsou specifické pro System.Net.HttpWebRequest objekt.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.

Pokud vývojáři odvozují třídy z HttpMessageHandler a přepisují SendAsync metodu, musí se ujistit, že SendAsync mohou být volány souběžně pomocí různých vláken.If developers derive classes from HttpMessageHandler and override the SendAsync method, they must make sure that SendAsync can get called concurrently by different threads.

To je nezbytné, protože metody HttpClient lze volat souběžně a potřebují záruku bezpečnosti vlákna.This is necessary since methods on HttpClient can be called concurrently and need a guarantee of thread safety. Takže pokud je obslužná rutina přiřazena HttpClient instance, SendAsync Metoda obslužné rutiny může být volána současně HttpClient instancí a musí být bezpečná pro přístup z více vláken.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.

Konstruktory

HttpMessageHandler()

Inicializuje novou instanci HttpMessageHandler třídy.Initializes a new instance of the HttpMessageHandler class.

Metody

Dispose()

Uvolní nespravované prostředky a odstraní spravované prostředky, které používá HttpMessageHandler .Releases the unmanaged resources and disposes of the managed resources used by the HttpMessageHandler.

Dispose(Boolean)

Uvolní nespravované prostředky používané HttpMessageHandler a volitelně vyřadí spravované prostředky.Releases the unmanaged resources used by the HttpMessageHandler and optionally disposes of the managed resources.

Equals(Object)

Určí, zda se zadaný objekt rovná aktuálnímu objektu.Determines whether the specified object is equal to the current object.

(Zděděno od Object)
GetHashCode()

Slouží jako výchozí funkce hash.Serves as the default hash function.

(Zděděno od Object)
GetType()

Získá Type aktuální instanci.Gets the Type of the current instance.

(Zděděno od Object)
MemberwiseClone()

Vytvoří kopii aktuálního seznamu Object .Creates a shallow copy of the current Object.

(Zděděno od Object)
Send(HttpRequestMessage, CancellationToken)

Při přepsání v odvozené třídě odešle požadavek HTTP se zadaným požadavkem a tokenem zrušení.When overridden in a derived class, sends an HTTP request with the specified request and cancellation token. V opačném případě vyvolá výjimku NotSupportedException .Otherwise, throws a NotSupportedException.

SendAsync(HttpRequestMessage, CancellationToken)

Odeslat požadavek HTTP jako asynchronní operaci.Send an HTTP request as an asynchronous operation.

ToString()

Vrátí řetězec, který představuje aktuální objekt.Returns a string that represents the current object.

(Zděděno od Object)

Platí pro