aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations/HttpServer
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Server.Implementations/HttpServer')
-rw-r--r--MediaBrowser.Server.Implementations/HttpServer/RangeRequestWriter.cs13
-rw-r--r--MediaBrowser.Server.Implementations/HttpServer/StreamWriter.cs5
2 files changed, 11 insertions, 7 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)
{
diff --git a/MediaBrowser.Server.Implementations/HttpServer/StreamWriter.cs b/MediaBrowser.Server.Implementations/HttpServer/StreamWriter.cs
index fe662542e..daa5b86d9 100644
--- a/MediaBrowser.Server.Implementations/HttpServer/StreamWriter.cs
+++ b/MediaBrowser.Server.Implementations/HttpServer/StreamWriter.cs
@@ -81,6 +81,9 @@ namespace MediaBrowser.Server.Implementations.HttpServer
WriteToInternal(responseStream);
}
+ // 256k
+ private const int BufferSize = 262144;
+
/// <summary>
/// Writes to async.
/// </summary>
@@ -92,7 +95,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
{
using (var src = SourceStream)
{
- src.CopyTo(responseStream);
+ src.CopyTo(responseStream, BufferSize);
}
}
catch (Exception ex)