diff --git a/Dockerfile b/Dockerfile
index 02332d40b4..f21249e54e 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -27,5 +27,9 @@ COPY --from=ffmpeg /ffmpeg-bin/* /usr/bin/
EXPOSE 8096
VOLUME /config /media
RUN apt-get update \
- && apt-get install -y libfontconfig1 --no-install-recommends # needed for Skia
+ && apt-get install --no-install-recommends --no-install-suggests -y \
+ libfontconfig1 # Required for Skia \
+ && apt-get clean autoclean \
+ && apt-get autoremove \
+ && rm -rf /var/lib/{apt,dpkg,cache,log}
ENTRYPOINT dotnet /jellyfin/jellyfin.dll -programdata /config
diff --git a/Emby.Naming/Emby.Naming.csproj b/Emby.Naming/Emby.Naming.csproj
index 7b40f905b0..49619d5560 100644
--- a/Emby.Naming/Emby.Naming.csproj
+++ b/Emby.Naming/Emby.Naming.csproj
@@ -13,4 +13,11 @@
+
+ Jellyfin Contributors
+ Jellyfin.Naming
+ https://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
+ https://github.com/jellyfin/jellyfin
+
+
diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs
index d4144d5c5c..91eaf9bbf2 100644
--- a/Emby.Server.Implementations/ApplicationHost.cs
+++ b/Emby.Server.Implementations/ApplicationHost.cs
@@ -230,7 +230,6 @@ namespace Emby.Server.Implementations
{
get
{
-
#if BETA
return PackageVersionClass.Beta;
#endif
@@ -510,7 +509,7 @@ namespace Emby.Server.Implementations
protected void RegisterSingleInstance(T obj, bool manageLifetime = true)
where T : class
{
- Container.RegisterSingleton(obj);
+ Container.RegisterInstance(obj);
if (manageLifetime)
{
@@ -575,7 +574,7 @@ namespace Emby.Server.Implementations
}
catch (Exception ex)
{
- Logger.LogError(ex, "Error loading assembly {file}", file);
+ Logger.LogError(ex, "Error loading assembly {File}", file);
return null;
}
}
diff --git a/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs b/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs
index 8b0012410a..3aab10026f 100644
--- a/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs
+++ b/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs
@@ -387,7 +387,7 @@ namespace Emby.Server.Implementations.HttpClientManager
{
options.ResourcePool?.Release();
- throw new HttpException(string.Format("Connection to {0} timed out", options.Url)) { IsTimedOut = true };
+ throw new HttpException($"Connection to {options.Url} timed out") { IsTimedOut = true };
}
if (options.LogRequest)
diff --git a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs
index 163b54e39d..033ffd4c02 100644
--- a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs
+++ b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs
@@ -54,39 +54,33 @@ namespace Emby.Server.Implementations.HttpServer
private IWebSocketListener[] _webSocketListeners = Array.Empty();
private readonly List _webSocketConnections = new List();
- public HttpListenerHost(IServerApplicationHost applicationHost,
+ public HttpListenerHost(
+ IServerApplicationHost applicationHost,
ILogger logger,
IServerConfigurationManager config,
- string defaultRedirectPath, INetworkManager networkManager, ITextEncoding textEncoding, IJsonSerializer jsonSerializer, IXmlSerializer xmlSerializer, Func> funcParseFn)
+ string defaultRedirectPath,
+ INetworkManager networkManager,
+ ITextEncoding textEncoding,
+ IJsonSerializer jsonSerializer,
+ IXmlSerializer xmlSerializer,
+ Func> funcParseFn)
{
- Instance = this;
-
_appHost = applicationHost;
+ _logger = logger;
+ _config = config;
DefaultRedirectPath = defaultRedirectPath;
_networkManager = networkManager;
_textEncoding = textEncoding;
_jsonSerializer = jsonSerializer;
_xmlSerializer = xmlSerializer;
- _config = config;
-
- _logger = logger;
_funcParseFn = funcParseFn;
- ResponseFilters = new Action[] { };
+ Instance = this;
+ ResponseFilters = Array.Empty>();
}
public string GlobalResponse { get; set; }
- readonly Dictionary _mapExceptionToStatusCode = new Dictionary
- {
- {typeof (ResourceNotFoundException), 404},
- {typeof (RemoteServiceUnavailableException), 502},
- {typeof (FileNotFoundException), 404},
- //{typeof (DirectoryNotFoundException), 404},
- {typeof (SecurityException), 401},
- {typeof (ArgumentException), 400}
- };
-
protected ILogger Logger => _logger;
public object CreateInstance(Type type)
@@ -103,9 +97,9 @@ namespace Emby.Server.Implementations.HttpServer
{
//Exec all RequestFilter attributes with Priority < 0
var attributes = GetRequestFilterAttributes(requestDto.GetType());
- var i = 0;
- var count = attributes.Count;
+ int count = attributes.Count;
+ int i = 0;
for (; i < count && attributes[i].Priority < 0; i++)
{
var attribute = attributes[i];
@@ -167,10 +161,7 @@ namespace Emby.Server.Implementations.HttpServer
_webSocketConnections.Add(connection);
}
- if (WebSocketConnected != null)
- {
- WebSocketConnected?.Invoke(this, new GenericEventArgs(connection));
- }
+ WebSocketConnected?.Invoke(this, new GenericEventArgs(connection));
}
private void Connection_Closed(object sender, EventArgs e)
@@ -205,26 +196,16 @@ namespace Emby.Server.Implementations.HttpServer
private int GetStatusCode(Exception ex)
{
- if (ex is ArgumentException)
+ switch (ex)
{
- return 400;
+ case ArgumentException _: return 400;
+ case SecurityException _: return 401;
+ case DirectoryNotFoundException _:
+ case FileNotFoundException _:
+ case ResourceNotFoundException _: return 404;
+ case RemoteServiceUnavailableException _: return 502;
+ default: return 500;
}
-
- var exceptionType = ex.GetType();
-
- if (!_mapExceptionToStatusCode.TryGetValue(exceptionType, out var statusCode))
- {
- if (ex is DirectoryNotFoundException)
- {
- statusCode = 404;
- }
- else
- {
- statusCode = 500;
- }
- }
-
- return statusCode;
}
private async Task ErrorHandler(Exception ex, IRequest httpReq, bool logExceptionStackTrace, bool logExceptionMessage)
@@ -310,29 +291,22 @@ namespace Emby.Server.Implementations.HttpServer
}
}
- private readonly Dictionary _skipLogExtensions = new Dictionary(StringComparer.OrdinalIgnoreCase)
+ private static readonly string[] _skipLogExtensions =
{
- {".js", 0},
- {".css", 0},
- {".woff", 0},
- {".woff2", 0},
- {".ttf", 0},
- {".html", 0}
+ ".js",
+ ".css",
+ ".woff",
+ ".woff2",
+ ".ttf",
+ ".html"
};
private bool EnableLogging(string url, string localPath)
{
var extension = GetExtension(url);
- if (string.IsNullOrEmpty(extension) || !_skipLogExtensions.ContainsKey(extension))
- {
- if (string.IsNullOrEmpty(localPath) || localPath.IndexOf("system/ping", StringComparison.OrdinalIgnoreCase) == -1)
- {
- return true;
- }
- }
-
- return false;
+ return ((string.IsNullOrEmpty(extension) || !_skipLogExtensions.Contains(extension))
+ && (string.IsNullOrEmpty(localPath) || localPath.IndexOf("system/ping", StringComparison.OrdinalIgnoreCase) == -1));
}
private static string GetExtension(string url)
@@ -555,9 +529,7 @@ namespace Emby.Server.Implementations.HttpServer
return;
}
- if (string.Equals(localPath, "/mediabrowser/", StringComparison.OrdinalIgnoreCase) ||
- string.Equals(localPath, "/mediabrowser", StringComparison.OrdinalIgnoreCase) ||
- localPath.IndexOf("mediabrowser/web", StringComparison.OrdinalIgnoreCase) != -1)
+ if (localPath.IndexOf("mediabrowser/web", StringComparison.OrdinalIgnoreCase) != -1)
{
httpRes.StatusCode = 200;
httpRes.ContentType = "text/html";
@@ -711,7 +683,7 @@ namespace Emby.Server.Implementations.HttpServer
};
}
- _logger.LogError("Could not find handler for {pathInfo}", pathInfo);
+ _logger.LogError("Could not find handler for {PathInfo}", pathInfo);
return null;
}
@@ -725,13 +697,13 @@ namespace Emby.Server.Implementations.HttpServer
private void RedirectToSecureUrl(IHttpRequest httpReq, IResponse httpRes, string url)
{
- int currentPort;
- if (Uri.TryCreate(url, UriKind.Absolute, out var uri))
+ if (Uri.TryCreate(url, UriKind.Absolute, out Uri uri))
{
- currentPort = uri.Port;
- var builder = new UriBuilder(uri);
- builder.Port = _config.Configuration.PublicHttpsPort;
- builder.Scheme = "https";
+ var builder = new UriBuilder(uri)
+ {
+ Port = _config.Configuration.PublicHttpsPort,
+ Scheme = "https"
+ };
url = builder.Uri.ToString();
RedirectToUrl(httpRes, url);
@@ -831,12 +803,6 @@ namespace Emby.Server.Implementations.HttpServer
public Task