aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations/HttpServer/RangeRequestWriter.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Server.Implementations/HttpServer/RangeRequestWriter.cs')
-rw-r--r--MediaBrowser.Server.Implementations/HttpServer/RangeRequestWriter.cs14
1 files changed, 12 insertions, 2 deletions
diff --git a/MediaBrowser.Server.Implementations/HttpServer/RangeRequestWriter.cs b/MediaBrowser.Server.Implementations/HttpServer/RangeRequestWriter.cs
index 9de6972f8..5fd43aa76 100644
--- a/MediaBrowser.Server.Implementations/HttpServer/RangeRequestWriter.cs
+++ b/MediaBrowser.Server.Implementations/HttpServer/RangeRequestWriter.cs
@@ -1,10 +1,10 @@
-using System.Threading;
-using ServiceStack.Web;
+using ServiceStack.Web;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Net;
+using System.Threading;
using System.Threading.Tasks;
namespace MediaBrowser.Server.Implementations.HttpServer
@@ -24,6 +24,9 @@ namespace MediaBrowser.Server.Implementations.HttpServer
private long RangeLength { get; set; }
private long TotalContentLength { get; set; }
+ public bool Throttle { get; set; }
+ public long ThrottleLimit { get; set; }
+
/// <summary>
/// The _options
/// </summary>
@@ -159,6 +162,13 @@ namespace MediaBrowser.Server.Implementations.HttpServer
/// <param name="responseStream">The response stream.</param>
public void WriteTo(Stream responseStream)
{
+ if (Throttle)
+ {
+ responseStream = new ThrottledStream(responseStream, ThrottleLimit)
+ {
+ MinThrottlePosition = ThrottleLimit * 180
+ };
+ }
var task = WriteToAsync(responseStream);
Task.WaitAll(task);