aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations
diff options
context:
space:
mode:
Diffstat (limited to 'Emby.Server.Implementations')
-rw-r--r--Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs14
-rw-r--r--Emby.Server.Implementations/ApplicationHost.cs113
-rw-r--r--Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs13
-rw-r--r--Emby.Server.Implementations/Data/SqliteUserRepository.cs2
-rw-r--r--Emby.Server.Implementations/HttpServer/FileWriter.cs6
-rw-r--r--Emby.Server.Implementations/HttpServer/HttpListenerHost.cs52
-rw-r--r--Emby.Server.Implementations/HttpServer/HttpResultFactory.cs15
-rw-r--r--Emby.Server.Implementations/HttpServer/RangeRequestWriter.cs1
-rw-r--r--Emby.Server.Implementations/HttpServer/ResponseFilter.cs3
-rw-r--r--Emby.Server.Implementations/HttpServer/StreamWriter.cs11
-rw-r--r--Emby.Server.Implementations/Library/UserManager.cs46
-rw-r--r--Emby.Server.Implementations/Localization/Core/cs.json24
-rw-r--r--Emby.Server.Implementations/Localization/Core/da.json4
-rw-r--r--Emby.Server.Implementations/Localization/Core/el.json8
-rw-r--r--Emby.Server.Implementations/Localization/Core/gsw.json166
-rw-r--r--Emby.Server.Implementations/Localization/Core/kk.json8
-rw-r--r--Emby.Server.Implementations/Localization/Core/sl-SI.json66
-rw-r--r--Emby.Server.Implementations/Localization/Core/zh-TW.json93
-rw-r--r--Emby.Server.Implementations/Services/HttpResult.cs5
-rw-r--r--Emby.Server.Implementations/Services/ResponseHelper.cs81
-rw-r--r--Emby.Server.Implementations/Services/ServiceController.cs54
-rw-r--r--Emby.Server.Implementations/Services/ServiceHandler.cs106
-rw-r--r--Emby.Server.Implementations/Services/StringMapTypeDeserializer.cs2
-rw-r--r--Emby.Server.Implementations/Services/SwaggerService.cs20
-rw-r--r--Emby.Server.Implementations/Udp/UdpServer.cs2
-rw-r--r--Emby.Server.Implementations/Updates/InstallationManager.cs38
26 files changed, 518 insertions, 435 deletions
diff --git a/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs b/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs
index 98cd97c31..190e4d55c 100644
--- a/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs
+++ b/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs
@@ -83,8 +83,6 @@ namespace Emby.Server.Implementations.Activity
_deviceManager.CameraImageUploaded += OnCameraImageUploaded;
- _appHost.ApplicationUpdated += OnApplicationUpdated;
-
return Task.CompletedTask;
}
@@ -275,16 +273,6 @@ namespace Emby.Server.Implementations.Activity
});
}
- private void OnApplicationUpdated(object sender, GenericEventArgs<PackageVersionInfo> e)
- {
- CreateLogEntry(new ActivityLogEntry
- {
- Name = string.Format(_localization.GetLocalizedString("MessageApplicationUpdatedTo"), e.Argument.versionStr),
- Type = NotificationType.ApplicationUpdateInstalled.ToString(),
- Overview = e.Argument.description
- });
- }
-
private void OnUserPolicyUpdated(object sender, GenericEventArgs<User> e)
{
CreateLogEntry(new ActivityLogEntry
@@ -460,8 +448,6 @@ namespace Emby.Server.Implementations.Activity
_userManager.UserLockedOut -= OnUserLockedOut;
_deviceManager.CameraImageUploaded -= OnCameraImageUploaded;
-
- _appHost.ApplicationUpdated -= OnApplicationUpdated;
}
/// <summary>
diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs
index 41ca2a102..53bc85b28 100644
--- a/Emby.Server.Implementations/ApplicationHost.cs
+++ b/Emby.Server.Implementations/ApplicationHost.cs
@@ -155,11 +155,6 @@ namespace Emby.Server.Implementations
public event EventHandler HasPendingRestartChanged;
/// <summary>
- /// Occurs when [application updated].
- /// </summary>
- public event EventHandler<GenericEventArgs<PackageVersionInfo>> ApplicationUpdated;
-
- /// <summary>
/// Gets a value indicating whether this instance has changes that require the entire application to restart.
/// </summary>
/// <value><c>true</c> if this instance has pending application restart; otherwise, <c>false</c>.</value>
@@ -620,8 +615,6 @@ namespace Emby.Server.Implementations
DiscoverTypes();
- SetHttpLimit();
-
await RegisterResources(serviceCollection).ConfigureAwait(false);
FindParts();
@@ -918,8 +911,7 @@ namespace Emby.Server.Implementations
.Distinct();
logger.LogInformation("Arguments: {Args}", commandLineArgs);
- // FIXME: @bond this logs the kernel version, not the OS version
- logger.LogInformation("Operating system: {OS} {OSVersion}", OperatingSystem.Name, Environment.OSVersion.Version);
+ logger.LogInformation("Operating system: {OS}", OperatingSystem.Name);
logger.LogInformation("Architecture: {Architecture}", RuntimeInformation.OSArchitecture);
logger.LogInformation("64-Bit Process: {Is64Bit}", Environment.Is64BitProcess);
logger.LogInformation("User Interactive: {IsUserInteractive}", Environment.UserInteractive);
@@ -929,19 +921,6 @@ namespace Emby.Server.Implementations
logger.LogInformation("Application directory: {ApplicationPath}", appPaths.ProgramSystemPath);
}
- private void SetHttpLimit()
- {
- try
- {
- // Increase the max http request limit
- ServicePointManager.DefaultConnectionLimit = Math.Max(96, ServicePointManager.DefaultConnectionLimit);
- }
- catch (Exception ex)
- {
- Logger.LogError(ex, "Error setting http limit");
- }
- }
-
private X509Certificate2 GetCertificate(CertificateInfo info)
{
var certificateLocation = info?.Path;
@@ -1046,8 +1025,8 @@ namespace Emby.Server.Implementations
private async void PluginInstalled(object sender, GenericEventArgs<PackageVersionInfo> args)
{
- string dir = Path.Combine(ApplicationPaths.PluginsPath, Path.GetFileNameWithoutExtension(args.Argument.targetFilename));
- var types = Directory.EnumerateFiles(dir, "*.dll", SearchOption.TopDirectoryOnly)
+ string dir = Path.Combine(ApplicationPaths.PluginsPath, args.Argument.name);
+ var types = Directory.EnumerateFiles(dir, "*.dll", SearchOption.AllDirectories)
.Select(x => Assembly.LoadFrom(x))
.SelectMany(x => x.ExportedTypes)
.Where(x => x.IsClass && !x.IsAbstract && !x.IsInterface && !x.IsGenericType)
@@ -1167,7 +1146,7 @@ namespace Emby.Server.Implementations
}
catch (Exception ex)
{
- Logger.LogError(ex, "Error loading plugin {pluginName}", plugin.GetType().FullName);
+ Logger.LogError(ex, "Error loading plugin {PluginName}", plugin.GetType().FullName);
return null;
}
@@ -1181,10 +1160,32 @@ namespace Emby.Server.Implementations
{
Logger.LogInformation("Loading assemblies");
- AllConcreteTypes = GetComposablePartAssemblies()
- .SelectMany(x => x.ExportedTypes)
- .Where(type => type.IsClass && !type.IsAbstract && !type.IsInterface && !type.IsGenericType)
- .ToArray();
+ AllConcreteTypes = GetTypes(GetComposablePartAssemblies()).ToArray();
+ }
+
+ private IEnumerable<Type> GetTypes(IEnumerable<Assembly> assemblies)
+ {
+ foreach (var ass in assemblies)
+ {
+ Type[] exportedTypes;
+ try
+ {
+ exportedTypes = ass.GetExportedTypes();
+ }
+ catch (TypeLoadException ex)
+ {
+ Logger.LogError(ex, "Error getting exported types from {Assembly}", ass.FullName);
+ continue;
+ }
+
+ foreach (Type type in exportedTypes)
+ {
+ if (type.IsClass && !type.IsAbstract && !type.IsInterface && !type.IsGenericType)
+ {
+ yield return type;
+ }
+ }
+ }
}
private CertificateInfo CertificateInfo { get; set; }
@@ -1346,10 +1347,21 @@ namespace Emby.Server.Implementations
{
if (Directory.Exists(ApplicationPaths.PluginsPath))
{
- foreach (var file in Directory.EnumerateFiles(ApplicationPaths.PluginsPath, "*.dll", SearchOption.TopDirectoryOnly))
+ foreach (var file in Directory.EnumerateFiles(ApplicationPaths.PluginsPath, "*.dll", SearchOption.AllDirectories))
{
- Logger.LogInformation("Loading assembly {Path}", file);
- yield return Assembly.LoadFrom(file);
+ Assembly plugAss;
+ try
+ {
+ plugAss = Assembly.LoadFrom(file);
+ }
+ catch (FileLoadException ex)
+ {
+ Logger.LogError(ex, "Failed to load assembly {Path}", file);
+ continue;
+ }
+
+ Logger.LogInformation("Loaded assembly {Assembly} from {Path}", plugAss.FullName, file);
+ yield return plugAss;
}
}
@@ -1408,9 +1420,9 @@ namespace Emby.Server.Implementations
public async Task<SystemInfo> GetSystemInfo(CancellationToken cancellationToken)
{
var localAddress = await GetLocalApiUrl(cancellationToken).ConfigureAwait(false);
-
- string wanAddress;
-
+
+ string wanAddress;
+
if (string.IsNullOrEmpty(ServerConfigurationManager.Configuration.WanDdns))
{
wanAddress = await GetWanApiUrlFromExternal(cancellationToken).ConfigureAwait(false);
@@ -1425,7 +1437,6 @@ namespace Emby.Server.Implementations
HasPendingRestart = HasPendingRestart,
IsShuttingDown = IsShuttingDown,
Version = ApplicationVersion,
- ProductName = ApplicationProductName,
WebSocketPortNumber = HttpPort,
CompletedInstallations = InstallationManager.CompletedInstallations.ToArray(),
Id = SystemId,
@@ -1467,10 +1478,10 @@ namespace Emby.Server.Implementations
public async Task<PublicSystemInfo> GetPublicSystemInfo(CancellationToken cancellationToken)
{
- var localAddress = await GetLocalApiUrl(cancellationToken).ConfigureAwait(false);
-
+ var localAddress = await GetLocalApiUrl(cancellationToken).ConfigureAwait(false);
+
string wanAddress;
-
+
if (string.IsNullOrEmpty(ServerConfigurationManager.Configuration.WanDdns))
{
wanAddress = await GetWanApiUrlFromExternal(cancellationToken).ConfigureAwait(false);
@@ -1482,6 +1493,7 @@ namespace Emby.Server.Implementations
return new PublicSystemInfo
{
Version = ApplicationVersion,
+ ProductName = ApplicationProductName,
Id = SystemId,
OperatingSystem = OperatingSystem.Id.ToString(),
WanAddress = wanAddress,
@@ -1539,6 +1551,7 @@ namespace Emby.Server.Implementations
{
Logger.LogError(ex, "Error getting WAN Ip address information");
}
+
return null;
}
@@ -1585,9 +1598,9 @@ namespace Emby.Server.Implementations
}
return string.Format("http://{0}:{1}",
host,
- ServerConfigurationManager.Configuration.PublicPort.ToString(CultureInfo.InvariantCulture));
+ ServerConfigurationManager.Configuration.PublicPort.ToString(CultureInfo.InvariantCulture));
}
-
+
public Task<List<IpAddressInfo>> GetLocalIpAddresses(CancellationToken cancellationToken)
{
return GetLocalIpAddressesInternal(true, 0, cancellationToken);
@@ -1841,24 +1854,6 @@ namespace Emby.Server.Implementations
{
}
- /// <summary>
- /// Called when [application updated].
- /// </summary>
- /// <param name="package">The package.</param>
- protected void OnApplicationUpdated(PackageVersionInfo package)
- {
- Logger.LogInformation("Application has been updated to version {0}", package.versionStr);
-
- ApplicationUpdated?.Invoke(
- this,
- new GenericEventArgs<PackageVersionInfo>()
- {
- Argument = package
- });
-
- NotifyPendingRestart();
- }
-
private bool _disposed = false;
/// <summary>
diff --git a/Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs b/Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs
index 18e279c2f..c4fa68cac 100644
--- a/Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs
+++ b/Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs
@@ -74,23 +74,14 @@ namespace Emby.Server.Implementations.Configuration
/// </summary>
private void UpdateMetadataPath()
{
- string metadataPath;
-
if (string.IsNullOrWhiteSpace(Configuration.MetadataPath))
{
- metadataPath = GetInternalMetadataPath();
+ ((ServerApplicationPaths)ApplicationPaths).InternalMetadataPath = Path.Combine(ApplicationPaths.ProgramDataPath, "metadata");
}
else
{
- metadataPath = Path.Combine(Configuration.MetadataPath, "metadata");
+ ((ServerApplicationPaths)ApplicationPaths).InternalMetadataPath = Configuration.MetadataPath;
}
-
- ((ServerApplicationPaths)ApplicationPaths).InternalMetadataPath = metadataPath;
- }
-
- private string GetInternalMetadataPath()
- {
- return Path.Combine(ApplicationPaths.ProgramDataPath, "metadata");
}
/// <summary>
diff --git a/Emby.Server.Implementations/Data/SqliteUserRepository.cs b/Emby.Server.Implementations/Data/SqliteUserRepository.cs
index 182df0edc..5957b2903 100644
--- a/Emby.Server.Implementations/Data/SqliteUserRepository.cs
+++ b/Emby.Server.Implementations/Data/SqliteUserRepository.cs
@@ -81,7 +81,7 @@ namespace Emby.Server.Implementations.Data
{
// If the user password is the sha1 hash of the empty string, remove it
if (!string.Equals(user.Password, "DA39A3EE5E6B4B0D3255BFEF95601890AFD80709", StringComparison.Ordinal)
- || !string.Equals(user.Password, "$SHA1$DA39A3EE5E6B4B0D3255BFEF95601890AFD80709", StringComparison.Ordinal))
+ && !string.Equals(user.Password, "$SHA1$DA39A3EE5E6B4B0D3255BFEF95601890AFD80709", StringComparison.Ordinal))
{
continue;
}
diff --git a/Emby.Server.Implementations/HttpServer/FileWriter.cs b/Emby.Server.Implementations/HttpServer/FileWriter.cs
index c4d2a70e2..c6b7d31a8 100644
--- a/Emby.Server.Implementations/HttpServer/FileWriter.cs
+++ b/Emby.Server.Implementations/HttpServer/FileWriter.cs
@@ -67,6 +67,7 @@ namespace Emby.Server.Implementations.HttpServer
if (string.IsNullOrWhiteSpace(rangeHeader))
{
+ Headers[HeaderNames.ContentLength] = TotalContentLength.ToString(CultureInfo.InvariantCulture);
StatusCode = HttpStatusCode.OK;
}
else
@@ -99,10 +100,13 @@ namespace Emby.Server.Implementations.HttpServer
RangeStart = requestedRange.Key;
RangeLength = 1 + RangeEnd - RangeStart;
+ // Content-Length is the length of what we're serving, not the original content
+ var lengthString = RangeLength.ToString(CultureInfo.InvariantCulture);
+ Headers[HeaderNames.ContentLength] = lengthString;
var rangeString = $"bytes {RangeStart}-{RangeEnd}/{TotalContentLength}";
Headers[HeaderNames.ContentRange] = rangeString;
- Logger.LogInformation("Setting range response values for {0}. RangeRequest: {1} Content-Range: {2}", Path, RangeHeader, rangeString);
+ Logger.LogInformation("Setting range response values for {0}. RangeRequest: {1} Content-Length: {2}, Content-Range: {3}", Path, RangeHeader, lengthString, rangeString);
}
/// <summary>
diff --git a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs
index e8d47cad5..b3d2b9cc2 100644
--- a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs
+++ b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
-using System.Globalization;
using System.IO;
using System.Linq;
using System.Net.Sockets;
@@ -11,7 +10,6 @@ using System.Threading;
using System.Threading.Tasks;
using Emby.Server.Implementations.Net;
using Emby.Server.Implementations.Services;
-using Emby.Server.Implementations.SocketSharp;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller;
@@ -127,12 +125,12 @@ namespace Emby.Server.Implementations.HttpServer
private List<IHasRequestFilter> GetRequestFilterAttributes(Type requestDtoType)
{
- var attributes = requestDtoType.GetTypeInfo().GetCustomAttributes(true).OfType<IHasRequestFilter>().ToList();
+ var attributes = requestDtoType.GetCustomAttributes(true).OfType<IHasRequestFilter>().ToList();
var serviceType = GetServiceTypeByRequest(requestDtoType);
if (serviceType != null)
{
- attributes.AddRange(serviceType.GetTypeInfo().GetCustomAttributes(true).OfType<IHasRequestFilter>());
+ attributes.AddRange(serviceType.GetCustomAttributes(true).OfType<IHasRequestFilter>());
}
attributes.Sort((x, y) => x.Priority - y.Priority);
@@ -154,7 +152,7 @@ namespace Emby.Server.Implementations.HttpServer
QueryString = e.QueryString ?? new QueryCollection()
};
- connection.Closed += Connection_Closed;
+ connection.Closed += OnConnectionClosed;
lock (_webSocketConnections)
{
@@ -164,7 +162,7 @@ namespace Emby.Server.Implementations.HttpServer
WebSocketConnected?.Invoke(this, new GenericEventArgs<IWebSocketConnection>(connection));
}
- private void Connection_Closed(object sender, EventArgs e)
+ private void OnConnectionClosed(object sender, EventArgs e)
{
lock (_webSocketConnections)
{
@@ -203,6 +201,7 @@ namespace Emby.Server.Implementations.HttpServer
case DirectoryNotFoundException _:
case FileNotFoundException _:
case ResourceNotFoundException _: return 404;
+ case MethodNotAllowedException _: return 405;
case RemoteServiceUnavailableException _: return 502;
default: return 500;
}
@@ -322,14 +321,14 @@ namespace Emby.Server.Implementations.HttpServer
private static string NormalizeConfiguredLocalAddress(string address)
{
- var index = address.Trim('/').IndexOf('/');
-
+ var add = address.AsSpan().Trim('/');
+ int index = add.IndexOf('/');
if (index != -1)
{
- address = address.Substring(index + 1);
+ add = add.Slice(index + 1);
}
- return address.Trim('/');
+ return add.TrimStart('/').ToString();
}
private bool ValidateHost(string host)
@@ -399,8 +398,8 @@ namespace Emby.Server.Implementations.HttpServer
if (urlString.IndexOf("https://", StringComparison.OrdinalIgnoreCase) == -1)
{
// These are hacks, but if these ever occur on ipv6 in the local network they could be incorrectly redirected
- if (urlString.IndexOf("system/ping", StringComparison.OrdinalIgnoreCase) != -1 ||
- urlString.IndexOf("dlna/", StringComparison.OrdinalIgnoreCase) != -1)
+ if (urlString.IndexOf("system/ping", StringComparison.OrdinalIgnoreCase) != -1
+ || urlString.IndexOf("dlna/", StringComparison.OrdinalIgnoreCase) != -1)
{
return true;
}
@@ -572,7 +571,7 @@ namespace Emby.Server.Implementations.HttpServer
if (handler != null)
{
- await handler.ProcessRequestAsync(this, httpReq, httpRes, Logger, httpReq.OperationName, cancellationToken).ConfigureAwait(false);
+ await handler.ProcessRequestAsync(this, httpReq, httpRes, Logger, cancellationToken).ConfigureAwait(false);
}
else
{
@@ -613,21 +612,11 @@ namespace Emby.Server.Implementations.HttpServer
{
var pathInfo = httpReq.PathInfo;
- var pathParts = pathInfo.TrimStart('/').Split('/');
- if (pathParts.Length == 0)
- {
- Logger.LogError("Path parts empty for PathInfo: {PathInfo}, Url: {RawUrl}", pathInfo, httpReq.RawUrl);
- return null;
- }
-
- var restPath = ServiceHandler.FindMatchingRestPath(httpReq.HttpMethod, pathInfo, out string contentType);
+ pathInfo = ServiceHandler.GetSanitizedPathInfo(pathInfo, out string contentType);
+ var restPath = ServiceController.GetRestPathForRequest(httpReq.HttpMethod, pathInfo);
if (restPath != null)
{
- return new ServiceHandler
- {
- RestPath = restPath,
- ResponseContentType = contentType
- };
+ return new ServiceHandler(restPath, contentType);
}
Logger.LogError("Could not find handler for {PathInfo}", pathInfo);
@@ -637,6 +626,7 @@ namespace Emby.Server.Implementations.HttpServer
private static Task Write(IResponse response, string text)
{
var bOutput = Encoding.UTF8.GetBytes(text);
+ response.OriginalResponse.ContentLength = bOutput.Length;
return response.OutputStream.WriteAsync(bOutput, 0, bOutput.Length);
}
@@ -655,11 +645,6 @@ 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);
-
RedirectToUrl(httpRes, url);
}
}
@@ -684,10 +669,7 @@ namespace Emby.Server.Implementations.HttpServer
UrlPrefixes = urlPrefixes.ToArray();
ServiceController = new ServiceController();
- Logger.LogInformation("Calling ServiceStack AppHost.Init");
-
- var types = services.Select(r => r.GetType()).ToArray();
-
+ var types = services.Select(r => r.GetType());
ServiceController.Init(this, types);
ResponseFilters = new Action<IRequest, IResponse, object>[]
diff --git a/Emby.Server.Implementations/HttpServer/HttpResultFactory.cs b/Emby.Server.Implementations/HttpServer/HttpResultFactory.cs
index 134f3c841..0b2924a3b 100644
--- a/Emby.Server.Implementations/HttpServer/HttpResultFactory.cs
+++ b/Emby.Server.Implementations/HttpServer/HttpResultFactory.cs
@@ -132,7 +132,7 @@ namespace Emby.Server.Implementations.HttpServer
content = Array.Empty<byte>();
}
- result = new StreamWriter(content, contentType);
+ result = new StreamWriter(content, contentType, contentLength);
}
else
{
@@ -176,7 +176,7 @@ namespace Emby.Server.Implementations.HttpServer
bytes = Array.Empty<byte>();
}
- result = new StreamWriter(bytes, contentType);
+ result = new StreamWriter(bytes, contentType, contentLength);
}
else
{
@@ -335,13 +335,13 @@ namespace Emby.Server.Implementations.HttpServer
if (isHeadRequest)
{
- var result = new StreamWriter(Array.Empty<byte>(), contentType);
+ var result = new StreamWriter(Array.Empty<byte>(), contentType, contentLength);
AddResponseHeaders(result, responseHeaders);
return result;
}
else
{
- var result = new StreamWriter(content, contentType);
+ var result = new StreamWriter(content, contentType, contentLength);
AddResponseHeaders(result, responseHeaders);
return result;
}
@@ -581,6 +581,11 @@ namespace Emby.Server.Implementations.HttpServer
}
else
{
+ if (totalContentLength.HasValue)
+ {
+ responseHeaders["Content-Length"] = totalContentLength.Value.ToString(CultureInfo.InvariantCulture);
+ }
+
if (isHeadRequest)
{
using (stream)
@@ -624,7 +629,7 @@ namespace Emby.Server.Implementations.HttpServer
if (lastModifiedDate.HasValue)
{
- responseHeaders[HeaderNames.LastModified] = lastModifiedDate.ToString();
+ responseHeaders[HeaderNames.LastModified] = lastModifiedDate.Value.ToString(CultureInfo.InvariantCulture);
}
}
diff --git a/Emby.Server.Implementations/HttpServer/RangeRequestWriter.cs b/Emby.Server.Implementations/HttpServer/RangeRequestWriter.cs
index 449159834..e27f794ba 100644
--- a/Emby.Server.Implementations/HttpServer/RangeRequestWriter.cs
+++ b/Emby.Server.Implementations/HttpServer/RangeRequestWriter.cs
@@ -96,6 +96,7 @@ namespace Emby.Server.Implementations.HttpServer
RangeStart = requestedRange.Key;
RangeLength = 1 + RangeEnd - RangeStart;
+ Headers[HeaderNames.ContentLength] = RangeLength.ToString(CultureInfo.InvariantCulture);
Headers[HeaderNames.ContentRange] = $"bytes {RangeStart}-{RangeEnd}/{TotalContentLength}";
if (RangeStart > 0 && SourceStream.CanSeek)
diff --git a/Emby.Server.Implementations/HttpServer/ResponseFilter.cs b/Emby.Server.Implementations/HttpServer/ResponseFilter.cs
index a53d9bf0b..08f424757 100644
--- a/Emby.Server.Implementations/HttpServer/ResponseFilter.cs
+++ b/Emby.Server.Implementations/HttpServer/ResponseFilter.cs
@@ -26,7 +26,7 @@ namespace Emby.Server.Implementations.HttpServer
public void FilterResponse(IRequest req, IResponse res, object dto)
{
// Try to prevent compatibility view
- res.AddHeader("Access-Control-Allow-Headers", "Accept, Accept-Language, Authorization, Cache-Control, Content-Disposition, Content-Encoding, Content-Language, Content-MD5, Content-Range, Content-Type, Date, Host, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since, Origin, OriginToken, Pragma, Range, Slug, Transfer-Encoding, Want-Digest, X-MediaBrowser-Token, X-Emby-Authorization");
+ res.AddHeader("Access-Control-Allow-Headers", "Accept, Accept-Language, Authorization, Cache-Control, Content-Disposition, Content-Encoding, Content-Language, Content-Length, Content-MD5, Content-Range, Content-Type, Date, Host, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since, Origin, OriginToken, Pragma, Range, Slug, Transfer-Encoding, Want-Digest, X-MediaBrowser-Token, X-Emby-Authorization");
res.AddHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, PATCH, OPTIONS");
res.AddHeader("Access-Control-Allow-Origin", "*");
@@ -58,6 +58,7 @@ namespace Emby.Server.Implementations.HttpServer
if (length > 0)
{
+ res.OriginalResponse.ContentLength = length;
res.SendChunked = false;
}
}
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;
}
diff --git a/Emby.Server.Implementations/Library/UserManager.cs b/Emby.Server.Implementations/Library/UserManager.cs
index 75c82ca71..c33bb7740 100644
--- a/Emby.Server.Implementations/Library/UserManager.cs
+++ b/Emby.Server.Implementations/Library/UserManager.cs
@@ -277,24 +277,35 @@ namespace Emby.Server.Implementations.Library
.FirstOrDefault(i => string.Equals(username, i.Name, StringComparison.OrdinalIgnoreCase));
var success = false;
+ string updatedUsername = null;
IAuthenticationProvider authenticationProvider = null;
if (user != null)
{
var authResult = await AuthenticateLocalUser(username, password, hashedPassword, user, remoteEndPoint).ConfigureAwait(false);
authenticationProvider = authResult.Item1;
- success = authResult.Item2;
+ updatedUsername = authResult.Item2;
+ success = authResult.Item3;
}
else
{
// user is null
var authResult = await AuthenticateLocalUser(username, password, hashedPassword, null, remoteEndPoint).ConfigureAwait(false);
authenticationProvider = authResult.Item1;
- success = authResult.Item2;
+ updatedUsername = authResult.Item2;
+ success = authResult.Item3;
if (success && authenticationProvider != null && !(authenticationProvider is DefaultAuthenticationProvider))
{
- user = await CreateUser(username).ConfigureAwait(false);
+ // We should trust the user that the authprovider says, not what was typed
+ if (updatedUsername != username)
+ {
+ username = updatedUsername;
+ }
+
+ // Search the database for the user again; the authprovider might have created it
+ user = Users
+ .FirstOrDefault(i => string.Equals(username, i.Name, StringComparison.OrdinalIgnoreCase));
var hasNewUserPolicy = authenticationProvider as IHasNewUserPolicy;
if (hasNewUserPolicy != null)
@@ -414,32 +425,40 @@ namespace Emby.Server.Implementations.Library
return providers;
}
- private async Task<bool> AuthenticateWithProvider(IAuthenticationProvider provider, string username, string password, User resolvedUser)
+ private async Task<Tuple<string, bool>> AuthenticateWithProvider(IAuthenticationProvider provider, string username, string password, User resolvedUser)
{
try
{
var requiresResolvedUser = provider as IRequiresResolvedUser;
+ ProviderAuthenticationResult authenticationResult = null;
if (requiresResolvedUser != null)
{
- await requiresResolvedUser.Authenticate(username, password, resolvedUser).ConfigureAwait(false);
+ authenticationResult = await requiresResolvedUser.Authenticate(username, password, resolvedUser).ConfigureAwait(false);
}
else
{
- await provider.Authenticate(username, password).ConfigureAwait(false);
+ authenticationResult = await provider.Authenticate(username, password).ConfigureAwait(false);
+ }
+
+ if(authenticationResult.Username != username)
+ {
+ _logger.LogDebug("Authentication provider provided updated username {1}", authenticationResult.Username);
+ username = authenticationResult.Username;
}
- return true;
+ return new Tuple<string, bool>(username, true);
}
catch (Exception ex)
{
_logger.LogError(ex, "Error authenticating with provider {provider}", provider.Name);
- return false;
+ return new Tuple<string, bool>(username, false);
}
}
- private async Task<Tuple<IAuthenticationProvider, bool>> AuthenticateLocalUser(string username, string password, string hashedPassword, User user, string remoteEndPoint)
+ private async Task<Tuple<IAuthenticationProvider, string, bool>> AuthenticateLocalUser(string username, string password, string hashedPassword, User user, string remoteEndPoint)
{
+ string updatedUsername = null;
bool success = false;
IAuthenticationProvider authenticationProvider = null;
@@ -458,11 +477,14 @@ namespace Emby.Server.Implementations.Library
{
foreach (var provider in GetAuthenticationProviders(user))
{
- success = await AuthenticateWithProvider(provider, username, password, user).ConfigureAwait(false);
+ var providerAuthResult = await AuthenticateWithProvider(provider, username, password, user).ConfigureAwait(false);
+ updatedUsername = providerAuthResult.Item1;
+ success = providerAuthResult.Item2;
if (success)
{
authenticationProvider = provider;
+ username = updatedUsername;
break;
}
}
@@ -484,7 +506,7 @@ namespace Emby.Server.Implementations.Library
}
}
- return new Tuple<IAuthenticationProvider, bool>(authenticationProvider, success);
+ return new Tuple<IAuthenticationProvider, string, bool>(authenticationProvider, username, success);
}
private void UpdateInvalidLoginAttemptCount(User user, int newValue)
@@ -574,7 +596,7 @@ namespace Emby.Server.Implementations.Library
}
bool hasConfiguredPassword = GetAuthenticationProvider(user).HasPassword(user).Result;
- bool hasConfiguredEasyPassword = string.IsNullOrEmpty(GetLocalPasswordHash(user));
+ bool hasConfiguredEasyPassword = !string.IsNullOrEmpty(GetLocalPasswordHash(user));
bool hasPassword = user.Configuration.EnableLocalPassword && !string.IsNullOrEmpty(remoteEndPoint) && _networkManager.IsInLocalNetwork(remoteEndPoint) ?
hasConfiguredEasyPassword :
diff --git a/Emby.Server.Implementations/Localization/Core/cs.json b/Emby.Server.Implementations/Localization/Core/cs.json
index a8b4a4424..c19148921 100644
--- a/Emby.Server.Implementations/Localization/Core/cs.json
+++ b/Emby.Server.Implementations/Localization/Core/cs.json
@@ -5,7 +5,7 @@
"Artists": "Umělci",
"AuthenticationSucceededWithUserName": "{0} úspěšně ověřen",
"Books": "Knihy",
- "CameraImageUploadedFrom": "A new camera image has been uploaded from {0}",
+ "CameraImageUploadedFrom": "Z {0} byla nahrána nová fotografie",
"Channels": "Kanály",
"ChapterNameValue": "Kapitola {0}",
"Collections": "Kolekce",
@@ -16,14 +16,14 @@
"Folders": "Složky",
"Genres": "Žánry",
"HeaderAlbumArtists": "Umělci alba",
- "HeaderCameraUploads": "Camera Uploads",
+ "HeaderCameraUploads": "Nahrané fotografie",
"HeaderContinueWatching": "Pokračovat ve sledování",
"HeaderFavoriteAlbums": "Oblíbená alba",
- "HeaderFavoriteArtists": "Oblíbení umělci",
+ "HeaderFavoriteArtists": "Oblíbení interpreti",
"HeaderFavoriteEpisodes": "Oblíbené epizody",
"HeaderFavoriteShows": "Oblíbené seriály",
- "HeaderFavoriteSongs": "Oblíbené písně",
- "HeaderLiveTV": "Živá TV",
+ "HeaderFavoriteSongs": "Oblíbená hudba",
+ "HeaderLiveTV": "Live TV",
"HeaderNextUp": "Nadcházející",
"HeaderRecordingGroups": "Skupiny nahrávek",
"HomeVideos": "Domáci videa",
@@ -34,17 +34,17 @@
"LabelRunningTimeValue": "Délka média: {0}",
"Latest": "Nejnovější",
"MessageApplicationUpdated": "Jellyfin Server byl aktualizován",
- "MessageApplicationUpdatedTo": "Jellyfin Server has been updated to {0}",
+ "MessageApplicationUpdatedTo": "Jellyfin server byl aktualizován na verzi {0}",
"MessageNamedServerConfigurationUpdatedWithValue": "Konfigurace sekce {0} na serveru byla aktualizována",
"MessageServerConfigurationUpdated": "Konfigurace serveru aktualizována",
"MixedContent": "Smíšený obsah",
"Movies": "Filmy",
"Music": "Hudba",
"MusicVideos": "Hudební klipy",
- "NameInstallFailed": "{0} installation failed",
+ "NameInstallFailed": "Instalace {0} selhala",
"NameSeasonNumber": "Sezóna {0}",
"NameSeasonUnknown": "Neznámá sezóna",
- "NewVersionIsAvailable": "A new version of Jellyfin Server is available for download.",
+ "NewVersionIsAvailable": "Nová verze Jellyfin serveru je k dispozici ke stažení.",
"NotificationOptionApplicationUpdateAvailable": "Dostupná aktualizace aplikace",
"NotificationOptionApplicationUpdateInstalled": "Aktualizace aplikace instalována",
"NotificationOptionAudioPlayback": "Přehrávání audia zahájeno",
@@ -70,12 +70,12 @@
"ProviderValue": "Poskytl: {0}",
"ScheduledTaskFailedWithName": "{0} selhalo",
"ScheduledTaskStartedWithName": "{0} zahájeno",
- "ServerNameNeedsToBeRestarted": "{0} needs to be restarted",
+ "ServerNameNeedsToBeRestarted": "{0} vyžaduje restart",
"Shows": "Seriály",
"Songs": "Skladby",
"StartupEmbyServerIsLoading": "Jellyfin Server je spouštěn. Zkuste to prosím v brzké době znovu.",
"SubtitleDownloadFailureForItem": "Stahování titulků selhalo pro {0}",
- "SubtitleDownloadFailureFromForItem": "Subtitles failed to download from {0} for {1}",
+ "SubtitleDownloadFailureFromForItem": "Stažení titulků pro {1} z {0} selhalo",
"SubtitlesDownloadedForItem": "Staženy titulky pro {0}",
"Sync": "Synchronizace",
"System": "Systém",
@@ -88,10 +88,10 @@
"UserOfflineFromDevice": "{0} se odpojil od {1}",
"UserOnlineFromDevice": "{0} se připojil z {1}",
"UserPasswordChangedWithName": "Provedena změna hesla pro uživatele {0}",
- "UserPolicyUpdatedWithName": "User policy has been updated for {0}",
+ "UserPolicyUpdatedWithName": "Zásady uživatele pro {0} byly aktualizovány",
"UserStartedPlayingItemWithValues": "{0} spustil přehrávání {1}",
"UserStoppedPlayingItemWithValues": "{0} zastavil přehrávání {1}",
- "ValueHasBeenAddedToLibrary": "{0} has been added to your media library",
+ "ValueHasBeenAddedToLibrary": "{0} byl přidán do vaší knihovny médií",
"ValueSpecialEpisodeName": "Speciál - {0}",
"VersionNumber": "Verze {0}"
}
diff --git a/Emby.Server.Implementations/Localization/Core/da.json b/Emby.Server.Implementations/Localization/Core/da.json
index 9d4d74099..cb8f4576a 100644
--- a/Emby.Server.Implementations/Localization/Core/da.json
+++ b/Emby.Server.Implementations/Localization/Core/da.json
@@ -61,8 +61,8 @@
"NotificationOptionUserLockedOut": "Bruger låst ude",
"NotificationOptionVideoPlayback": "Videoafspilning påbegyndt",
"NotificationOptionVideoPlaybackStopped": "Videoafspilning stoppet",
- "Photos": "Fotos",
- "Playlists": "Spillelister",
+ "Photos": "Fotoer",
+ "Playlists": "Afspilningslister",
"Plugin": "Plugin",
"PluginInstalledWithName": "{0} blev installeret",
"PluginUninstalledWithName": "{0} blev afinstalleret",
diff --git a/Emby.Server.Implementations/Localization/Core/el.json b/Emby.Server.Implementations/Localization/Core/el.json
index 91ca34edc..db7ebb0c0 100644
--- a/Emby.Server.Implementations/Localization/Core/el.json
+++ b/Emby.Server.Implementations/Localization/Core/el.json
@@ -16,7 +16,7 @@
"Folders": "Φάκελοι",
"Genres": "Είδη",
"HeaderAlbumArtists": "Άλμπουμ Καλλιτεχνών",
- "HeaderCameraUploads": "Camera Uploads",
+ "HeaderCameraUploads": "Μεταφορτώσεις Κάμερας",
"HeaderContinueWatching": "Συνεχίστε να παρακολουθείτε",
"HeaderFavoriteAlbums": "Αγαπημένα Άλμπουμ",
"HeaderFavoriteArtists": "Αγαπημένοι Καλλιτέχνες",
@@ -34,7 +34,7 @@
"LabelRunningTimeValue": "Διάρκεια: {0}",
"Latest": "Πρόσφατα",
"MessageApplicationUpdated": "Ο Jellyfin Server έχει ενημερωθεί",
- "MessageApplicationUpdatedTo": "Jellyfin Server has been updated to {0}",
+ "MessageApplicationUpdatedTo": "Ο server Jellyfin αναβαθμίστηκε σε έκδοση {0}",
"MessageNamedServerConfigurationUpdatedWithValue": "Η ενότητα {0} ρύθμισης παραμέτρων του server έχει ενημερωθεί",
"MessageServerConfigurationUpdated": "Η ρύθμιση παραμέτρων του server έχει ενημερωθεί",
"MixedContent": "Ανάμεικτο Περιεχόμενο",
@@ -49,7 +49,7 @@
"NotificationOptionApplicationUpdateInstalled": "Η ενημέρωση εφαρμογής εγκαταστάθηκε",
"NotificationOptionAudioPlayback": "Η αναπαραγωγή ήχου ξεκίνησε",
"NotificationOptionAudioPlaybackStopped": "Η αναπαραγωγή ήχου σταμάτησε",
- "NotificationOptionCameraImageUploaded": "Camera image uploaded",
+ "NotificationOptionCameraImageUploaded": "Μεταφορτώθηκε φωτογραφία απο κάμερα",
"NotificationOptionInstallationFailed": "Αποτυχία εγκατάστασης",
"NotificationOptionNewLibraryContent": "Προστέθηκε νέο περιεχόμενο",
"NotificationOptionPluginError": "Αποτυχία του plugin",
@@ -75,7 +75,7 @@
"Songs": "Τραγούδια",
"StartupEmbyServerIsLoading": "Ο Jellyfin Server φορτώνει. Παρακαλώ δοκιμάστε σε λίγο.",
"SubtitleDownloadFailureForItem": "Οι υπότιτλοι απέτυχαν να κατέβουν για {0}",
- "SubtitleDownloadFailureFromForItem": "Subtitles failed to download from {0} for {1}",
+ "SubtitleDownloadFailureFromForItem": "Αποτυχίες μεταφόρτωσης υποτίτλων από {0} για {1}",
"SubtitlesDownloadedForItem": "Οι υπότιτλοι κατέβηκαν για {0}",
"Sync": "Συγχρονισμός",
"System": "Σύστημα",
diff --git a/Emby.Server.Implementations/Localization/Core/gsw.json b/Emby.Server.Implementations/Localization/Core/gsw.json
index 728002a56..69c157401 100644
--- a/Emby.Server.Implementations/Localization/Core/gsw.json
+++ b/Emby.Server.Implementations/Localization/Core/gsw.json
@@ -1,97 +1,97 @@
{
- "Albums": "Albums",
- "AppDeviceValues": "App: {0}, Device: {1}",
- "Application": "Application",
- "Artists": "Artists",
- "AuthenticationSucceededWithUserName": "{0} successfully authenticated",
+ "Albums": "Albom",
+ "AppDeviceValues": "App: {0}, Grät: {1}",
+ "Application": "Aawändig",
+ "Artists": "Könstler",
+ "AuthenticationSucceededWithUserName": "{0} het sech aagmäudet",
"Books": "Büecher",
- "CameraImageUploadedFrom": "A new camera image has been uploaded from {0}",
- "Channels": "Channels",
- "ChapterNameValue": "Chapter {0}",
- "Collections": "Collections",
- "DeviceOfflineWithName": "{0} has disconnected",
- "DeviceOnlineWithName": "{0} is connected",
- "FailedLoginAttemptWithUserName": "Failed login attempt from {0}",
- "Favorites": "Favorites",
- "Folders": "Folders",
+ "CameraImageUploadedFrom": "Es nöis Foti esch ufeglade worde vo {0}",
+ "Channels": "Kanäu",
+ "ChapterNameValue": "Kapitu {0}",
+ "Collections": "Sammlige",
+ "DeviceOfflineWithName": "{0} esch offline gange",
+ "DeviceOnlineWithName": "{0} esch online cho",
+ "FailedLoginAttemptWithUserName": "Fäugschlagne Aamäudeversuech vo {0}",
+ "Favorites": "Favorite",
+ "Folders": "Ordner",
"Genres": "Genres",
- "HeaderAlbumArtists": "Albuminterprete",
- "HeaderCameraUploads": "Camera Uploads",
+ "HeaderAlbumArtists": "Albom-Könstler",
+ "HeaderCameraUploads": "Kamera-Uploads",
"HeaderContinueWatching": "Wiiterluege",
- "HeaderFavoriteAlbums": "Favorite Albums",
- "HeaderFavoriteArtists": "Besti Interpret",
- "HeaderFavoriteEpisodes": "Favorite Episodes",
- "HeaderFavoriteShows": "Favorite Shows",
- "HeaderFavoriteSongs": "Besti Lieder",
- "HeaderLiveTV": "Live TV",
- "HeaderNextUp": "Next Up",
+ "HeaderFavoriteAlbums": "Lieblingsalbe",
+ "HeaderFavoriteArtists": "Lieblings-Interprete",
+ "HeaderFavoriteEpisodes": "Lieblingsepisode",
+ "HeaderFavoriteShows": "Lieblingsserie",
+ "HeaderFavoriteSongs": "Lieblingslieder",
+ "HeaderLiveTV": "Live-Färnseh",
+ "HeaderNextUp": "Als nächts",
"HeaderRecordingGroups": "Ufnahmegruppe",
"HomeVideos": "Heimfilmli",
"Inherit": "Hinzuefüege",
- "ItemAddedWithName": "{0} was added to the library",
- "ItemRemovedWithName": "{0} was removed from the library",
- "LabelIpAddressValue": "Ip address: {0}",
- "LabelRunningTimeValue": "Running time: {0}",
- "Latest": "Letschte",
- "MessageApplicationUpdated": "Jellyfin Server has been updated",
- "MessageApplicationUpdatedTo": "Jellyfin Server has been updated to {0}",
- "MessageNamedServerConfigurationUpdatedWithValue": "Server configuration section {0} has been updated",
- "MessageServerConfigurationUpdated": "Server configuration has been updated",
- "MixedContent": "Gmischte Inhalt",
- "Movies": "Movies",
+ "ItemAddedWithName": "{0} esch de Bibliothek dezuegfüegt worde",
+ "ItemRemovedWithName": "{0} esch vo de Bibliothek entfärnt worde",
+ "LabelIpAddressValue": "IP-Adrässe: {0}",
+ "LabelRunningTimeValue": "Loufziit: {0}",
+ "Latest": "Nöischti",
+ "MessageApplicationUpdated": "Jellyfin Server esch aktualisiert worde",
+ "MessageApplicationUpdatedTo": "Jellyfin Server esch of Version {0} aktualisiert worde",
+ "MessageNamedServerConfigurationUpdatedWithValue": "De Serveriistöuigsberiich {0} esch aktualisiert worde",
+ "MessageServerConfigurationUpdated": "Serveriistöuige send aktualisiert worde",
+ "MixedContent": "Gmeschti Inhäut",
+ "Movies": "Film",
"Music": "Musig",
- "MusicVideos": "Musigfilm",
- "NameInstallFailed": "{0} installation failed",
- "NameSeasonNumber": "Season {0}",
- "NameSeasonUnknown": "Season Unknown",
- "NewVersionIsAvailable": "A new version of Jellyfin Server is available for download.",
- "NotificationOptionApplicationUpdateAvailable": "Application update available",
- "NotificationOptionApplicationUpdateInstalled": "Application update installed",
- "NotificationOptionAudioPlayback": "Audio playback started",
- "NotificationOptionAudioPlaybackStopped": "Audio playback stopped",
- "NotificationOptionCameraImageUploaded": "Camera image uploaded",
- "NotificationOptionInstallationFailed": "Installation failure",
- "NotificationOptionNewLibraryContent": "New content added",
- "NotificationOptionPluginError": "Plugin failure",
- "NotificationOptionPluginInstalled": "Plugin installed",
- "NotificationOptionPluginUninstalled": "Plugin uninstalled",
- "NotificationOptionPluginUpdateInstalled": "Plugin update installed",
- "NotificationOptionServerRestartRequired": "Server restart required",
- "NotificationOptionTaskFailed": "Scheduled task failure",
- "NotificationOptionUserLockedOut": "User locked out",
- "NotificationOptionVideoPlayback": "Video playback started",
- "NotificationOptionVideoPlaybackStopped": "Video playback stopped",
+ "MusicVideos": "Musigvideos",
+ "NameInstallFailed": "Installation vo {0} fäugschlage",
+ "NameSeasonNumber": "Staffle {0}",
+ "NameSeasonUnknown": "Staffle unbekannt",
+ "NewVersionIsAvailable": "E nöi Version vo Jellyfin Server esch zom Download parat.",
+ "NotificationOptionApplicationUpdateAvailable": "Aawändigsupdate verfüegbar",
+ "NotificationOptionApplicationUpdateInstalled": "Aawändigsupdate installiert",
+ "NotificationOptionAudioPlayback": "Audiowedergab gstartet",
+ "NotificationOptionAudioPlaybackStopped": "Audiwedergab gstoppt",
+ "NotificationOptionCameraImageUploaded": "Foti ueglade",
+ "NotificationOptionInstallationFailed": "Installationsfäuer",
+ "NotificationOptionNewLibraryContent": "Nöie Inhaut hinzuegfüegt",
+ "NotificationOptionPluginError": "Plugin-Fäuer",
+ "NotificationOptionPluginInstalled": "Plugin installiert",
+ "NotificationOptionPluginUninstalled": "Plugin deinstalliert",
+ "NotificationOptionPluginUpdateInstalled": "Pluginupdate installiert",
+ "NotificationOptionServerRestartRequired": "Serverneustart notwändig",
+ "NotificationOptionTaskFailed": "Planti Uufgab fäugschlage",
+ "NotificationOptionUserLockedOut": "Benotzer usgschlosse",
+ "NotificationOptionVideoPlayback": "Videowedergab gstartet",
+ "NotificationOptionVideoPlaybackStopped": "Videowedergab gstoppt",
"Photos": "Fotis",
- "Playlists": "Abspielliste",
+ "Playlists": "Wedergabeliste",
"Plugin": "Plugin",
- "PluginInstalledWithName": "{0} was installed",
- "PluginUninstalledWithName": "{0} was uninstalled",
- "PluginUpdatedWithName": "{0} was updated",
- "ProviderValue": "Provider: {0}",
- "ScheduledTaskFailedWithName": "{0} failed",
- "ScheduledTaskStartedWithName": "{0} started",
- "ServerNameNeedsToBeRestarted": "{0} needs to be restarted",
- "Shows": "Shows",
- "Songs": "Songs",
- "StartupEmbyServerIsLoading": "Jellyfin Server is loading. Please try again shortly.",
+ "PluginInstalledWithName": "{0} esch installiert worde",
+ "PluginUninstalledWithName": "{0} esch deinstalliert worde",
+ "PluginUpdatedWithName": "{0} esch updated worde",
+ "ProviderValue": "Aabieter: {0}",
+ "ScheduledTaskFailedWithName": "{0} esch fäugschlage",
+ "ScheduledTaskStartedWithName": "{0} het gstartet",
+ "ServerNameNeedsToBeRestarted": "{0} mues nöi gstartet wärde",
+ "Shows": "Serie",
+ "Songs": "Lieder",
+ "StartupEmbyServerIsLoading": "Jellyfin Server ladt. Bitte grad noeinisch probiere.",
"SubtitleDownloadFailureForItem": "Subtitles failed to download for {0}",
- "SubtitleDownloadFailureFromForItem": "Subtitles failed to download from {0} for {1}",
- "SubtitlesDownloadedForItem": "Subtitles downloaded for {0}",
- "Sync": "Sync",
+ "SubtitleDownloadFailureFromForItem": "Ondertetle vo {0} för {1} hend ned chönne abeglade wärde",
+ "SubtitlesDownloadedForItem": "Ondertetle abeglade för {0}",
+ "Sync": "Synchronisation",
"System": "System",
- "TvShows": "TV Shows",
- "User": "User",
- "UserCreatedWithName": "User {0} has been created",
- "UserDeletedWithName": "User {0} has been deleted",
- "UserDownloadingItemWithValues": "{0} is downloading {1}",
- "UserLockedOutWithName": "User {0} has been locked out",
- "UserOfflineFromDevice": "{0} has disconnected from {1}",
- "UserOnlineFromDevice": "{0} is online from {1}",
- "UserPasswordChangedWithName": "Password has been changed for user {0}",
- "UserPolicyUpdatedWithName": "User policy has been updated for {0}",
- "UserStartedPlayingItemWithValues": "{0} is playing {1} on {2}",
- "UserStoppedPlayingItemWithValues": "{0} has finished playing {1} on {2}",
- "ValueHasBeenAddedToLibrary": "{0} has been added to your media library",
- "ValueSpecialEpisodeName": "Spezial - {0}",
+ "TvShows": "Färnsehserie",
+ "User": "Benotzer",
+ "UserCreatedWithName": "Benotzer {0} esch erstöut worde",
+ "UserDeletedWithName": "Benotzer {0} esch glösche worde",
+ "UserDownloadingItemWithValues": "{0} ladt {1} abe",
+ "UserLockedOutWithName": "Benotzer {0} esch usgschlosse worde",
+ "UserOfflineFromDevice": "{0} esch vo {1} trennt worde",
+ "UserOnlineFromDevice": "{0} esch online vo {1}",
+ "UserPasswordChangedWithName": "S'Passwort för Benotzer {0} esch gänderet worde",
+ "UserPolicyUpdatedWithName": "Benotzerrechtlinie för {0} esch aktualisiert worde",
+ "UserStartedPlayingItemWithValues": "{0} hed d'Wedergab vo {1} of {2} gstartet",
+ "UserStoppedPlayingItemWithValues": "{0} het d'Wedergab vo {1} of {2} gstoppt",
+ "ValueHasBeenAddedToLibrary": "{0} esch dinnere Biblithek hinzuegfüegt worde",
+ "ValueSpecialEpisodeName": "Extra - {0}",
"VersionNumber": "Version {0}"
}
diff --git a/Emby.Server.Implementations/Localization/Core/kk.json b/Emby.Server.Implementations/Localization/Core/kk.json
index 23841f37d..cbee71155 100644
--- a/Emby.Server.Implementations/Localization/Core/kk.json
+++ b/Emby.Server.Implementations/Localization/Core/kk.json
@@ -5,7 +5,7 @@
"Artists": "Oryndaýshylar",
"AuthenticationSucceededWithUserName": "{0} túpnusqalyq rastalýy sátti aıaqtaldy",
"Books": "Kitaptar",
- "CameraImageUploadedFrom": "{0} kamerasynan jańa sýret júktep alyndy",
+ "CameraImageUploadedFrom": "{0} kamerasynan jańa sýret júktep salyndy",
"Channels": "Arnalar",
"ChapterNameValue": "{0}-sahna",
"Collections": "Jıyntyqtar",
@@ -35,8 +35,8 @@
"Latest": "Eń keıingi",
"MessageApplicationUpdated": "Jellyfin Serveri jańartyldy",
"MessageApplicationUpdatedTo": "Jellyfin Serveri {0} nusqasyna jańartyldy",
- "MessageNamedServerConfigurationUpdatedWithValue": "Server teńsheliminiń {0} bólimi jańartyldy",
- "MessageServerConfigurationUpdated": "Server teńshelimi jańartyldy",
+ "MessageNamedServerConfigurationUpdatedWithValue": "Server konfıgýrasýasynyń {0} bólimi jańartyldy",
+ "MessageServerConfigurationUpdated": "Server konfıgýrasıasy jańartyldy",
"MixedContent": "Aralas mazmun",
"Movies": "Fılmder",
"Music": "Mýzyka",
@@ -49,7 +49,7 @@
"NotificationOptionApplicationUpdateInstalled": "Qoldanba jańartýy ornatyldy",
"NotificationOptionAudioPlayback": "Dybys oınatýy bastaldy",
"NotificationOptionAudioPlaybackStopped": "Dybys oınatýy toqtatyldy",
- "NotificationOptionCameraImageUploaded": "Kameradan fotosýret keri qotarylǵan",
+ "NotificationOptionCameraImageUploaded": "Kameradan fotosýret júktep salynǵan",
"NotificationOptionInstallationFailed": "Ornatý sátsizdigi",
"NotificationOptionNewLibraryContent": "Jańa mazmun ústelgen",
"NotificationOptionPluginError": "Plagın sátsizdigi",
diff --git a/Emby.Server.Implementations/Localization/Core/sl-SI.json b/Emby.Server.Implementations/Localization/Core/sl-SI.json
index b50ff4706..531dfe51f 100644
--- a/Emby.Server.Implementations/Localization/Core/sl-SI.json
+++ b/Emby.Server.Implementations/Localization/Core/sl-SI.json
@@ -9,7 +9,7 @@
"Channels": "Kanali",
"ChapterNameValue": "Poglavje {0}",
"Collections": "Zbirke",
- "DeviceOfflineWithName": "{0} has disconnected",
+ "DeviceOfflineWithName": "{0} je prekinil povezavo",
"DeviceOnlineWithName": "{0} je povezan",
"FailedLoginAttemptWithUserName": "Neuspešen poskus prijave z {0}",
"Favorites": "Priljubljeni",
@@ -33,9 +33,9 @@
"LabelIpAddressValue": "IP naslov: {0}",
"LabelRunningTimeValue": "Čas trajanja: {0}",
"Latest": "Najnovejše",
- "MessageApplicationUpdated": "Jellyfin strežnik je bil posodobljen",
- "MessageApplicationUpdatedTo": "Jellyfin strežnik je bil posodobljen na {0}",
- "MessageNamedServerConfigurationUpdatedWithValue": "Server configuration section {0} has been updated",
+ "MessageApplicationUpdated": "Jellyfin Server je bil posodobljen",
+ "MessageApplicationUpdatedTo": "Jellyfin Server je bil posodobljen na {0}",
+ "MessageNamedServerConfigurationUpdatedWithValue": "Oddelek nastavitve strežnika {0} je bil posodobljen",
"MessageServerConfigurationUpdated": "Nastavitve strežnika so bile posodobljene",
"MixedContent": "Razne vsebine",
"Movies": "Filmi",
@@ -57,41 +57,41 @@
"NotificationOptionPluginUninstalled": "Dodatek odstranjen",
"NotificationOptionPluginUpdateInstalled": "Posodobitev dodatka nameščena",
"NotificationOptionServerRestartRequired": "Potreben je ponovni zagon strežnika",
- "NotificationOptionTaskFailed": "Scheduled task failure",
- "NotificationOptionUserLockedOut": "User locked out",
- "NotificationOptionVideoPlayback": "Video playback started",
- "NotificationOptionVideoPlaybackStopped": "Video playback stopped",
- "Photos": "Photos",
- "Playlists": "Playlists",
+ "NotificationOptionTaskFailed": "Razporejena naloga neuspešna",
+ "NotificationOptionUserLockedOut": "Uporabnik zaklenjen",
+ "NotificationOptionVideoPlayback": "Predvajanje videa se je začelo",
+ "NotificationOptionVideoPlaybackStopped": "Predvajanje videa se je ustavilo",
+ "Photos": "Fotografije",
+ "Playlists": "Seznami predvajanja",
"Plugin": "Plugin",
- "PluginInstalledWithName": "{0} was installed",
- "PluginUninstalledWithName": "{0} was uninstalled",
- "PluginUpdatedWithName": "{0} was updated",
+ "PluginInstalledWithName": "{0} je bil nameščen",
+ "PluginUninstalledWithName": "{0} je bil odstranjen",
+ "PluginUpdatedWithName": "{0} je bil posodobljen",
"ProviderValue": "Provider: {0}",
- "ScheduledTaskFailedWithName": "{0} failed",
- "ScheduledTaskStartedWithName": "{0} started",
- "ServerNameNeedsToBeRestarted": "{0} needs to be restarted",
+ "ScheduledTaskFailedWithName": "{0} ni uspelo",
+ "ScheduledTaskStartedWithName": "{0} začeto",
+ "ServerNameNeedsToBeRestarted": "{0} mora biti ponovno zagnan",
"Shows": "Serije",
- "Songs": "Songs",
- "StartupEmbyServerIsLoading": "Jellyfin Server is loading. Please try again shortly.",
+ "Songs": "Pesmi",
+ "StartupEmbyServerIsLoading": "Jellyfin Server se nalaga. Poskusi ponovno kasneje.",
"SubtitleDownloadFailureForItem": "Subtitles failed to download for {0}",
- "SubtitleDownloadFailureFromForItem": "Subtitles failed to download from {0} for {1}",
- "SubtitlesDownloadedForItem": "Subtitles downloaded for {0}",
- "Sync": "Sync",
+ "SubtitleDownloadFailureFromForItem": "Neuspešen prenos podnapisov iz {0} za {1}",
+ "SubtitlesDownloadedForItem": "Podnapisi preneseni za {0}",
+ "Sync": "Sinhroniziraj",
"System": "System",
- "TvShows": "TV Shows",
+ "TvShows": "TV serije",
"User": "User",
- "UserCreatedWithName": "User {0} has been created",
- "UserDeletedWithName": "User {0} has been deleted",
- "UserDownloadingItemWithValues": "{0} is downloading {1}",
- "UserLockedOutWithName": "User {0} has been locked out",
- "UserOfflineFromDevice": "{0} has disconnected from {1}",
- "UserOnlineFromDevice": "{0} is online from {1}",
- "UserPasswordChangedWithName": "Password has been changed for user {0}",
- "UserPolicyUpdatedWithName": "User policy has been updated for {0}",
- "UserStartedPlayingItemWithValues": "{0} is playing {1} on {2}",
- "UserStoppedPlayingItemWithValues": "{0} has finished playing {1} on {2}",
- "ValueHasBeenAddedToLibrary": "{0} has been added to your media library",
+ "UserCreatedWithName": "Uporabnik {0} je bil ustvarjen",
+ "UserDeletedWithName": "Uporabnik {0} je bil izbrisan",
+ "UserDownloadingItemWithValues": "{0} prenaša {1}",
+ "UserLockedOutWithName": "Uporabnik {0} je bil zaklenjen",
+ "UserOfflineFromDevice": "{0} je prekinil povezavo z {1}",
+ "UserOnlineFromDevice": "{0} je aktiven iz {1}",
+ "UserPasswordChangedWithName": "Geslo za uporabnika {0} je bilo spremenjeno",
+ "UserPolicyUpdatedWithName": "Pravilnik uporabe je bil posodobljen za uporabnika {0}",
+ "UserStartedPlayingItemWithValues": "{0} predvaja {1} na {2}",
+ "UserStoppedPlayingItemWithValues": "{0} je nehal predvajati {1} na {2}",
+ "ValueHasBeenAddedToLibrary": "{0} je bil dodan vaši knjižnici",
"ValueSpecialEpisodeName": "Special - {0}",
"VersionNumber": "Version {0}"
}
diff --git a/Emby.Server.Implementations/Localization/Core/zh-TW.json b/Emby.Server.Implementations/Localization/Core/zh-TW.json
new file mode 100644
index 000000000..effff5566
--- /dev/null
+++ b/Emby.Server.Implementations/Localization/Core/zh-TW.json
@@ -0,0 +1,93 @@
+{
+ "Albums": "專輯",
+ "AppDeviceValues": "應用: {0}, 裝置: {1}",
+ "Application": "應用程式",
+ "Artists": "演出者",
+ "AuthenticationSucceededWithUserName": "{0} 成功授權",
+ "Books": "圖書",
+ "CameraImageUploadedFrom": "{0} 已經成功上傳一張相片",
+ "Channels": "頻道",
+ "ChapterNameValue": "章節 {0}",
+ "Collections": "合輯",
+ "DeviceOfflineWithName": "{0} 已經斷線",
+ "DeviceOnlineWithName": "{0} 已經連線",
+ "FailedLoginAttemptWithUserName": "來自 {0} 的失敗登入嘗試",
+ "Favorites": "我的最愛",
+ "Folders": "資料夾",
+ "Genres": "風格",
+ "HeaderAlbumArtists": "專輯演出者",
+ "HeaderCameraUploads": "相機上傳",
+ "HeaderContinueWatching": "繼續觀賞",
+ "HeaderFavoriteAlbums": "最愛專輯",
+ "HeaderFavoriteArtists": "最愛演出者",
+ "HeaderFavoriteEpisodes": "最愛級數",
+ "HeaderFavoriteShows": "最愛節目",
+ "HeaderFavoriteSongs": "最愛歌曲",
+ "HeaderLiveTV": "電視直播",
+ "HeaderNextUp": "接下來",
+ "HomeVideos": "自製影片",
+ "ItemAddedWithName": "{0} 已新增至媒體庫",
+ "ItemRemovedWithName": "{0} 已從媒體庫移除",
+ "LabelIpAddressValue": "IP 位置: {0}",
+ "LabelRunningTimeValue": "運行時間: {0}",
+ "Latest": "最新",
+ "MessageApplicationUpdated": "Jellyfin Server 已經更新",
+ "MessageApplicationUpdatedTo": "Jellyfin Server 已經更新至 {0}",
+ "MessageNamedServerConfigurationUpdatedWithValue": "伺服器設定 {0} 部分已經更新",
+ "MessageServerConfigurationUpdated": "伺服器設定已經更新",
+ "MixedContent": "混合內容",
+ "Movies": "電影",
+ "Music": "音樂",
+ "MusicVideos": "音樂MV",
+ "NameInstallFailed": "{0} 安裝失敗",
+ "NameSeasonNumber": "第 {0} 季",
+ "NameSeasonUnknown": "未知季數",
+ "NewVersionIsAvailable": "新版本的Jellyfin Server 軟體已經推出可供下載。",
+ "NotificationOptionApplicationUpdateAvailable": "有可用的應用程式更新",
+ "NotificationOptionApplicationUpdateInstalled": "應用程式已更新",
+ "NotificationOptionAudioPlayback": "音樂開始播放",
+ "NotificationOptionAudioPlaybackStopped": "音樂停止播放",
+ "NotificationOptionCameraImageUploaded": "相機相片已上傳",
+ "NotificationOptionInstallationFailed": "安裝失敗",
+ "NotificationOptionNewLibraryContent": "已新增新內容",
+ "NotificationOptionPluginError": "外掛失敗",
+ "NotificationOptionPluginInstalled": "外掛已安裝",
+ "NotificationOptionPluginUninstalled": "外掛已移除",
+ "NotificationOptionPluginUpdateInstalled": "已更新外掛",
+ "NotificationOptionServerRestartRequired": "伺服器需要重新啟動",
+ "NotificationOptionTaskFailed": "排程任務失敗",
+ "NotificationOptionUserLockedOut": "使用者已鎖定",
+ "NotificationOptionVideoPlayback": "影片開始播放",
+ "NotificationOptionVideoPlaybackStopped": "影片停止播放",
+ "Photos": "相片",
+ "Playlists": "播放清單",
+ "Plugin": "外掛",
+ "PluginInstalledWithName": "{0} 已安裝",
+ "PluginUninstalledWithName": "{0} 已移除",
+ "PluginUpdatedWithName": "{0} 已更新",
+ "ProviderValue": "提供商: {0}",
+ "ScheduledTaskFailedWithName": "{0} 已失敗",
+ "ScheduledTaskStartedWithName": "{0} 已開始",
+ "ServerNameNeedsToBeRestarted": "{0} 需要重新啟動",
+ "Shows": "節目",
+ "Songs": "歌曲",
+ "StartupEmbyServerIsLoading": "Jellyfin Server正在啟動,請稍後再試一次。",
+ "SubtitlesDownloadedForItem": "已為 {0} 下載字幕",
+ "Sync": "同步",
+ "System": "系統",
+ "TvShows": "電視節目",
+ "User": "使用者",
+ "UserCreatedWithName": "使用者 {0} 已建立",
+ "UserDeletedWithName": "使用者 {0} 已移除",
+ "UserDownloadingItemWithValues": "{0} 正在下載 {1}",
+ "UserLockedOutWithName": "使用者 {0} 已鎖定",
+ "UserOfflineFromDevice": "{0} 已從 {1} 斷線",
+ "UserOnlineFromDevice": "{0} 已連線,來自 {1}",
+ "UserPasswordChangedWithName": "使用者 {0} 的密碼已變更",
+ "UserPolicyUpdatedWithName": "使用者條約已更新為 {0}",
+ "UserStartedPlayingItemWithValues": "{0}正在使用 {2} 播放 {1}",
+ "UserStoppedPlayingItemWithValues": "{0} 已停止在 {2} 播放 {1}",
+ "ValueHasBeenAddedToLibrary": "{0} 已新增至您的媒體庫",
+ "ValueSpecialEpisodeName": "特典 - {0}",
+ "VersionNumber": "版本 {0}"
+}
diff --git a/Emby.Server.Implementations/Services/HttpResult.cs b/Emby.Server.Implementations/Services/HttpResult.cs
index b6758486c..2b5963a77 100644
--- a/Emby.Server.Implementations/Services/HttpResult.cs
+++ b/Emby.Server.Implementations/Services/HttpResult.cs
@@ -43,6 +43,11 @@ namespace Emby.Server.Implementations.Services
{
var contentLength = bytesResponse.Length;
+ if (response != null)
+ {
+ response.OriginalResponse.ContentLength = contentLength;
+ }
+
if (contentLength > 0)
{
await responseStream.WriteAsync(bytesResponse, 0, contentLength, cancellationToken).ConfigureAwait(false);
diff --git a/Emby.Server.Implementations/Services/ResponseHelper.cs b/Emby.Server.Implementations/Services/ResponseHelper.cs
index 0301ff335..251ba3529 100644
--- a/Emby.Server.Implementations/Services/ResponseHelper.cs
+++ b/Emby.Server.Implementations/Services/ResponseHelper.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Globalization;
using System.IO;
using System.Net;
using System.Text;
@@ -20,6 +21,8 @@ namespace Emby.Server.Implementations.Services
{
response.StatusCode = (int)HttpStatusCode.NoContent;
}
+
+ response.OriginalResponse.ContentLength = 0;
return Task.CompletedTask;
}
@@ -39,11 +42,6 @@ namespace Emby.Server.Implementations.Services
response.StatusCode = httpResult.Status;
response.StatusDescription = httpResult.StatusCode.ToString();
- //if (string.IsNullOrEmpty(httpResult.ContentType))
- //{
- // httpResult.ContentType = defaultContentType;
- //}
- //response.ContentType = httpResult.ContentType;
}
var responseOptions = result as IHasHeaders;
@@ -53,6 +51,7 @@ namespace Emby.Server.Implementations.Services
{
if (string.Equals(responseHeaders.Key, "Content-Length", StringComparison.OrdinalIgnoreCase))
{
+ response.OriginalResponse.ContentLength = long.Parse(responseHeaders.Value, CultureInfo.InvariantCulture);
continue;
}
@@ -72,52 +71,37 @@ namespace Emby.Server.Implementations.Services
response.ContentType += "; charset=utf-8";
}
- var asyncStreamWriter = result as IAsyncStreamWriter;
- if (asyncStreamWriter != null)
- {
- return asyncStreamWriter.WriteToAsync(response.OutputStream, cancellationToken);
- }
-
- var streamWriter = result as IStreamWriter;
- if (streamWriter != null)
+ switch (result)
{
- streamWriter.WriteTo(response.OutputStream);
- return Task.CompletedTask;
- }
-
- var fileWriter = result as FileWriter;
- if (fileWriter != null)
- {
- return fileWriter.WriteToAsync(response, cancellationToken);
- }
-
- var stream = result as Stream;
- if (stream != null)
- {
- return CopyStream(stream, response.OutputStream);
- }
+ case IAsyncStreamWriter asyncStreamWriter:
+ return asyncStreamWriter.WriteToAsync(response.OutputStream, cancellationToken);
+ case IStreamWriter streamWriter:
+ streamWriter.WriteTo(response.OutputStream);
+ return Task.CompletedTask;
+ case FileWriter fileWriter:
+ return fileWriter.WriteToAsync(response, cancellationToken);
+ case Stream stream:
+ return CopyStream(stream, response.OutputStream);
+ case byte[] bytes:
+ response.ContentType = "application/octet-stream";
+ response.OriginalResponse.ContentLength = bytes.Length;
+
+ if (bytes.Length > 0)
+ {
+ return response.OutputStream.WriteAsync(bytes, 0, bytes.Length, cancellationToken);
+ }
- var bytes = result as byte[];
- if (bytes != null)
- {
- response.ContentType = "application/octet-stream";
+ return Task.CompletedTask;
+ case string responseText:
+ var responseTextAsBytes = Encoding.UTF8.GetBytes(responseText);
+ response.OriginalResponse.ContentLength = responseTextAsBytes.Length;
- if (bytes.Length > 0)
- {
- return response.OutputStream.WriteAsync(bytes, 0, bytes.Length, cancellationToken);
- }
- return Task.CompletedTask;
- }
+ if (responseTextAsBytes.Length > 0)
+ {
+ return response.OutputStream.WriteAsync(responseTextAsBytes, 0, responseTextAsBytes.Length, cancellationToken);
+ }
- var responseText = result as string;
- if (responseText != null)
- {
- bytes = Encoding.UTF8.GetBytes(responseText);
- if (bytes.Length > 0)
- {
- return response.OutputStream.WriteAsync(bytes, 0, bytes.Length, cancellationToken);
- }
- return Task.CompletedTask;
+ return Task.CompletedTask;
}
return WriteObject(request, result, response);
@@ -143,14 +127,13 @@ namespace Emby.Server.Implementations.Services
ms.Position = 0;
var contentLength = ms.Length;
+ response.OriginalResponse.ContentLength = contentLength;
if (contentLength > 0)
{
await ms.CopyToAsync(response.OutputStream).ConfigureAwait(false);
}
}
-
- //serializer(result, outputStream);
}
}
}
diff --git a/Emby.Server.Implementations/Services/ServiceController.cs b/Emby.Server.Implementations/Services/ServiceController.cs
index 5796956d8..5e3d529c6 100644
--- a/Emby.Server.Implementations/Services/ServiceController.cs
+++ b/Emby.Server.Implementations/Services/ServiceController.cs
@@ -1,26 +1,17 @@
using System;
using System.Collections.Generic;
-using System.Reflection;
using System.Threading.Tasks;
using Emby.Server.Implementations.HttpServer;
using MediaBrowser.Model.Services;
namespace Emby.Server.Implementations.Services
{
- public delegate Task<object> InstanceExecFn(IRequest requestContext, object intance, object request);
public delegate object ActionInvokerFn(object intance, object request);
public delegate void VoidActionInvokerFn(object intance, object request);
public class ServiceController
{
- public static ServiceController Instance;
-
- public ServiceController()
- {
- Instance = this;
- }
-
- public void Init(HttpListenerHost appHost, Type[] serviceTypes)
+ public void Init(HttpListenerHost appHost, IEnumerable<Type> serviceTypes)
{
foreach (var serviceType in serviceTypes)
{
@@ -37,7 +28,11 @@ namespace Emby.Server.Implementations.Services
foreach (var mi in serviceType.GetActions())
{
var requestType = mi.GetParameters()[0].ParameterType;
- if (processedReqs.Contains(requestType)) continue;
+ if (processedReqs.Contains(requestType))
+ {
+ continue;
+ }
+
processedReqs.Add(requestType);
ServiceExecGeneral.CreateServiceRunnersFor(requestType, actions);
@@ -55,18 +50,6 @@ namespace Emby.Server.Implementations.Services
}
}
- public static Type FirstGenericType(Type type)
- {
- while (type != null)
- {
- if (type.GetTypeInfo().IsGenericType)
- return type;
-
- type = type.GetTypeInfo().BaseType;
- }
- return null;
- }
-
public readonly RestPath.RestPathMap RestPathMap = new RestPath.RestPathMap();
public void RegisterRestPaths(HttpListenerHost appHost, Type requestType, Type serviceType)
@@ -84,17 +67,24 @@ namespace Emby.Server.Implementations.Services
public void RegisterRestPath(RestPath restPath)
{
- if (!restPath.Path.StartsWith("/"))
+ if (restPath.Path[0] != '/')
+ {
throw new ArgumentException(string.Format("Route '{0}' on '{1}' must start with a '/'", restPath.Path, restPath.RequestType.GetMethodName()));
+ }
+
if (restPath.Path.IndexOfAny(InvalidRouteChars) != -1)
+ {
throw new ArgumentException(string.Format("Route '{0}' on '{1}' contains invalid chars. ", restPath.Path, restPath.RequestType.GetMethodName()));
+ }
- if (!RestPathMap.TryGetValue(restPath.FirstMatchHashKey, out List<RestPath> pathsAtFirstMatch))
+ if (RestPathMap.TryGetValue(restPath.FirstMatchHashKey, out List<RestPath> pathsAtFirstMatch))
{
- pathsAtFirstMatch = new List<RestPath>();
- RestPathMap[restPath.FirstMatchHashKey] = pathsAtFirstMatch;
+ pathsAtFirstMatch.Add(restPath);
+ }
+ else
+ {
+ RestPathMap[restPath.FirstMatchHashKey] = new List<RestPath>() { restPath };
}
- pathsAtFirstMatch.Add(restPath);
}
public RestPath GetRestPathForRequest(string httpMethod, string pathInfo)
@@ -155,17 +145,15 @@ namespace Emby.Server.Implementations.Services
return null;
}
- public Task<object> Execute(HttpListenerHost appHost, object requestDto, IRequest req)
+ public Task<object> Execute(HttpListenerHost httpHost, object requestDto, IRequest req)
{
req.Dto = requestDto;
var requestType = requestDto.GetType();
req.OperationName = requestType.Name;
- var serviceType = appHost.GetServiceTypeByRequest(requestType);
-
- var service = appHost.CreateInstance(serviceType);
+ var serviceType = httpHost.GetServiceTypeByRequest(requestType);
- //var service = typeFactory.CreateInstance(serviceType);
+ var service = httpHost.CreateInstance(serviceType);
var serviceRequiresContext = service as IRequiresRequest;
if (serviceRequiresContext != null)
diff --git a/Emby.Server.Implementations/Services/ServiceHandler.cs b/Emby.Server.Implementations/Services/ServiceHandler.cs
index 3c8adfc98..d32fce1c7 100644
--- a/Emby.Server.Implementations/Services/ServiceHandler.cs
+++ b/Emby.Server.Implementations/Services/ServiceHandler.cs
@@ -11,6 +11,16 @@ namespace Emby.Server.Implementations.Services
{
public class ServiceHandler
{
+ public RestPath RestPath { get; }
+
+ public string ResponseContentType { get; }
+
+ internal ServiceHandler(RestPath restPath, string responseContentType)
+ {
+ RestPath = restPath;
+ ResponseContentType = responseContentType;
+ }
+
protected static Task<object> CreateContentTypeRequest(HttpListenerHost host, IRequest httpReq, Type requestType, string contentType)
{
if (!string.IsNullOrEmpty(contentType) && httpReq.ContentLength > 0)
@@ -18,24 +28,18 @@ namespace Emby.Server.Implementations.Services
var deserializer = RequestHelper.GetRequestReader(host, contentType);
if (deserializer != null)
{
- return deserializer(requestType, httpReq.InputStream);
+ return deserializer.Invoke(requestType, httpReq.InputStream);
}
}
- return Task.FromResult(host.CreateInstance(requestType));
- }
-
- public static RestPath FindMatchingRestPath(string httpMethod, string pathInfo, out string contentType)
- {
- pathInfo = GetSanitizedPathInfo(pathInfo, out contentType);
- return ServiceController.Instance.GetRestPathForRequest(httpMethod, pathInfo);
+ return Task.FromResult(host.CreateInstance(requestType));
}
public static string GetSanitizedPathInfo(string pathInfo, out string contentType)
{
contentType = null;
var pos = pathInfo.LastIndexOf('.');
- if (pos >= 0)
+ if (pos != -1)
{
var format = pathInfo.Substring(pos + 1);
contentType = GetFormatContentType(format);
@@ -44,58 +48,38 @@ namespace Emby.Server.Implementations.Services
pathInfo = pathInfo.Substring(0, pos);
}
}
+
return pathInfo;
}
private static string GetFormatContentType(string format)
{
//built-in formats
- if (format == "json")
- return "application/json";
- if (format == "xml")
- return "application/xml";
-
- return null;
- }
-
- public RestPath GetRestPath(string httpMethod, string pathInfo)
- {
- if (this.RestPath == null)
+ switch (format)
{
- this.RestPath = FindMatchingRestPath(httpMethod, pathInfo, out string contentType);
-
- if (contentType != null)
- ResponseContentType = contentType;
+ case "json": return "application/json";
+ case "xml": return "application/xml";
+ default: return null;
}
- return this.RestPath;
}
- public RestPath RestPath { get; set; }
-
- // Set from SSHHF.GetHandlerForPathInfo()
- public string ResponseContentType { get; set; }
-
- public async Task ProcessRequestAsync(HttpListenerHost appHost, IRequest httpReq, IResponse httpRes, ILogger logger, string operationName, CancellationToken cancellationToken)
+ public async Task ProcessRequestAsync(HttpListenerHost httpHost, IRequest httpReq, IResponse httpRes, ILogger logger, CancellationToken cancellationToken)
{
- var restPath = GetRestPath(httpReq.Verb, httpReq.PathInfo);
- if (restPath == null)
- {
- throw new NotSupportedException("No RestPath found for: " + httpReq.Verb + " " + httpReq.PathInfo);
- }
-
- SetRoute(httpReq, restPath);
+ httpReq.Items["__route"] = RestPath;
if (ResponseContentType != null)
+ {
httpReq.ResponseContentType = ResponseContentType;
+ }
- var request = httpReq.Dto = await CreateRequest(appHost, httpReq, restPath, logger).ConfigureAwait(false);
+ var request = httpReq.Dto = await CreateRequest(httpHost, httpReq, RestPath, logger).ConfigureAwait(false);
- appHost.ApplyRequestFilters(httpReq, httpRes, request);
+ httpHost.ApplyRequestFilters(httpReq, httpRes, request);
- var response = await appHost.ServiceController.Execute(appHost, request, httpReq).ConfigureAwait(false);
+ var response = await httpHost.ServiceController.Execute(httpHost, request, httpReq).ConfigureAwait(false);
// Apply response filters
- foreach (var responseFilter in appHost.ResponseFilters)
+ foreach (var responseFilter in httpHost.ResponseFilters)
{
responseFilter(httpReq, httpRes, response);
}
@@ -152,7 +136,11 @@ namespace Emby.Server.Implementations.Services
foreach (var name in request.QueryString.Keys)
{
- if (name == null) continue; //thank you ASP.NET
+ if (name == null)
+ {
+ // thank you ASP.NET
+ continue;
+ }
var values = request.QueryString[name];
if (values.Count == 1)
@@ -175,7 +163,11 @@ namespace Emby.Server.Implementations.Services
{
foreach (var name in formData.Keys)
{
- if (name == null) continue; //thank you ASP.NET
+ if (name == null)
+ {
+ // thank you ASP.NET
+ continue;
+ }
var values = formData.GetValues(name);
if (values.Count == 1)
@@ -210,7 +202,12 @@ namespace Emby.Server.Implementations.Services
foreach (var name in request.QueryString.Keys)
{
- if (name == null) continue; //thank you ASP.NET
+ if (name == null)
+ {
+ // thank you ASP.NET
+ continue;
+ }
+
map[name] = request.QueryString[name];
}
@@ -221,7 +218,12 @@ namespace Emby.Server.Implementations.Services
{
foreach (var name in formData.Keys)
{
- if (name == null) continue; //thank you ASP.NET
+ if (name == null)
+ {
+ // thank you ASP.NET
+ continue;
+ }
+
map[name] = formData[name];
}
}
@@ -229,17 +231,5 @@ namespace Emby.Server.Implementations.Services
return map;
}
-
- private static void SetRoute(IRequest req, RestPath route)
- {
- req.Items["__route"] = route;
- }
-
- private static RestPath GetRoute(IRequest req)
- {
- req.Items.TryGetValue("__route", out var route);
- return route as RestPath;
- }
}
-
}
diff --git a/Emby.Server.Implementations/Services/StringMapTypeDeserializer.cs b/Emby.Server.Implementations/Services/StringMapTypeDeserializer.cs
index f835aa1b5..6a522fbef 100644
--- a/Emby.Server.Implementations/Services/StringMapTypeDeserializer.cs
+++ b/Emby.Server.Implementations/Services/StringMapTypeDeserializer.cs
@@ -71,7 +71,7 @@ namespace Emby.Server.Implementations.Services
string propertyName = pair.Key;
string propertyTextValue = pair.Value;
- if (string.IsNullOrEmpty(propertyTextValue)
+ if (propertyTextValue == null
|| !propertySetterMap.TryGetValue(propertyName, out propertySerializerEntry)
|| propertySerializerEntry.PropertySetFn == null)
{
diff --git a/Emby.Server.Implementations/Services/SwaggerService.cs b/Emby.Server.Implementations/Services/SwaggerService.cs
index 3e6970eef..d22386436 100644
--- a/Emby.Server.Implementations/Services/SwaggerService.cs
+++ b/Emby.Server.Implementations/Services/SwaggerService.cs
@@ -1,9 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+using MediaBrowser.Controller.Net;
using MediaBrowser.Model.Services;
+using Emby.Server.Implementations.HttpServer;
namespace Emby.Server.Implementations.Services
{
@@ -109,10 +109,16 @@ namespace Emby.Server.Implementations.Services
public class SwaggerService : IService, IRequiresRequest
{
+ private readonly IHttpServer _httpServer;
private SwaggerSpec _spec;
public IRequest Request { get; set; }
+ public SwaggerService(IHttpServer httpServer)
+ {
+ _httpServer = httpServer;
+ }
+
public object Get(GetSwaggerSpec request)
{
return _spec ?? (_spec = GetSpec());
@@ -181,7 +187,8 @@ namespace Emby.Server.Implementations.Services
{
var paths = new SortedDictionary<string, Dictionary<string, SwaggerMethod>>();
- var all = ServiceController.Instance.RestPathMap.OrderBy(i => i.Key, StringComparer.OrdinalIgnoreCase).ToList();
+ // REVIEW: this can be done better
+ var all = ((HttpListenerHost)_httpServer).ServiceController.RestPathMap.OrderBy(i => i.Key, StringComparer.OrdinalIgnoreCase).ToList();
foreach (var current in all)
{
@@ -192,11 +199,8 @@ namespace Emby.Server.Implementations.Services
continue;
}
- if (info.Path.StartsWith("/mediabrowser", StringComparison.OrdinalIgnoreCase))
- {
- continue;
- }
- if (info.Path.StartsWith("/jellyfin", StringComparison.OrdinalIgnoreCase))
+ if (info.Path.StartsWith("/mediabrowser", StringComparison.OrdinalIgnoreCase)
+ || info.Path.StartsWith("/jellyfin", StringComparison.OrdinalIgnoreCase))
{
continue;
}
diff --git a/Emby.Server.Implementations/Udp/UdpServer.cs b/Emby.Server.Implementations/Udp/UdpServer.cs
index bd86c6cdc..e7cda2993 100644
--- a/Emby.Server.Implementations/Udp/UdpServer.cs
+++ b/Emby.Server.Implementations/Udp/UdpServer.cs
@@ -41,8 +41,6 @@ namespace Emby.Server.Implementations.Udp
_socketFactory = socketFactory;
AddMessageResponder("who is JellyfinServer?", true, RespondToV2Message);
- AddMessageResponder("who is EmbyServer?", true, RespondToV2Message);
- AddMessageResponder("who is MediaBrowserServer_v2?", false, RespondToV2Message);
}
private void AddMessageResponder(string message, bool isSubstring, Func<string, IpEndPointInfo, Encoding, CancellationToken, Task> responder)
diff --git a/Emby.Server.Implementations/Updates/InstallationManager.cs b/Emby.Server.Implementations/Updates/InstallationManager.cs
index 7310de55d..6833c20c3 100644
--- a/Emby.Server.Implementations/Updates/InstallationManager.cs
+++ b/Emby.Server.Implementations/Updates/InstallationManager.cs
@@ -509,6 +509,8 @@ namespace Emby.Server.Implementations.Updates
private async Task PerformPackageInstallation(IProgress<double> progress, string target, PackageVersionInfo package, CancellationToken cancellationToken)
{
+ // TODO: Remove the `string target` argument as it is not used any longer
+
var extension = Path.GetExtension(package.targetFilename);
var isArchive = string.Equals(extension, ".zip", StringComparison.OrdinalIgnoreCase);
@@ -518,12 +520,12 @@ namespace Emby.Server.Implementations.Updates
return;
}
- if (target == null)
- {
- target = Path.Combine(_appPaths.PluginsPath, Path.GetFileNameWithoutExtension(package.targetFilename));
- }
+ // Always override the passed-in target (which is a file) and figure it out again
+ target = Path.Combine(_appPaths.PluginsPath, package.name);
+ _logger.LogDebug("Installing plugin to {Filename}.", target);
// Download to temporary file so that, if interrupted, it won't destroy the existing installation
+ _logger.LogDebug("Downloading ZIP.");
var tempFile = await _httpClient.GetTempFile(new HttpRequestOptions
{
Url = package.sourceUrl,
@@ -536,9 +538,17 @@ namespace Emby.Server.Implementations.Updates
// TODO: Validate with a checksum, *properly*
+ // Check if the target directory already exists, and remove it if so
+ if (Directory.Exists(target))
+ {
+ _logger.LogDebug("Deleting existing plugin at {Filename}.", target);
+ Directory.Delete(target, true);
+ }
+
// Success - move it to the real target
try
{
+ _logger.LogDebug("Extracting ZIP {TempFile} to {Filename}.", tempFile, target);
using (var stream = File.OpenRead(tempFile))
{
_zipClient.ExtractAllFromZip(stream, target, true);
@@ -552,6 +562,7 @@ namespace Emby.Server.Implementations.Updates
try
{
+ _logger.LogDebug("Deleting temporary file {Filename}.", tempFile);
_fileSystem.DeleteFile(tempFile);
}
catch (IOException ex)
@@ -574,7 +585,13 @@ namespace Emby.Server.Implementations.Updates
_applicationHost.RemovePlugin(plugin);
var path = plugin.AssemblyFilePath;
- _logger.LogInformation("Deleting plugin file {0}", path);
+ bool isDirectory = false;
+ // Check if we have a plugin directory we should remove too
+ if (Path.GetDirectoryName(plugin.AssemblyFilePath) != _appPaths.PluginsPath)
+ {
+ path = Path.GetDirectoryName(plugin.AssemblyFilePath);
+ isDirectory = true;
+ }
// Make this case-insensitive to account for possible incorrect assembly naming
var file = _fileSystem.GetFilePaths(Path.GetDirectoryName(path))
@@ -585,7 +602,16 @@ namespace Emby.Server.Implementations.Updates
path = file;
}
- _fileSystem.DeleteFile(path);
+ if (isDirectory)
+ {
+ _logger.LogInformation("Deleting plugin directory {0}", path);
+ Directory.Delete(path, true);
+ }
+ else
+ {
+ _logger.LogInformation("Deleting plugin file {0}", path);
+ _fileSystem.DeleteFile(path);
+ }
var list = _config.Configuration.UninstalledPlugins.ToList();
var filename = Path.GetFileName(path);