aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations/HttpServer/RangeRequestWriter.cs
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2015-07-31 16:38:08 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2015-07-31 16:38:08 -0400
commita7b25c065c831804c701c44f30b277c9c7689ac3 (patch)
tree9a6ec8af764cefcb414dbc172804203cc7df908c /MediaBrowser.Server.Implementations/HttpServer/RangeRequestWriter.cs
parent25395c5d82a9136253706a7fed5a552dcc452acd (diff)
update stream buffering
Diffstat (limited to 'MediaBrowser.Server.Implementations/HttpServer/RangeRequestWriter.cs')
-rw-r--r--MediaBrowser.Server.Implementations/HttpServer/RangeRequestWriter.cs13
1 files changed, 7 insertions, 6 deletions
diff --git a/MediaBrowser.Server.Implementations/HttpServer/RangeRequestWriter.cs b/MediaBrowser.Server.Implementations/HttpServer/RangeRequestWriter.cs
index 322114112..f20487733 100644
--- a/MediaBrowser.Server.Implementations/HttpServer/RangeRequestWriter.cs
+++ b/MediaBrowser.Server.Implementations/HttpServer/RangeRequestWriter.cs
@@ -28,6 +28,9 @@ namespace MediaBrowser.Server.Implementations.HttpServer
public Action OnComplete { get; set; }
private readonly ILogger _logger;
+ // 256k
+ private const int BufferSize = 262144;
+
/// <summary>
/// The _options
/// </summary>
@@ -187,7 +190,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
// If the requested range is "0-", we can optimize by just doing a stream copy
if (RangeEnd >= TotalContentLength - 1)
{
- source.CopyTo(responseStream);
+ source.CopyTo(responseStream, BufferSize);
}
else
{
@@ -211,8 +214,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
private void CopyToInternal(Stream source, Stream destination, long copyLength)
{
- const int bufferSize = 81920;
- var array = new byte[bufferSize];
+ var array = new byte[BufferSize];
int count;
while ((count = source.Read(array, 0, array.Length)) != 0)
{
@@ -249,7 +251,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
// If the requested range is "0-", we can optimize by just doing a stream copy
if (RangeEnd >= TotalContentLength - 1)
{
- await source.CopyToAsync(responseStream).ConfigureAwait(false);
+ await source.CopyToAsync(responseStream, BufferSize).ConfigureAwait(false);
}
else
{
@@ -268,8 +270,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
private async Task CopyToAsyncInternal(Stream source, Stream destination, int copyLength, CancellationToken cancellationToken)
{
- const int bufferSize = 81920;
- var array = new byte[bufferSize];
+ var array = new byte[BufferSize];
int count;
while ((count = await source.ReadAsync(array, 0, array.Length, cancellationToken).ConfigureAwait(false)) != 0)
{