Add Content to all HttpResponseMessages#387
Merged
dougbu merged 1 commit intoaspnet:mainfrom Feb 17, 2023
dougbu:dougbu/Newtonsoft.Json.net6.0/EmptyContent
Merged
Add Content to all HttpResponseMessages#387dougbu merged 1 commit intoaspnet:mainfrom dougbu:dougbu/Newtonsoft.Json.net6.0/EmptyContent
Content to all HttpResponseMessages#387dougbu merged 1 commit intoaspnet:mainfrom
dougbu:dougbu/Newtonsoft.Json.net6.0/EmptyContent
Conversation
- fix #386 - reenable `net6.0` tests disabled in #384 for this issue - also, check `Stream.CanSeek` less when calculating `HttpMessageContent.ContentLength` value - use inner `HttpContent.Headers.ContentLength` if available - this changes behaviour slightly for both requests and responses - observable as `HttpMessageContent.Headers.ContentLength!=null` for empty messages - for responses, avoids `ContentLength==null` versus `ContentLength==0` inconsistencies (depending on platform) - `ContentLength==null` may still occur in some corner cases (which existed before) - e.g. when inner `HttpContent` doesn't know its length and `ReadAsStreamAsync()` hasn't completed - main change means `HttpResponseMessage`s we expose to user code are consistent across platforms - note: user code won't see `EmptyContent` in `HttpResponseMessage`s we create
Tratcher
reviewed
Feb 17, 2023
Member
Tratcher
left a comment
There was a problem hiding this comment.
This version looks fine, but you say you're still seeing other issues?
Contributor
Author
Not yet. I suspect there be a few more gremlins in |
Tratcher
approved these changes
Feb 17, 2023
This was referenced Sep 2, 2025
This was referenced Dec 15, 2025
Open
This was referenced Jan 6, 2026
This was referenced Jan 31, 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.
HttpResponseMessage.Content == nullto user code #386net6.0tests disabled in Test Formatting assemblies w/net6.0#384 for this issueStream.CanSeekless when calculatingHttpMessageContent.ContentLengthvalueHttpContent.Headers.ContentLengthif availableHttpMessageContent.Headers.ContentLength!=nullfor empty messagesContentLength==nullversusContentLength==0inconsistencies (depending on platform)ContentLength==nullmay still occur in some corner cases (which existed before)HttpContentdoesn't know its length andReadAsStreamAsync()hasn't completedHttpResponseMessages we expose to user code are consistent across platformsEmptyContentinHttpResponseMessages we create