Skip to content
This repository was archived by the owner on Oct 11, 2023. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,18 @@ public async Task Invoke(HttpContext context)
await this._next(context);

context.Response.Body = responseStream;
memStream.Seek(0, SeekOrigin.Begin);
using (StreamReader reader = new StreamReader(memStream))
// Writing to response body is not supported for 204, 205 and 304 responses.
if (context.Response.StatusCode != 204 /* NoContent */ &&
context.Response.StatusCode != 205 /* ResetContent */ &&
context.Response.StatusCode != 304 /* NotModified */)
{
responseBody = await reader.ReadToEndAsync();
memStream.Seek(0, SeekOrigin.Begin);
using (StreamReader reader = new StreamReader(memStream))
{
responseBody = await reader.ReadToEndAsync();
}
await context.Response.WriteAsync(responseBody);
}
await context.Response.WriteAsync(responseBody);
}

if (context.Response.StatusCode >= 500)
Expand Down