Skip to content

Conversation

dougbu
Copy link
Contributor

@dougbu dougbu commented Feb 17, 2023

  • fix Do not expose HttpResponseMessage.Content == null to user code #386
  • 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 HttpResponseMessages we expose to user code are consistent across platforms
    • note: user code won't see EmptyContent in HttpResponseMessages we create

- 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
Copy link
Member

@Tratcher Tratcher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This version looks fine, but you say you're still seeing other issues?

@dougbu
Copy link
Contributor Author

dougbu commented Feb 17, 2023

This version looks fine, but you say you're still seeing other issues?

Not yet. I suspect there be a few more gremlins in HttpMessageContent, at least wrt. HttpMessageContent.ValidateStreamForReading(...). I haven't filed an issue about that or anything else my testing may turn up today. My plan is to do so and fix what I find in another PR.

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.

Do not expose HttpResponseMessage.Content == null to user code
2 participants