Table of Contents

Class HttpClientExtensions

Namespace
AiDotNet.Extensions
Assembly
AiDotNet.dll

Extension methods for HttpClient providing cross-platform compatibility.

public static class HttpClientExtensions
Inheritance
HttpClientExtensions
Inherited Members

Methods

GetByteArrayWithCancellationAsync(HttpClient, string, CancellationToken)

Downloads the content at the specified URL as a byte array with cancellation support.

public static Task<byte[]> GetByteArrayWithCancellationAsync(this HttpClient client, string requestUri, CancellationToken cancellationToken = default)

Parameters

client HttpClient

The HTTP client.

requestUri string

The URL to download from.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<byte[]>

The downloaded bytes.

Remarks

This extension provides a unified API for downloading byte arrays with cancellation support across all .NET target frameworks. In .NET 5+, the native overload is used. In older frameworks, GetAsync with cancellation is used followed by ReadAsByteArrayAsync.