From c4220c3d8cb912f245f536e5d429868726817bb6 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Fri, 22 Jul 2016 09:21:52 -0700 Subject: [PATCH] Pass bigger buffer size to StreamCopyOperation.CopyToAsync (#148) --- src/Microsoft.AspNetCore.StaticFiles/StaticFileContext.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.StaticFiles/StaticFileContext.cs b/src/Microsoft.AspNetCore.StaticFiles/StaticFileContext.cs index 3d182b172a..3e5696744c 100644 --- a/src/Microsoft.AspNetCore.StaticFiles/StaticFileContext.cs +++ b/src/Microsoft.AspNetCore.StaticFiles/StaticFileContext.cs @@ -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 {