diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs
index 41ca2a1025..9804f28cf3 100644
--- a/Emby.Server.Implementations/ApplicationHost.cs
+++ b/Emby.Server.Implementations/ApplicationHost.cs
@@ -620,8 +620,6 @@ namespace Emby.Server.Implementations
DiscoverTypes();
- SetHttpLimit();
-
await RegisterResources(serviceCollection).ConfigureAwait(false);
FindParts();
@@ -918,8 +916,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 +926,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;
@@ -1539,6 +1523,7 @@ namespace Emby.Server.Implementations
{
Logger.LogError(ex, "Error getting WAN Ip address information");
}
+
return null;
}
@@ -1841,24 +1826,6 @@ namespace Emby.Server.Implementations
{
}
- ///
- /// Called when [application updated].
- ///
- /// The package.
- protected void OnApplicationUpdated(PackageVersionInfo package)
- {
- Logger.LogInformation("Application has been updated to version {0}", package.versionStr);
-
- ApplicationUpdated?.Invoke(
- this,
- new GenericEventArgs()
- {
- Argument = package
- });
-
- NotifyPendingRestart();
- }
-
private bool _disposed = false;
///
diff --git a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs
index e8d47cad52..79b8f52d78 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 GetRequestFilterAttributes(Type requestDtoType)
{
- var attributes = requestDtoType.GetTypeInfo().GetCustomAttributes(true).OfType().ToList();
+ var attributes = requestDtoType.GetCustomAttributes(true).OfType().ToList();
var serviceType = GetServiceTypeByRequest(requestDtoType);
if (serviceType != null)
{
- attributes.AddRange(serviceType.GetTypeInfo().GetCustomAttributes(true).OfType());
+ attributes.AddRange(serviceType.GetCustomAttributes(true).OfType());
}
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(connection));
}
- private void Connection_Closed(object sender, EventArgs e)
+ private void OnConnectionClosed(object sender, EventArgs e)
{
lock (_webSocketConnections)
{
@@ -322,14 +320,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 +397,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 +570,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 +611,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);
@@ -655,11 +643,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 +667,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[]
diff --git a/Emby.Server.Implementations/Services/ServiceController.cs b/Emby.Server.Implementations/Services/ServiceController.cs
index 5796956d87..5e3d529c68 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