Skip to content

Commit

Permalink
use Response.WriteAsync instead of HttpResponseStreamWriter (#32735)
Browse files Browse the repository at this point in the history
  • Loading branch information
ilkayilknur authored May 17, 2021
1 parent 94b7c9a commit 6a119cc
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions src/Mvc/Mvc.Core/src/ContentResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,7 @@ async Task IResult.ExecuteAsync(HttpContext httpContext)
if (Content != null)
{
response.ContentLength = resolvedContentTypeEncoding.GetByteCount(Content);

await using (var textWriter = new HttpResponseStreamWriter(response.Body, resolvedContentTypeEncoding))
{
await textWriter.WriteAsync(Content);

// Flushing the HttpResponseStreamWriter does not flush the underlying stream. This just flushes
// the buffered text in the writer.
// We do this rather than letting dispose handle it because dispose would call Write and we want
// to call WriteAsync.
await textWriter.FlushAsync();
}
await response.WriteAsync(Content, resolvedContentTypeEncoding);
}
}
}
Expand Down

0 comments on commit 6a119cc

Please sign in to comment.