The Wayback Machine - https://web.archive.org/web/20220204174701/https://github.com/dotnet/aspnetcore/pull/39989
Skip to content
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

Complete inner Pipewriter in HttpLoggingMiddleware #39989

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

@wtgodbe
Copy link
Member

@wtgodbe wtgodbe commented Feb 4, 2022

Fixes #39317. When replacing the Body feature in HttpLoggingMiddleware with a new IHttpResponseBodyFeature that wraps the original PipeWriter used by gRPC (or whoever), the implicit flush that happens in Kestrel doesn't wind up flushing the original PipeWriter. This causes Responses sent by gRPC to be silently swallowed. Instead we explicitly complete the original PipeWriter after receiving the response.

Still thinking about how to add a test for this.

Also adds new API to allow completing the PipeWriter on a StreamResponseBodyFeature:

public class StreamResponseBodyFeature
{
+   public async Task CompleteWriterAsync()
}
@wtgodbe wtgodbe requested review from halter73 and Tratcher Feb 4, 2022
@wtgodbe wtgodbe requested a review from BrennanConroy as a code owner Feb 4, 2022
@msftbot msftbot bot added the area-runtime label Feb 4, 2022
_bufferingWriter = new BufferingWriter();
}

public override bool CanSeek => _innerStream.CanSeek;
Copy link
Member Author

@wtgodbe wtgodbe Feb 4, 2022

Choose a reason for hiding this comment

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

Most of the changes to this file & ResponseBufferingStream are moving the Stream overrides from BufferingStream (now BufferingWriter) to these 2 files which now inherit from Stream

{
if (_pipeWriter != null)
{
await _pipeWriter.CompleteAsync();
Copy link
Member

@Tratcher Tratcher Feb 4, 2022

Choose a reason for hiding this comment

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

Why Complete rather than just Flush?

Copy link
Member Author

@wtgodbe wtgodbe Feb 4, 2022

Choose a reason for hiding this comment

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

In case someone else has already completed it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

2 participants