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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Soenneker.HttpContents.PooledByteArrays" Version="4.0.17" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.HttpContents.PooledByteArrays" Version="4.0.17" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.HttpContents.PooledByteArrays" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Soenneker.HttpContents.PooledByteArrays --version 4.0.17
                    
#r "nuget: Soenneker.HttpContents.PooledByteArrays, 4.0.17"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Soenneker.HttpContents.PooledByteArrays@4.0.17
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Soenneker.HttpContents.PooledByteArrays&version=4.0.17
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.HttpContents.PooledByteArrays&version=4.0.17
                    
Install as a Cake Tool

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • 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