aspnetcore icon indicating copy to clipboard operation
aspnetcore copied to clipboard

Complete inner Pipewriter in HttpLoggingMiddleware

Open wtgodbe opened this issue 4 years ago • 0 comments

Fixes https://github.com/dotnet/aspnetcore/issues/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 avatar Feb 04 '22 17:02 wtgodbe