Skip to content

Commit ea3745b

Browse files
committed
Explanation with a comment
1 parent 8f0ca65 commit ea3745b

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/Particular.LicensingComponent/WebApi/LicensingController.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ public async Task GetThroughputReportFile([FromQuery(Name = "spVersion")] string
6868
FileName = $"{fileName}.zip"
6969
}.ToString();
7070

71+
// The zip archive is written directly to the response body stream and has to remain open until the response is fully sent.
72+
// This is done for performance reasons to avoid buffering the entire report in memory before sending it.
73+
// The BodyWriter is used as a stream to avoid into synchronous IO operations that would be prevented by the ASP.NET Core pipeline.
7174
using var archive = new ZipArchive(Response.BodyWriter.AsStream(), ZipArchiveMode.Create, leaveOpen: true);
7275
var entry = archive.CreateEntry($"{fileName}.json");
7376
await using var entryStream = entry.Open();

0 commit comments

Comments
 (0)