Soenneker.Extensions.HttpContent 4.0.947

Prefix Reserved
dotnet add package Soenneker.Extensions.HttpContent --version 4.0.947
                    
NuGet\Install-Package Soenneker.Extensions.HttpContent -Version 4.0.947
                    
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.Extensions.HttpContent" Version="4.0.947" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Extensions.HttpContent" Version="4.0.947" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.Extensions.HttpContent" />
                    
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.Extensions.HttpContent --version 4.0.947
                    
#r "nuget: Soenneker.Extensions.HttpContent, 4.0.947"
                    
#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.Extensions.HttpContent@4.0.947
                    
#: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.Extensions.HttpContent&version=4.0.947
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Extensions.HttpContent&version=4.0.947
                    
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.Extensions.HttpContent

Extensions for cloning, inspecting, and logging HttpContent without forcing every caller to choose its own buffering strategy.

Installation

dotnet add package Soenneker.Extensions.HttpContent

Clone content for another request

using Soenneker.Extensions.HttpContent;

using HttpContent? copy = await originalContent.Clone(cancellationToken: cancellationToken);

if (copy is not null)
{
    using var request = new HttpRequestMessage(HttpMethod.Post, destination)
    {
        Content = copy
    };

    await httpClient.SendAsync(request, cancellationToken);
}

Clone() copies the body and content headers into independently disposable content. It returns null for a null input. Cloning reads the original body, so do not assume a non-seekable original stream can be read again afterward.

An IMemoryStreamUtil can be supplied when the application already uses pooled memory streams:

using HttpContent? copy = await originalContent.Clone(memoryStreamUtil, cancellationToken);

Choose buffering or streaming

ShouldUseStream() returns true when Content-Length is unknown or greater than 64 KiB. GetSmallContentBytes() reads a body only when its declared length is at most 64 KiB:

if (content.ShouldUseStream())
{
    await using Stream stream = await content.ReadAsStreamAsync(cancellationToken);
    await ProcessStream(stream, cancellationToken);
}
else
{
    ReadOnlyMemory<byte> bytes = await content.GetSmallContentBytes(cancellationToken);
    ProcessBytes(bytes.Span);
}

GetSmallContentBytes() returns empty memory for null, zero-length, unknown-length, and oversized content. Use ShouldUseStream() when the distinction matters. These decisions trust the declared Content-Length; they are a routing aid, not an enforcement limit.

content.AddCookie("session", token, "https://api.example.com/orders");

// Or provide the domain and path separately:
content.AddCookie("session", token, "api.example.com", "/orders");

When given an absolute URI and no explicit path, AddCookie() uses the URI host and absolute path. Otherwise, it treats the third argument as a domain and defaults the path to /. The resulting header has the form name=value; Domain=domain; Path=path.

Debug logging

await content.Log(logger, cancellationToken);

Log() reads the complete body as text and writes it at Debug level. It does not read the body when debug logging is disabled. Avoid it for large, binary, credential-bearing, or personally identifiable payloads unless the configured log destination is appropriate for that data.

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.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on Soenneker.Extensions.HttpContent:

Package Downloads
Soenneker.Extensions.HttpResponseMessage

A collection of helpful HttpResponseMessage extension methods

Soenneker.Extensions.HttpRequestMessage

A collection of helpful HttpRequestMessage extension methods

Soenneker.Renovate.Jobs

A utility library for Mend Renovate job related operations

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.0.947 0 8/30/2026
4.0.946 0 8/30/2026
4.0.944 0 8/30/2026
4.0.943 26 8/30/2026
4.0.941 40 8/30/2026
4.0.940 37 8/30/2026
4.0.938 114 8/30/2026
4.0.937 256 8/29/2026
4.0.935 223 8/29/2026
4.0.934 1,251 8/26/2026
4.0.933 35 8/26/2026
4.0.932 463 8/26/2026
4.0.931 498 8/25/2026
4.0.930 1,665 8/21/2026
4.0.929 2,161 8/18/2026
4.0.928 521 8/18/2026
4.0.927 2,085 8/13/2026
4.0.926 401 8/12/2026
4.0.925 883 8/11/2026
4.0.924 1,788 8/9/2026
Loading failed

Update dependency Soenneker.Extensions.Stream to 4.0.145 (#1301)