DefaultHttpRequestHandler Class

Definition

Default implementation of IHttpRequestHandler built on HttpClient.

public sealed class DefaultHttpRequestHandler : IAsyncDisposable, Microsoft.Agents.AI.Workflows.Declarative.IHttpRequestHandler
type DefaultHttpRequestHandler = class
    interface IHttpRequestHandler
    interface IAsyncDisposable
Public NotInheritable Class DefaultHttpRequestHandler
Implements IAsyncDisposable, IHttpRequestHandler
Inheritance
DefaultHttpRequestHandler
Implements

Remarks

This handler supports per-request authentication via an optional httpClientProvider callback that returns a pre-configured HttpClient for a given request (e.g. authenticated, custom handler). When the provider returns null, or no provider is supplied, a shared internal HttpClient is used.

The handler applies the per-request Timeout using a linked CancellationTokenSource so it does not mutate Timeout on shared instances.

Constructors

Name Description
DefaultHttpRequestHandler()

Initializes a new instance of the DefaultHttpRequestHandler class that uses an internally owned HttpClient for all requests. The internal client is disposed when DisposeAsync() is called.

DefaultHttpRequestHandler(Func<HttpRequestInfo,CancellationToken,Task<HttpClient>>)

Initializes a new instance of the DefaultHttpRequestHandler class that selects an HttpClient per request via a caller-supplied callback — for example, to route different URLs through differently authenticated clients.

DefaultHttpRequestHandler(HttpClient)

Initializes a new instance of the DefaultHttpRequestHandler class that uses the supplied HttpClient for all requests.

Methods

Name Description
DisposeAsync()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.

SendAsync(HttpRequestInfo, CancellationToken)

Sends an HTTP request and returns the response.

Applies to