Pass bigger buffer size to StreamCopyOperation.CopyToAsync (#148)

This commit is contained in:
Pavel Krymets 2016-07-22 09:21:52 -07:00 committed by GitHub
parent 482987bd23
commit c4220c3d8c
1 changed files with 3 additions and 1 deletions

View File

@ -22,6 +22,7 @@ namespace Microsoft.AspNetCore.StaticFiles
{
internal struct StaticFileContext
{
private const int StreamCopyBufferSize = 64 * 1024;
private readonly HttpContext _context;
private readonly StaticFileOptions _options;
private readonly PathString _matchUrl;
@ -356,7 +357,8 @@ namespace Microsoft.AspNetCore.StaticFiles
Stream readStream = _fileInfo.CreateReadStream();
try
{
await StreamCopyOperation.CopyToAsync(readStream, _response.Body, _length, _context.RequestAborted);
// Larger StreamCopyBufferSize is required because in case of FileStream readStream isn't going to be buffering
await StreamCopyOperation.CopyToAsync(readStream, _response.Body, _length, StreamCopyBufferSize, _context.RequestAborted);
}
finally
{