Soenneker.Extensions.HttpRequestMessage
11.0.1468
Prefix Reserved
See the version list below for details.
dotnet add package Soenneker.Extensions.HttpRequestMessage --version 11.0.1468
NuGet\Install-Package Soenneker.Extensions.HttpRequestMessage -Version 11.0.1468
<PackageReference Include="Soenneker.Extensions.HttpRequestMessage" Version="11.0.1468" />
<PackageVersion Include="Soenneker.Extensions.HttpRequestMessage" Version="11.0.1468" />
<PackageReference Include="Soenneker.Extensions.HttpRequestMessage" />
paket add Soenneker.Extensions.HttpRequestMessage --version 11.0.1468
#r "nuget: Soenneker.Extensions.HttpRequestMessage, 11.0.1468"
#:package Soenneker.Extensions.HttpRequestMessage@11.0.1468
#addin nuget:?package=Soenneker.Extensions.HttpRequestMessage&version=11.0.1468
#tool nuget:?package=Soenneker.Extensions.HttpRequestMessage&version=11.0.1468
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 | net11.0 is compatible. |
-
net11.0
- Soenneker.Extensions.HttpContent (>= 11.0.1050)
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 |
|---|---|---|
| 11.0.1471 | 6 | 12/1/2026 |
| 11.0.1470 | 36 | 12/1/2026 |
| 11.0.1469 | 90 | 12/1/2026 |
| 11.0.1468 | 278 | 12/1/2026 |
| 11.0.1467 | 216 | 11/30/2026 |
| 11.0.1466 | 338 | 11/30/2026 |
| 11.0.1465 | 333 | 11/30/2026 |
| 11.0.1464 | 378 | 11/29/2026 |
| 11.0.1463 | 1,180 | 11/19/2026 |
| 11.0.1462 | 332 | 11/18/2026 |
| 11.0.1461 | 260 | 11/18/2026 |
| 11.0.1459 | 1,136 | 11/15/2026 |
| 11.0.1457 | 1,481 | 11/11/2026 |
| 11.0.1456 | 202 | 11/11/2026 |
| 11.0.1455 | 113 | 11/11/2026 |
| 11.0.1454 | 472 | 11/11/2026 |
| 11.0.1453 | 93 | 11/11/2026 |
| 11.0.1451 | 814 | 11/10/2026 |
| 11.0.1450 | 2,301 | 11/3/2026 |
| 11.0.1449 | 394 | 11/3/2026 |
Updated Multiple NuGet packages