aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/HttpServer/StreamWriter.cs
diff options
context:
space:
mode:
authorBond-009 <bond.009@outlook.com>2019-06-01 17:06:01 +0200
committerGitHub <noreply@github.com>2019-06-01 17:06:01 +0200
commitce1fa42f9d39add8467bfed186730c4a9545344d (patch)
tree8c2aafa3a3552174d15208551da1c34449a13b18 /Emby.Server.Implementations/HttpServer/StreamWriter.cs
parent2696ac5eacfb4702d629bc06a8b42b868c316116 (diff)
parentb1f764984f7098ee1164efee77f1bcb3de9fd08a (diff)
Merge branch 'master' into tasks
Diffstat (limited to 'Emby.Server.Implementations/HttpServer/StreamWriter.cs')
-rw-r--r--Emby.Server.Implementations/HttpServer/StreamWriter.cs12
1 files changed, 9 insertions, 3 deletions
diff --git a/Emby.Server.Implementations/HttpServer/StreamWriter.cs b/Emby.Server.Implementations/HttpServer/StreamWriter.cs
index cf30bbc32..194d04441 100644
--- a/Emby.Server.Implementations/HttpServer/StreamWriter.cs
+++ b/Emby.Server.Implementations/HttpServer/StreamWriter.cs
@@ -14,8 +14,6 @@ namespace Emby.Server.Implementations.HttpServer
/// </summary>
public class StreamWriter : IAsyncStreamWriter, IHasHeaders
{
- private static readonly CultureInfo UsCulture = new CultureInfo("en-US");
-
/// <summary>
/// Gets or sets the source stream.
/// </summary>
@@ -52,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;
}
@@ -60,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))
{
@@ -69,6 +74,7 @@ namespace Emby.Server.Implementations.HttpServer
SourceBytes = source;
+ Headers[HeaderNames.ContentLength] = contentLength.ToString(CultureInfo.InvariantCulture);
Headers[HeaderNames.ContentType] = contentType;
}