HttpMessageFormatter 2.0.10
dotnet add package HttpMessageFormatter --version 2.0.10
NuGet\Install-Package HttpMessageFormatter -Version 2.0.10
<PackageReference Include="HttpMessageFormatter" Version="2.0.10" />
<PackageVersion Include="HttpMessageFormatter" Version="2.0.10" />
<PackageReference Include="HttpMessageFormatter" />
paket add HttpMessageFormatter --version 2.0.10
#r "nuget: HttpMessageFormatter, 2.0.10"
#:package HttpMessageFormatter@2.0.10
#addin nuget:?package=HttpMessageFormatter&version=2.0.10
#tool nuget:?package=HttpMessageFormatter&version=2.0.10
HttpMessageFormatter is the shared HTTP request/response rendering engine behind the FluentAssertions.Web, FluentAssertions.Web.v8, AwesomeAssertions.Web and Shouldly.Web assertion libraries, published on its own so it can be used in any other context too.
It formats HTTP request and response messages for inspection and debugging, producing rich, readable output that includes headers, content, status codes, and more. This library has no dependencies on any assertion framework, making it suitable for general-purpose use.
Basic Usage
using HttpMessageFormatter;
public class HttpResponseFormatterExtensionsTests
{
[Fact]
public void GivenUnspecifiedResponse_ShouldFormatBasicResponse()
{
// Arrange
using var subject = new HttpResponseMessage();
// Act
var formatted = subject.Format();
// Assert
Assert.Contains("The HTTP response was:", formatted);
Assert.Contains("HTTP/1.1 200 OK", formatted);
}
}
Limiting The Printed Content
By default, only the first 10 * 128 * 1024 characters of the content are printed. Pass an
HttpResponseFormatterOptions parameter object to change this limit:
using HttpMessageFormatter;
var formatted = subject.Format(new HttpResponseFormatterOptions
{
MaximumReadableBytes = 4 * 1024
});
Customizing The Formatted Output
HttpResponseFormatterOptions also exposes two optional delegates that give full control over the
formatted output of both the response and the originating request:
ResponseFormatter(Func<HttpResponseMessage, string>) — when configured, it replaces the built-in formatting entirely. It receives the completeHttpResponseMessage(the originating request is available through itsRequestMessageproperty) and returns the text to be printed. When it is set, the built-in pipeline, including the content processors and theMaximumReadableByteslimit, is bypassed.PostFormat(Func<string, string>) — when configured, it transforms the final formatted output, whether it was produced by the built-in formatting or byResponseFormatter. It can be used, for example, to make escaped newlines in stack traces readable or to redact sensitive values.
var formatted = subject.Format(new HttpResponseFormatterOptions
{
PostFormat = formattedOutput => formattedOutput.Replace("\\r\\n", Environment.NewLine)
});
Both delegates are optional; when neither is set, the formatting is unchanged. If a delegate throws, the exception is reported into the formatted output, similar to any other formatting error.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.AspNetCore.WebUtilities (>= 2.3.14)
- System.Net.Http.Json (>= 8.0.1)
- System.Text.Encodings.Web (>= 8.0.0)
- System.Text.Json (>= 8.0.6)
-
net10.0
- Microsoft.AspNetCore.WebUtilities (>= 2.3.14)
-
net8.0
- Microsoft.AspNetCore.WebUtilities (>= 2.3.14)
NuGet packages (4)
Showing the top 4 NuGet packages that depend on HttpMessageFormatter:
| Package | Downloads |
|---|---|
|
FluentAssertions.Web
This is a FluentAssertions extension over the HttpResponseMessage object. It provides specific assertions and outputs rich erros messages that include the HTTP Request and Response. This version **DOES NOT** depend on the commercial version of the FluentAssertions library (>= 8.0.0). |
|
|
AwesomeAssertions.Web
This is a AwesomeAssertions extension over the HttpResponseMessage object. It provides specific assertions and outputs rich erros messages that include the HTTP Request and Response. |
|
|
FluentAssertions.Web.v8
This is a FluentAssertions extension over the HttpResponseMessage object. It provides specific assertions and outputs rich erros messages that include the HTTP Request and Response. This version depends on the commercial version of the FluentAssertions library (>= 8.0.0). |
|
|
Shouldly.Web
A Shouldly extension over the HttpResponseMessage object. It provides HTTP-specific assertions whose failure messages include the HTTP request and response. Prerelease until Shouldly 5.0.0 is stable; requires Shouldly >= 5.0.0-preview.2 (EquivalencyOptions). This is an unofficial, community-maintained extension and is not endorsed by the Shouldly project. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.0.10 | 10 | 11/18/2026 |
| 2.0.10-preview.1 | 41 | 11/18/2026 |
| 2.0.9 | 2,369 | 11/15/2026 |
| 2.0.8 | 745 | 11/14/2026 |
| 2.0.7 | 1,924 | 11/12/2026 |
| 2.0.6 | 60,584 | 10/9/2026 |
| 2.0.5 | 8,202 | 10/7/2026 |
| 2.0.4 | 8,614 | 10/2/2026 |
| 2.0.3 | 124,272 | 7/30/2026 |
| 2.0.2 | 1,398 | 7/30/2026 |
| 2.0.1 | 206 | 7/30/2026 |
| 2.0.0 | 5,009 | 7/23/2026 |
| 0.0.0-ci-286 | 192 | 10/2/2026 |
| 0.0.0-ci-285 | 205 | 10/2/2026 |