Content-Length: 272768 | pFad | https://github.com/adrianiftode/FluentAssertions.Web/pull/122

99 Print the Content-Length header only if it actually exists by 0xced · Pull Request #122 · adrianiftode/FluentAssertions.Web · GitHub
Skip to content

Print the Content-Length header only if it actually exists #122

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 24, 2024

Conversation

0xced
Copy link
Contributor

@0xced 0xced commented May 24, 2024

It is unsettling to see the "Content-Length" header printed in the diagnosis messages even though it is not actually present in the request and/or response headers.

Note that we can't just test whether the ContentLength property is null or not because the HttpContentHeaders.ContentLength implementation automatically computes a value even if the Content-Length is not present. This is why using content.Headers.TryGetValues is mandatory.

It is unsettling to see the "Content-Length" header printed in the diagnosis messages even though it is not actually present in the request and/or response headers.

Note that we can't just test whether the `ContentLength` property is null or not because the [HttpContentHeaders.ContentLength implementation][1] automatically computes a value even if the Content-Length is not present. This is why using `content.Headers.TryGetValues` is mandatory.

[1]: https://github.com/dotnet/runtime/blob/v8.0.5/src/libraries/System.Net.Http/src/System/Net/Http/Headers/HttpContentHeaders.cs#L41-L55
@adrianiftode adrianiftode merged commit 8dd989b into adrianiftode:master May 24, 2024
1 check passed
@0xced 0xced deleted the ContentLength branch May 24, 2024 17:10
@0xced
Copy link
Contributor Author

0xced commented May 24, 2024

Thanks for merging a releasing a new version so quickly! 🚀

@adrianiftode
Copy link
Owner

adrianiftode commented May 24, 2024 via email

0xced added a commit to 0xced/FluentAssertions.Web that referenced this pull request Sep 2, 2024
Pull request adrianiftode#122 accidentally introduced a potential NullReferenceException.

Unfortunately the .NET Standard 2.0 assemblies don't have correct nullable annotations. `System.Net.Http.HttpRequestMessage.Content` is actually nullable and should be handled as such.
@0xced 0xced mentioned this pull request Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/adrianiftode/FluentAssertions.Web/pull/122

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy