Skip to content
This repository was archived by the owner on Nov 22, 2018. It is now read-only.

Commit c4220c3

Browse files
authored
Pass bigger buffer size to StreamCopyOperation.CopyToAsync (#148)
1 parent 482987b commit c4220c3

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/Microsoft.AspNetCore.StaticFiles/StaticFileContext.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ namespace Microsoft.AspNetCore.StaticFiles
2222
{
2323
internal struct StaticFileContext
2424
{
25+
private const int StreamCopyBufferSize = 64 * 1024;
2526
private readonly HttpContext _context;
2627
private readonly StaticFileOptions _options;
2728
private readonly PathString _matchUrl;
@@ -356,7 +357,8 @@ public async Task SendAsync()
356357
Stream readStream = _fileInfo.CreateReadStream();
357358
try
358359
{
359-
await StreamCopyOperation.CopyToAsync(readStream, _response.Body, _length, _context.RequestAborted);
360+
// Larger StreamCopyBufferSize is required because in case of FileStream readStream isn't going to be buffering
361+
await StreamCopyOperation.CopyToAsync(readStream, _response.Body, _length, StreamCopyBufferSize, _context.RequestAborted);
360362
}
361363
finally
362364
{

0 commit comments

Comments
 (0)