aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/HttpServer/RangeRequestWriter.cs
diff options
context:
space:
mode:
authorstefan <stefan@hegedues.at>2018-09-12 19:26:21 +0200
committerstefan <stefan@hegedues.at>2018-09-12 19:26:21 +0200
commit48facb797ed912e4ea6b04b17d1ff190ac2daac4 (patch)
tree8dae77a31670a888d733484cb17dd4077d5444e8 /Emby.Server.Implementations/HttpServer/RangeRequestWriter.cs
parentc32d8656382a0eacb301692e0084377fc433ae9b (diff)
Update to 3.5.2 and .net core 2.1
Diffstat (limited to 'Emby.Server.Implementations/HttpServer/RangeRequestWriter.cs')
-rw-r--r--Emby.Server.Implementations/HttpServer/RangeRequestWriter.cs10
1 files changed, 5 insertions, 5 deletions
diff --git a/Emby.Server.Implementations/HttpServer/RangeRequestWriter.cs b/Emby.Server.Implementations/HttpServer/RangeRequestWriter.cs
index 7c967949b..4177c7e78 100644
--- a/Emby.Server.Implementations/HttpServer/RangeRequestWriter.cs
+++ b/Emby.Server.Implementations/HttpServer/RangeRequestWriter.cs
@@ -58,7 +58,7 @@ namespace Emby.Server.Implementations.HttpServer
/// <param name="source">The source.</param>
/// <param name="contentType">Type of the content.</param>
/// <param name="isHeadRequest">if set to <c>true</c> [is head request].</param>
- public RangeRequestWriter(string rangeHeader, Stream source, string contentType, bool isHeadRequest, ILogger logger)
+ public RangeRequestWriter(string rangeHeader, long contentLength, Stream source, string contentType, bool isHeadRequest, ILogger logger)
{
if (string.IsNullOrEmpty(contentType))
{
@@ -76,17 +76,17 @@ namespace Emby.Server.Implementations.HttpServer
StatusCode = HttpStatusCode.PartialContent;
Cookies = new List<Cookie>();
- SetRangeValues();
+ SetRangeValues(contentLength);
}
/// <summary>
/// Sets the range values.
/// </summary>
- private void SetRangeValues()
+ private void SetRangeValues(long contentLength)
{
var requestedRange = RequestedRanges[0];
- TotalContentLength = SourceStream.Length;
+ TotalContentLength = contentLength;
// If the requested range is "0-", we can optimize by just doing a stream copy
if (!requestedRange.Value.HasValue)
@@ -105,7 +105,7 @@ namespace Emby.Server.Implementations.HttpServer
Headers["Content-Length"] = RangeLength.ToString(UsCulture);
Headers["Content-Range"] = string.Format("bytes {0}-{1}/{2}", RangeStart, RangeEnd, TotalContentLength);
- if (RangeStart > 0)
+ if (RangeStart > 0 && SourceStream.CanSeek)
{
SourceStream.Position = RangeStart;
}