SetResponseOnHttpContext can throw - Improper use of content.Length #556
Labels
bug
Identified as a potential bug
help wanted
Not actively being worked on. If you plan to contribute, please drop a note.
merged
Issue has been merged to dev and is waiting for the next release
small effort
Likely less than a day of development effort.
Expected Behavior
Proxying should work with a custom
IHttpRequester
Actual Behavior
Proxying fails if the custom
IHttpRequester
returns a response whose content isn't wrapping aMemoryStream
. Things work by default becauseHttpClient.SendAsync
's default is to buffer the entire response into an internalMemoryStream
, which supportsStream.Length
.However, if a custom
IHttpRequester
usesHttpClient.SendAsync(..., HttpCompletionOption.ResponseHeadersRead)
, the resulting content will wrap a non-seekable stream. This will throw if trying to readStream.Length
.Culprit is
HttpContextResponder.SetResponseOnHttpContext
:Steps to Reproduce the Problem
IHttpRequester
that callsHttpClient.SendAsync(..., HttpCompletionOption.ResponseHeadersRead)
Specifications
The text was updated successfully, but these errors were encountered: