The Free Software Media System - Server Backend & API
Remove SetContentLength and company
Claus Viumf1c93ae618f2
diff --git a/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs b/Emby.Server.Implementations/HttpClientManager/HttpClientManager.csindex 834a494f81..ef82d1d9ee 100644--- a/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs+++ b/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs@@ -327,7 +327,6 @@ namespace Emby.Server.Implementations.HttpClientManager}httpWebRequest.ContentType = contentType;- // httpWebRequest.ContentLength = bytes.Length;(await httpWebRequest.GetRequestStreamAsync().ConfigureAwait(false)).Write(bytes, 0, bytes.Length);}catch (Exception ex)diff --git a/Emby.Server.Implementations/HttpServer/FileWriter.cs b/Emby.Server.Implementations/HttpServer/FileWriter.csindex 835c6f52ef..1375089e39 100644--- a/Emby.Server.Implementations/HttpServer/FileWriter.cs+++ b/Emby.Server.Implementations/HttpServer/FileWriter.cs@@ -63,8 +63,6 @@ namespace Emby.Server.Implementations.HttpServerif (string.IsNullOrWhiteSpace(rangeHeader)){- // TODO- //Headers["Content-Length"] = TotalContentLength.ToString(UsCulture);StatusCode = HttpStatusCode.OK;}else@@ -99,7 +97,6 @@ namespace Emby.Server.Implementations.HttpServer// Content-Length is the length of what we're serving, not the original contentvar lengthString = RangeLength.ToString(UsCulture);- // TODO Headers["Content-Length"] = lengthString;var rangeString = string.Format("bytes {0}-{1}/{2}", RangeStart, RangeEnd, TotalContentLength);Headers["Content-Range"] = rangeString;diff --git a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs b/Emby.Server.Implementations/HttpServer/HttpListenerHost.csindex 12c23a8693..6b69fa0f4e 100644--- a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs+++ b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs@@ -649,11 +649,6 @@ namespace Emby.Server.Implementations.HttpServerprivate static Task Write(IResponse response, string text){var bOutput = Encoding.UTF8.GetBytes(text);- response.SetContentLength(bOutput.Length);- // TODO- response.Headers.Remove("Content-Length"); // DO NOT SET THIS, IT'S DONE AUTOMATICALLY BECAUSE MS ARE NOT STUPID- response.SendChunked = true;-return response.OutputStream.WriteAsync(bOutput, 0, bOutput.Length);}@@ -672,6 +667,7 @@ namespace Emby.Server.Implementations.HttpServer}else{+ // TODO what is this?var httpsUrl = url.Replace("http://", "https://", StringComparison.OrdinalIgnoreCase).Replace(":" + _config.Configuration.PublicPort.ToString(CultureInfo.InvariantCulture), ":" + _config.Configuration.PublicHttpsPort.ToString(CultureInfo.InvariantCulture), StringComparison.OrdinalIgnoreCase);diff --git a/Emby.Server.Implementations/HttpServer/HttpResultFactory.cs b/Emby.Server.Implementations/HttpServer/HttpResultFactory.csindex 5e9d2b4c36..09cdbc3c26 100644--- a/Emby.Server.Implementations/HttpServer/HttpResultFactory.cs+++ b/Emby.Server.Implementations/HttpServer/HttpResultFactory.cs@@ -131,7 +131,7 @@ namespace Emby.Server.Implementations.HttpServercontent = Array.Empty<byte>();}- result = new StreamWriter(content, contentType, contentLength);+ result = new StreamWriter(content, contentType);}else{@@ -175,7 +175,7 @@ namespace Emby.Server.Implementations.HttpServerbytes = Array.Empty<byte>();}- result = new StreamWriter(bytes, contentType, contentLength);+ result = new StreamWriter(bytes, contentType);}else{@@ -334,13 +334,13 @@ namespace Emby.Server.Implementations.HttpServerif (isHeadRequest){- var result = new StreamWriter(Array.Empty<byte>(), contentType, contentLength);+ var result = new StreamWriter(Array.Empty<byte>(), contentType);AddResponseHeaders(result, responseHeaders);return result;}else{- var result = new StreamWriter(content, contentType, contentLength);+ var result = new StreamWriter(content, contentType);AddResponseHeaders(result, responseHeaders);return result;}@@ -590,11 +590,6 @@ namespace Emby.Server.Implementations.HttpServer}else{- if (totalContentLength.HasValue)- {- // TODO responseHeaders["Content-Length"] = totalContentLength.Value.ToString(UsCulture);- }-if (isHeadRequest){using (stream)diff --git a/Emby.Server.Implementations/HttpServer/RangeRequestWriter.cs b/Emby.Server.Implementations/HttpServer/RangeRequestWriter.csindex 9c8ab8d91c..8904e11d30 100644--- a/Emby.Server.Implementations/HttpServer/RangeRequestWriter.cs+++ b/Emby.Server.Implementations/HttpServer/RangeRequestWriter.cs@@ -96,8 +96,7 @@ namespace Emby.Server.Implementations.HttpServerRangeLength = 1 + RangeEnd - RangeStart;// Content-Length is the length of what we're serving, not the original content- // TODO Headers["Content-Length"] = RangeLength.ToString(UsCulture);- Headers["Content-Range"] = string.Format("bytes {0}-{1}/{2}", RangeStart, RangeEnd, TotalContentLength);+ Headers["Content-Range"] = $"bytes {RangeStart}-{RangeEnd}/{TotalContentLength}";if (RangeStart > 0 && SourceStream.CanSeek){diff --git a/Emby.Server.Implementations/HttpServer/ResponseFilter.cs b/Emby.Server.Implementations/HttpServer/ResponseFilter.csindex dbce3250d4..ae6a6576e0 100644--- a/Emby.Server.Implementations/HttpServer/ResponseFilter.cs+++ b/Emby.Server.Implementations/HttpServer/ResponseFilter.cs@@ -57,7 +57,6 @@ namespace Emby.Server.Implementations.HttpServerif (length > 0){- res.SetContentLength(length);res.SendChunked = false;}}diff --git a/Emby.Server.Implementations/HttpServer/StreamWriter.cs b/Emby.Server.Implementations/HttpServer/StreamWriter.csindex 750b0f7958..90354385dc 100644--- a/Emby.Server.Implementations/HttpServer/StreamWriter.cs+++ b/Emby.Server.Implementations/HttpServer/StreamWriter.cs@@ -53,11 +53,6 @@ namespace Emby.Server.Implementations.HttpServerSourceStream = source;Headers["Content-Type"] = contentType;-- if (source.CanSeek)- {- // TODO Headers["Content-Length"] = source.Length.ToString(UsCulture);- }}/// <summary>@@ -65,8 +60,7 @@ namespace Emby.Server.Implementations.HttpServer/// </summary>/// <param name="source">The source.</param>/// <param name="contentType">Type of the content.</param>- /// <param name="logger">The logger.</param>- public StreamWriter(byte[] source, string contentType, int contentLength)+ public StreamWriter(byte[] source, string contentType){if (string.IsNullOrEmpty(contentType)){@@ -76,8 +70,6 @@ namespace Emby.Server.Implementations.HttpServerSourceBytes = source;Headers["Content-Type"] = contentType;-- // TODO Headers["Content-Length"] = contentLength.ToString(UsCulture);}public async Task WriteToAsync(Stream responseStream, CancellationToken cancellationToken)diff --git a/Emby.Server.Implementations/Services/HttpResult.cs b/Emby.Server.Implementations/Services/HttpResult.csindex 296da2f7a0..b6758486ce 100644--- a/Emby.Server.Implementations/Services/HttpResult.cs+++ b/Emby.Server.Implementations/Services/HttpResult.cs@@ -43,14 +43,9 @@ namespace Emby.Server.Implementations.Services{var contentLength = bytesResponse.Length;- if (response != null)- {- response.SetContentLength(contentLength);- }-if (contentLength > 0){- await responseStream.WriteAsync(bytesResponse, 0, contentLength).ConfigureAwait(false);+ await responseStream.WriteAsync(bytesResponse, 0, contentLength, cancellationToken).ConfigureAwait(false);}return;}diff --git a/Emby.Server.Implementations/Services/ResponseHelper.cs b/Emby.Server.Implementations/Services/ResponseHelper.csindex dc99753477..0301ff335f 100644--- a/Emby.Server.Implementations/Services/ResponseHelper.cs+++ b/Emby.Server.Implementations/Services/ResponseHelper.cs@@ -20,8 +20,6 @@ namespace Emby.Server.Implementations.Services{response.StatusCode = (int)HttpStatusCode.NoContent;}-- response.SetContentLength(0);return Task.CompletedTask;}@@ -55,7 +53,6 @@ namespace Emby.Server.Implementations.Services{if (string.Equals(responseHeaders.Key, "Content-Length", StringComparison.OrdinalIgnoreCase)){- response.SetContentLength(long.Parse(responseHeaders.Value));continue;}@@ -104,7 +101,6 @@ namespace Emby.Server.Implementations.Servicesif (bytes != null){response.ContentType = "application/octet-stream";- response.SetContentLength(bytes.Length);if (bytes.Length > 0){@@ -117,7 +113,6 @@ namespace Emby.Server.Implementations.Servicesif (responseText != null){bytes = Encoding.UTF8.GetBytes(responseText);- response.SetContentLength(bytes.Length);if (bytes.Length > 0){return response.OutputStream.WriteAsync(bytes, 0, bytes.Length, cancellationToken);@@ -149,8 +144,6 @@ namespace Emby.Server.Implementations.Servicesvar contentLength = ms.Length;- response.SetContentLength(contentLength);-if (contentLength > 0){await ms.CopyToAsync(response.OutputStream).ConfigureAwait(false);diff --git a/Emby.Server.Implementations/SocketSharp/WebSocketSharpResponse.cs b/Emby.Server.Implementations/SocketSharp/WebSocketSharpResponse.csindex c68b959846..f9ecb52a55 100644--- a/Emby.Server.Implementations/SocketSharp/WebSocketSharpResponse.cs+++ b/Emby.Server.Implementations/SocketSharp/WebSocketSharpResponse.cs@@ -143,14 +143,6 @@ namespace Emby.Server.Implementations.SocketSharpprivate set;}- public void SetContentLength(long contentLength)- {- // you can happily set the Content-Length header in Asp.Net- // but HttpListener will complain if you do - you have to set ContentLength64 on the response.- // workaround: HttpListener throws "The parameter is incorrect" exceptions when we try to set the Content-Length header- //_response.ContentLength64 = contentLength;- }-public void SetCookie(Cookie cookie){var cookieStr = AsHeaderValue(cookie);diff --git a/MediaBrowser.Model/Services/IRequest.cs b/MediaBrowser.Model/Services/IRequest.csindex 909cebce3d..b4ad24fec8 100644--- a/MediaBrowser.Model/Services/IRequest.cs+++ b/MediaBrowser.Model/Services/IRequest.cs@@ -145,8 +145,6 @@ namespace MediaBrowser.Model.Services/// </summary>bool IsClosed { get; }- void SetContentLength(long contentLength);-//Add Metadata to ResponseDictionary<string, object> Items { get; }