Soenneker.HttpContents.PooledByteArrays
4.0.17
Prefix Reserved
dotnet add package Soenneker.HttpContents.PooledByteArrays --version 4.0.17
NuGet\Install-Package Soenneker.HttpContents.PooledByteArrays -Version 4.0.17
<PackageReference Include="Soenneker.HttpContents.PooledByteArrays" Version="4.0.17" />
<PackageVersion Include="Soenneker.HttpContents.PooledByteArrays" Version="4.0.17" />
<PackageReference Include="Soenneker.HttpContents.PooledByteArrays" />
paket add Soenneker.HttpContents.PooledByteArrays --version 4.0.17
#r "nuget: Soenneker.HttpContents.PooledByteArrays, 4.0.17"
#:package Soenneker.HttpContents.PooledByteArrays@4.0.17
#addin nuget:?package=Soenneker.HttpContents.PooledByteArrays&version=4.0.17
#tool nuget:?package=Soenneker.HttpContents.PooledByteArrays&version=4.0.17
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 | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.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 |
|---|---|---|
| 4.0.17 | 0 | 8/30/2026 |
| 4.0.16 | 147 | 8/29/2026 |
| 4.0.15 | 15,723 | 7/28/2026 |
| 4.0.14 | 8,128 | 7/16/2026 |
| 4.0.13 | 10,400 | 6/19/2026 |
| 4.0.12 | 11,778 | 6/5/2026 |
| 4.0.11 | 13,132 | 4/22/2026 |
| 4.0.10 | 12,854 | 3/12/2026 |
| 4.0.9 | 234 | 3/12/2026 |
| 4.0.7 | 282 | 3/12/2026 |
| 4.0.6 | 5,140 | 3/10/2026 |
| 4.0.5 | 2,051 | 3/9/2026 |
| 4.0.4 | 116 | 3/9/2026 |
| 4.0.3 | 133 | 3/9/2026 |
| 4.0.2 | 7,518 | 3/4/2026 |
| 4.0.1 | 29,773 | 1/12/2026 |
Clarify pooled buffer ownership