Soenneker.HttpContents.PooledByteArrays
11.0.31
Prefix Reserved
dotnet add package Soenneker.HttpContents.PooledByteArrays --version 11.0.31
NuGet\Install-Package Soenneker.HttpContents.PooledByteArrays -Version 11.0.31
<PackageReference Include="Soenneker.HttpContents.PooledByteArrays" Version="11.0.31" />
<PackageVersion Include="Soenneker.HttpContents.PooledByteArrays" Version="11.0.31" />
<PackageReference Include="Soenneker.HttpContents.PooledByteArrays" />
paket add Soenneker.HttpContents.PooledByteArrays --version 11.0.31
#r "nuget: Soenneker.HttpContents.PooledByteArrays, 11.0.31"
#:package Soenneker.HttpContents.PooledByteArrays@11.0.31
#addin nuget:?package=Soenneker.HttpContents.PooledByteArrays&version=11.0.31
#tool nuget:?package=Soenneker.HttpContents.PooledByteArrays&version=11.0.31
Soenneker.HttpContents.PooledByteArrays
An HttpContent implementation that sends initialized bytes from an ArrayPool<byte> rental and returns the array on disposal.
Install
dotnet add package Soenneker.HttpContents.PooledByteArrays
Usage
using System.Buffers;
using System.Net.Http.Headers;
using Soenneker.HttpContents.PooledByteArrays;
ArrayPool<byte> pool = ArrayPool<byte>.Shared;
byte[] buffer = pool.Rent(payload.Length);
payload.CopyTo(buffer);
using var content = new PooledByteArrayContent(
pool,
buffer,
payload.Length,
clearArrayOnDispose: true);
content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
using HttpResponseMessage response = await httpClient.PostAsync(
"uploads",
content,
cancellationToken);
response.EnsureSuccessStatusCode();
Construction transfers ownership of buffer to PooledByteArrayContent. Do not read, write, or return the array afterward. Disposing the content returns it to the exact pool supplied to the constructor; disposing more than once does not return it twice.
count is the content length and must be between zero and buffer.Length. Bytes after count are never serialized.
Set clearArrayOnDispose: true when the rental may contain credentials, personal data, or other sensitive bytes. Clearing is disabled by default to avoid the extra full-array write for non-sensitive, high-throughput payloads.
Keep the content alive until the HTTP operation has completed, and do not send the same instance concurrently. A send uses the owned array directly; disposing or mutating ownership while an operation is in flight is invalid.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
-
net11.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Soenneker.HttpContents.PooledByteArrays:
| Package | Downloads |
|---|---|
|
Soenneker.Extensions.HttpContent
A collection of helpful HttpContent extension methods |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 11.0.31 | 0 | 11/11/2026 |
| 11.0.30 | 5 | 11/10/2026 |
| 4.0.29 | 11,321 | 10/15/2026 |
| 4.0.28 | 762 | 10/14/2026 |
| 4.0.23 | 648 | 10/12/2026 |
| 4.0.22 | 728 | 10/12/2026 |
| 4.0.21 | 1,269 | 10/11/2026 |
| 4.0.20 | 9,999 | 9/24/2026 |
| 4.0.19 | 3,992 | 9/15/2026 |
| 4.0.18 | 4,711 | 9/12/2026 |
| 4.0.17 | 14,750 | 8/30/2026 |
| 4.0.16 | 2,419 | 8/29/2026 |
| 4.0.15 | 17,054 | 7/28/2026 |
| 4.0.14 | 8,175 | 7/16/2026 |
| 4.0.13 | 10,804 | 6/19/2026 |
| 4.0.12 | 11,806 | 6/5/2026 |
| 4.0.11 | 13,904 | 4/22/2026 |
| 4.0.10 | 12,907 | 3/12/2026 |
| 4.0.9 | 259 | 3/12/2026 |
| 4.0.7 | 306 | 3/12/2026 |
Upgrade .NET 11 release candidates to stable