diff options
| author | Claus Vium <cvium@users.noreply.github.com> | 2019-04-24 14:06:54 +0200 |
|---|---|---|
| committer | Bond-009 <bond.009@outlook.com> | 2019-04-24 14:06:54 +0200 |
| commit | 28c2ac528d46ba97b920d37300fa814bd6f4a51a (patch) | |
| tree | a662a20d41fd5e2ef952c89cfee8a2e8368fe256 /Emby.Server.Implementations/HttpServer/StreamWriter.cs | |
| parent | 696a36b4a5ada69f00875afa5e1ff1c596c7a371 (diff) | |
Re-add content length, semi revert of changes in #1010 (#1287)
* Re-add content length, semi revert of changes in #1010
Diffstat (limited to 'Emby.Server.Implementations/HttpServer/StreamWriter.cs')
| -rw-r--r-- | Emby.Server.Implementations/HttpServer/StreamWriter.cs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/Emby.Server.Implementations/HttpServer/StreamWriter.cs b/Emby.Server.Implementations/HttpServer/StreamWriter.cs index 324f9085e..194d04441 100644 --- a/Emby.Server.Implementations/HttpServer/StreamWriter.cs +++ b/Emby.Server.Implementations/HttpServer/StreamWriter.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.IO; using System.Threading; using System.Threading.Tasks; @@ -49,6 +50,13 @@ namespace Emby.Server.Implementations.HttpServer SourceStream = source; + Headers["Content-Type"] = contentType; + + if (source.CanSeek) + { + Headers[HeaderNames.ContentLength] = source.Length.ToString(CultureInfo.InvariantCulture); + } + Headers[HeaderNames.ContentType] = contentType; } @@ -57,7 +65,7 @@ namespace Emby.Server.Implementations.HttpServer /// </summary> /// <param name="source">The source.</param> /// <param name="contentType">Type of the content.</param> - public StreamWriter(byte[] source, string contentType) + public StreamWriter(byte[] source, string contentType, int contentLength) { if (string.IsNullOrEmpty(contentType)) { @@ -66,6 +74,7 @@ namespace Emby.Server.Implementations.HttpServer SourceBytes = source; + Headers[HeaderNames.ContentLength] = contentLength.ToString(CultureInfo.InvariantCulture); Headers[HeaderNames.ContentType] = contentType; } |
