From b3de0249d8b97e305b064a45f6113d5b0d39f3bb Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 18 Jul 2015 14:07:03 -0400 Subject: replace channel tabs --- .../HttpServer/RangeRequestWriter.cs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'MediaBrowser.Server.Implementations/HttpServer/RangeRequestWriter.cs') diff --git a/MediaBrowser.Server.Implementations/HttpServer/RangeRequestWriter.cs b/MediaBrowser.Server.Implementations/HttpServer/RangeRequestWriter.cs index 8c72f9e7e..322114112 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/RangeRequestWriter.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/RangeRequestWriter.cs @@ -1,4 +1,5 @@ -using ServiceStack.Web; +using MediaBrowser.Model.Logging; +using ServiceStack.Web; using System; using System.Collections.Generic; using System.Globalization; @@ -25,6 +26,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer private long TotalContentLength { get; set; } public Action OnComplete { get; set; } + private readonly ILogger _logger; /// /// The _options @@ -61,7 +63,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer /// The source. /// Type of the content. /// if set to true [is head request]. - public RangeRequestWriter(string rangeHeader, Stream source, string contentType, bool isHeadRequest) + public RangeRequestWriter(string rangeHeader, Stream source, string contentType, bool isHeadRequest, ILogger logger) { if (string.IsNullOrEmpty(contentType)) { @@ -71,6 +73,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer RangeHeader = rangeHeader; SourceStream = source; IsHeadRequest = isHeadRequest; + this._logger = logger; ContentType = contentType; Options["Content-Type"] = contentType; @@ -188,10 +191,15 @@ namespace MediaBrowser.Server.Implementations.HttpServer } else { - CopyToInternal(source, responseStream, Convert.ToInt32(RangeLength)); + CopyToInternal(source, responseStream, RangeLength); } } } + catch (Exception ex) + { + _logger.ErrorException("Error in range request writer", ex); + throw; + } finally { if (OnComplete != null) @@ -201,7 +209,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer } } - private void CopyToInternal(Stream source, Stream destination, int copyLength) + private void CopyToInternal(Stream source, Stream destination, long copyLength) { const int bufferSize = 81920; var array = new byte[bufferSize]; @@ -210,7 +218,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer { var bytesToCopy = Math.Min(count, copyLength); - destination.Write(array, 0, bytesToCopy); + destination.Write(array, 0, Convert.ToInt32(bytesToCopy)); copyLength -= bytesToCopy; -- cgit v1.2.3