Soenneker.Extensions.HttpRequestMessage
4.0.1379
Prefix Reserved
See the version list below for details.
dotnet add package Soenneker.Extensions.HttpRequestMessage --version 4.0.1379
NuGet\Install-Package Soenneker.Extensions.HttpRequestMessage -Version 4.0.1379
<PackageReference Include="Soenneker.Extensions.HttpRequestMessage" Version="4.0.1379" />
<PackageVersion Include="Soenneker.Extensions.HttpRequestMessage" Version="4.0.1379" />
<PackageReference Include="Soenneker.Extensions.HttpRequestMessage" />
paket add Soenneker.Extensions.HttpRequestMessage --version 4.0.1379
#r "nuget: Soenneker.Extensions.HttpRequestMessage, 4.0.1379"
#:package Soenneker.Extensions.HttpRequestMessage@4.0.1379
#addin nuget:?package=Soenneker.Extensions.HttpRequestMessage&version=4.0.1379
#tool nuget:?package=Soenneker.Extensions.HttpRequestMessage&version=4.0.1379
Soenneker.Extensions.HttpRequestMessage
Extension methods for copying, inspecting, and preparing HttpRequestMessage instances for sending, retrying, and diagnostics.
Installation
dotnet add package Soenneker.Extensions.HttpRequestMessage
Usage
using Soenneker.Extensions.HttpRequestMessage;
using var original = new HttpRequestMessage(HttpMethod.Post, "https://api.example.com/orders")
{
Content = JsonContent.Create(order)
};
using HttpRequestMessage retry = await original.Clone(cancellationToken: cancellationToken);
using HttpResponseMessage firstResponse = await httpClient.SendAsync(original, cancellationToken);
if (!firstResponse.IsSuccessStatusCode)
{
retry.Headers.Add("X-Retry", "1");
using HttpResponseMessage retryResponse = await httpClient.SendAsync(retry, cancellationToken);
}
Create every clone before sending the original when its content may be backed by a non-seekable stream. Each request message can then be sent once.
Clone() copies the method, URI, HTTP version and version policy, request headers, options, and content headers/body. The body is buffered independently, so disposing or consuming one request does not consume the other's body. Transport state associated with a request that has already been sent is not copied.
Option values are copied by reference. If an option contains a mutable object, the original and clone still share that object.
An application already using pooled memory streams can pass its scoped utility while retaining ownership of the long-lived client:
using HttpRequestMessage copy = await request.Clone(memoryStreamUtil, cancellationToken);
The method returns ValueTask<HttpRequestMessage>. It completes synchronously when there is no content; content cloning is asynchronous and honors cancellation. The caller owns and must dispose the returned request. Passing null throws ArgumentNullException.
| 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
- Soenneker.Extensions.HttpContent (>= 4.0.947)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Soenneker.Extensions.HttpRequestMessage:
| Package | Downloads |
|---|---|
|
Soenneker.Extensions.HttpClient
A collection of helpful HttpClient extension methods, like retry and auto (de)serialization |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.0.1384 | 343 | 9/1/2026 |
| 4.0.1383 | 709 | 8/31/2026 |
| 4.0.1382 | 389 | 8/31/2026 |
| 4.0.1381 | 468 | 8/31/2026 |
| 4.0.1380 | 242 | 8/31/2026 |
| 4.0.1379 | 473 | 8/30/2026 |
| 4.0.1378 | 79 | 8/30/2026 |
| 4.0.1377 | 1,007 | 8/30/2026 |
| 4.0.1376 | 71 | 8/30/2026 |
| 4.0.1375 | 399 | 8/30/2026 |
| 4.0.1374 | 262 | 8/29/2026 |
| 4.0.1372 | 81 | 8/29/2026 |
| 4.0.1371 | 87 | 8/29/2026 |
| 4.0.1370 | 1,495 | 8/26/2026 |
| 4.0.1369 | 492 | 8/26/2026 |
| 4.0.1368 | 91 | 8/25/2026 |
| 4.0.1367 | 1,378 | 8/22/2026 |
| 4.0.1366 | 1,840 | 8/19/2026 |
| 4.0.1365 | 505 | 8/18/2026 |
| 4.0.1364 | 1,305 | 8/13/2026 |
Update dependency Soenneker.Extensions.HttpContent to 4.0.947 (#1754)