TestServer sends remaining content in pipe writer on complete#11268
TestServer sends remaining content in pipe writer on complete#11268JamesNK wants to merge 1 commit into
Conversation
| <Compile Update="WebHostService.cs"> | ||
| <SubType>Component</SubType> | ||
| </Compile> | ||
| <Compile Update="WebHostService.cs" /> |
There was a problem hiding this comment.
VS changed this automatically 🤷♂
| internal async Task CompleteResponseAsync() | ||
| { | ||
| // Flush any pending content in writer | ||
| await _httpContext.Response.BodyWriter.FlushAsync(); |
There was a problem hiding this comment.
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.
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.
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.