Skip to content

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

Closed
wants to merge 1 commit into from

Conversation

JamesNK
Copy link
Member

@JamesNK JamesNK commented Jun 16, 2019

Change TestServer to match Kestrel's behavior by sending unflushed content in pipe writer when completing request.

<Compile Update="WebHostService.cs">
<SubType>Component</SubType>
</Compile>
<Compile Update="WebHostService.cs" />
Copy link
Member Author

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();
Copy link
Member

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?

Copy link
Member

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.

Copy link
Member Author

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?

@analogrelay analogrelay added this to the 3.0.0-preview7 milestone Jun 17, 2019
@Tratcher
Copy link
Member

Recommend closing this PR. We realized this is an issue with the PipeWriter polyfill, not with the server. I'll file an issue.

@JamesNK
Copy link
Member Author

JamesNK commented Jun 17, 2019

Fix is either #11305 or changing TestServer to use pipes instead of Streams.

@JamesNK JamesNK deleted the jamesnk/testserver-pipewriter-flush branch November 11, 2019 22:51
@amcasey amcasey added the area-hosting Includes Hosting label Jun 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-hosting Includes Hosting
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants