Repository navigation
Add configurable MaximumReadableBytes via HttpResponseFormatterOptions - #166
Merged
Merged
Conversation
adrianiftode
marked this pull request as ready for review
October 7, 2026 10:26
This was referenced Oct 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #167
What
Makes the content truncation limit (
MaximumReadableBytes) configurable, without breaking existing users:HttpResponseFormatterOptionsonHttpMessageFormatter:ResponseFormatterOptionsonFluentAssertionsWebConfig/AwesomeAssertionsWebConfig, set the same way as the existingSerializersetting:Why
The limit was a hard-coded
const(10 * 128 * 1024) inContentFormatterOptions, so users had no way to print more (or less) of a large response in their assertion failure messages.How
HttpResponseFormatterOptionsis a public parameter object withMaximumReadableBytes(defaults to the previous const value, must be> 0).Formatoverload rather than an optional parameter on the existing method, so the change is both source- and binary-compatible —response.Format()keeps working untouched.Appender→ProcessorsRunner→ content processors →ProcessorBase.AppendContentWithinLimits), including multipart parts.HttpMessageFormatteritself keeps no global state. The global lives only inFluentAssertionsWebConfig(andAwesomeAssertionsWebConfigvia theAAVlink-compiled source) and is read by theHttpResponseMessageFormatteradapter when it renders assertion failure messages. The*.Web.Typesprojects now referenceHttpMessageFormatter.InternalServerErrorProcessorstill bypasses the limit, exactly as before.Tests
HttpMessageFormatter.Tests: truncation with a custom limit throughFormat(options), defaults unchanged, invalid values throw, plus processor-level coverage.FluentAssertions.Web.FluentAssertionsWebConfig.TestsandAwesomeAssertions.Web.AwesomeAssertionsWebConfig.Tests: default value and the global option limiting the formatted failure message (save/restore viaIDisposable, non-parallelized collection).Full solution builds with 0 errors, all tests pass on
net9.0/net10.0for the FluentAssertions.Web, .v8 and AwesomeAssertions flavors, anddotnet packsucceeds. Docs updated in the package readme and the root readme.