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
clientHttpClientThe HTTP client.
requestUristringThe URL to download from.
cancellationTokenCancellationTokenThe cancellation token.
Returns
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.