-
Notifications
You must be signed in to change notification settings - Fork 10.3k
TestServer sends remaining content in pipe writer on complete #11268
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
Conversation
<Compile Update="WebHostService.cs"> | ||
<SubType>Component</SubType> | ||
</Compile> | ||
<Compile Update="WebHostService.cs" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VS changed this automatically 🤷♂
@@ -127,6 +127,9 @@ internal void AbortRequest() | |||
|
|||
internal async Task CompleteResponseAsync() | |||
{ | |||
// Flush any pending content in writer | |||
await _httpContext.Response.BodyWriter.FlushAsync(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this redundant with PipeWriter.Complete()
that's called from CompleteWrites()
? Do you just need to reverse the calls to ReturnResponseMessageAsync and CompleteWrites?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. I'm not sure I understand this change. If the PipeWriter is completed, that should flush any pending content. The reader might see the pending data until after Complete() returns, but that's also true for FlushAsync() with a PauseWriterThreshold of anything other than 1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It isn't redundant because the unit test fails if FlushAsync isn't here.
Is there a better way to do this?
Recommend closing this PR. We realized this is an issue with the PipeWriter polyfill, not with the server. I'll file an issue. |
Fix is either #11305 or changing TestServer to use pipes instead of Streams. |
Change TestServer to match Kestrel's behavior by sending unflushed content in pipe writer when completing request.