Skip to content

Commit

Permalink
fix: leave response stream open after reading
Browse files Browse the repository at this point in the history
  • Loading branch information
alexpop-zengenti committed May 9, 2024
1 parent e1b13e8 commit 1c2df81
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ private async Task HandleResponse(HttpContext context, EndpointResponse response

// The content may have changed due to resolving pagelets and re-writing static paths, so get the actual length.
var responseContent = response.ToStream(true);
if (responseContent is MemoryStream)
if (responseContent is MemoryStream && context.Response.ContentLength != responseContent.Length)
{
context.Response.ContentLength = responseContent.Length;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ public async Task<EndpointResponse> Invoke(
var endpointResponseStream = endpointResponse.ToStream(true);
if (endpointResponseStream is { Length: > 0 } and MemoryStream stream)
{
using var reader = new StreamReader(stream);
responseContent = await reader.ReadToEndAsync();
using var reader = new StreamReader(stream, leaveOpen: true);
responseContent = await reader.ReadToEndAsync( );
}
}
}
Expand Down

0 comments on commit 1c2df81

Please sign in to comment.