From ab10f210274ff46bf68b5af752a817bbd90f749a Mon Sep 17 00:00:00 2001 From: BaronGreenback Date: Sun, 5 Jul 2020 17:47:23 +0100 Subject: [PATCH 01/20] Part 1 of a multi-PR change for Emby.DLNA --- .../ApplicationHost.cs | 40 ++++++++++++++++++- .../HttpServer/HttpListenerHost.cs | 5 +++ .../Services/ServiceController.cs | 4 +- MediaBrowser.Common/IApplicationHost.cs | 8 ++++ 4 files changed, 54 insertions(+), 3 deletions(-) diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index 18b6834ef..f10ebdd01 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -351,6 +351,42 @@ namespace Emby.Server.Implementations public object CreateInstance(Type type) => ActivatorUtilities.CreateInstance(ServiceProvider, type); + /// + /// Creates an instance of type and resolves all constructor dependencies. + /// + /// The type. + /// Additional argument for the constructor. + /// + public object CreateInstance(Type type, object parameter) + { + ConstructorInfo constructor = type.GetConstructors()[0]; + if (constructor != null) + { + ParameterInfo[] argInfo = constructor + .GetParameters(); + + object[] args = argInfo + .Select(o => o.ParameterType) + .Select(o => ServiceProvider.GetService(o)) + .ToArray(); + + if (parameter != null) + { + // Assumption is that the is always the last in the constructor's parameter list. + int argsLen = args.Length; + var argType = argInfo[argsLen - 1].ParameterType; + var paramType = parameter.GetType(); + if (argType.IsAssignableFrom(paramType) || argType == paramType) + { + args[argsLen - 1] = parameter; + return ActivatorUtilities.CreateInstance(ServiceProvider, type, args); + } + } + } + + return ActivatorUtilities.CreateInstance(ServiceProvider, type); + } + /// /// Creates an instance of type and resolves all constructor dependencies. /// @@ -566,8 +602,10 @@ namespace Emby.Server.Implementations serviceCollection.AddTransient(provider => new Lazy(provider.GetRequiredService)); // TODO: Refactor to eliminate the circular dependency here so that Lazy isn't required + // TODO: Add StartupOptions.FFmpegPath to IConfiguration and remove this custom activation serviceCollection.AddTransient(provider => new Lazy(provider.GetRequiredService)); - serviceCollection.AddSingleton(); + serviceCollection.AddSingleton(provider => + ActivatorUtilities.CreateInstance(provider, _startupOptions.FFmpegPath ?? string.Empty)); // TODO: Refactor to eliminate the circular dependencies here so that Lazy isn't required serviceCollection.AddTransient(provider => new Lazy(provider.GetRequiredService)); diff --git a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs index c3428ee62..6860b7ecd 100644 --- a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs +++ b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs @@ -107,6 +107,11 @@ namespace Emby.Server.Implementations.HttpServer return _appHost.CreateInstance(type); } + public object CreateInstance(Type type, object parameter) + { + return _appHost.CreateInstance(type, parameter); + } + private static string NormalizeUrlPath(string path) { if (path.Length > 0 && path[0] == '/') diff --git a/Emby.Server.Implementations/Services/ServiceController.cs b/Emby.Server.Implementations/Services/ServiceController.cs index 857df591a..2a780feb5 100644 --- a/Emby.Server.Implementations/Services/ServiceController.cs +++ b/Emby.Server.Implementations/Services/ServiceController.cs @@ -177,8 +177,8 @@ namespace Emby.Server.Implementations.Services var serviceType = httpHost.GetServiceTypeByRequest(requestType); - var service = httpHost.CreateInstance(serviceType); - + var service = httpHost.CreateInstance(serviceType, req); + var serviceRequiresContext = service as IRequiresRequest; if (serviceRequiresContext != null) { diff --git a/MediaBrowser.Common/IApplicationHost.cs b/MediaBrowser.Common/IApplicationHost.cs index e8d9282e4..cf4954eef 100644 --- a/MediaBrowser.Common/IApplicationHost.cs +++ b/MediaBrowser.Common/IApplicationHost.cs @@ -125,5 +125,13 @@ namespace MediaBrowser.Common /// The type. /// System.Object. object CreateInstance(Type type); + + /// + /// Creates a new instance of a class. + /// + /// The type to create. + /// An addtional parameter. + /// Created instance. + object CreateInstance(Type type, object parameter); } } From 70c638d1d48178bc1458fe86a48b2b60b06b7171 Mon Sep 17 00:00:00 2001 From: BaronGreenback Date: Sun, 5 Jul 2020 18:12:56 +0100 Subject: [PATCH 02/20] Updated code as per jellyfin/master as version i amended didn't execute. --- Emby.Server.Implementations/ApplicationHost.cs | 3 +-- Emby.Server.Implementations/Services/ServiceController.cs | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index f10ebdd01..4d99bd759 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -604,8 +604,7 @@ namespace Emby.Server.Implementations // TODO: Refactor to eliminate the circular dependency here so that Lazy isn't required // TODO: Add StartupOptions.FFmpegPath to IConfiguration and remove this custom activation serviceCollection.AddTransient(provider => new Lazy(provider.GetRequiredService)); - serviceCollection.AddSingleton(provider => - ActivatorUtilities.CreateInstance(provider, _startupOptions.FFmpegPath ?? string.Empty)); + serviceCollection.AddSingleton(); // TODO: Refactor to eliminate the circular dependencies here so that Lazy isn't required serviceCollection.AddTransient(provider => new Lazy(provider.GetRequiredService)); diff --git a/Emby.Server.Implementations/Services/ServiceController.cs b/Emby.Server.Implementations/Services/ServiceController.cs index 2a780feb5..b1f2a6827 100644 --- a/Emby.Server.Implementations/Services/ServiceController.cs +++ b/Emby.Server.Implementations/Services/ServiceController.cs @@ -178,7 +178,7 @@ namespace Emby.Server.Implementations.Services var serviceType = httpHost.GetServiceTypeByRequest(requestType); var service = httpHost.CreateInstance(serviceType, req); - + var serviceRequiresContext = service as IRequiresRequest; if (serviceRequiresContext != null) { @@ -189,5 +189,4 @@ namespace Emby.Server.Implementations.Services return ServiceExecGeneral.Execute(serviceType, req, service, requestDto, requestType.GetMethodName()); } } - } From 31ffd00dbd547c42db93df07ab9b1c87034bab13 Mon Sep 17 00:00:00 2001 From: BaronGreenback Date: Fri, 17 Jul 2020 12:51:55 +0100 Subject: [PATCH 03/20] Update ApplicationHost.cs --- .../ApplicationHost.cs | 36 ------------------- 1 file changed, 36 deletions(-) diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index 4d99bd759..8d213ac57 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -351,42 +351,6 @@ namespace Emby.Server.Implementations public object CreateInstance(Type type) => ActivatorUtilities.CreateInstance(ServiceProvider, type); - /// - /// Creates an instance of type and resolves all constructor dependencies. - /// - /// The type. - /// Additional argument for the constructor. - /// - public object CreateInstance(Type type, object parameter) - { - ConstructorInfo constructor = type.GetConstructors()[0]; - if (constructor != null) - { - ParameterInfo[] argInfo = constructor - .GetParameters(); - - object[] args = argInfo - .Select(o => o.ParameterType) - .Select(o => ServiceProvider.GetService(o)) - .ToArray(); - - if (parameter != null) - { - // Assumption is that the is always the last in the constructor's parameter list. - int argsLen = args.Length; - var argType = argInfo[argsLen - 1].ParameterType; - var paramType = parameter.GetType(); - if (argType.IsAssignableFrom(paramType) || argType == paramType) - { - args[argsLen - 1] = parameter; - return ActivatorUtilities.CreateInstance(ServiceProvider, type, args); - } - } - } - - return ActivatorUtilities.CreateInstance(ServiceProvider, type); - } - /// /// Creates an instance of type and resolves all constructor dependencies. /// From 02d3bb758866b7707971b282e40529e196a42880 Mon Sep 17 00:00:00 2001 From: BaronGreenback Date: Fri, 17 Jul 2020 12:53:20 +0100 Subject: [PATCH 04/20] Update ApplicationHost.cs --- Emby.Server.Implementations/ApplicationHost.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index 8d213ac57..18b6834ef 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -566,7 +566,6 @@ namespace Emby.Server.Implementations serviceCollection.AddTransient(provider => new Lazy(provider.GetRequiredService)); // TODO: Refactor to eliminate the circular dependency here so that Lazy isn't required - // TODO: Add StartupOptions.FFmpegPath to IConfiguration and remove this custom activation serviceCollection.AddTransient(provider => new Lazy(provider.GetRequiredService)); serviceCollection.AddSingleton(); From a44309f56f300cfc670ca2fb62e93f5571aac66a Mon Sep 17 00:00:00 2001 From: BaronGreenback Date: Fri, 17 Jul 2020 12:53:50 +0100 Subject: [PATCH 05/20] Update HttpListenerHost.cs --- Emby.Server.Implementations/HttpServer/HttpListenerHost.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs index 6860b7ecd..7c0d06fb2 100644 --- a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs +++ b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs @@ -106,12 +106,7 @@ namespace Emby.Server.Implementations.HttpServer { return _appHost.CreateInstance(type); } - - public object CreateInstance(Type type, object parameter) - { - return _appHost.CreateInstance(type, parameter); - } - + private static string NormalizeUrlPath(string path) { if (path.Length > 0 && path[0] == '/') From 7cd4ae3b6e5d1d921132b55e46d3db4f3aefe59f Mon Sep 17 00:00:00 2001 From: BaronGreenback Date: Fri, 17 Jul 2020 12:54:13 +0100 Subject: [PATCH 06/20] Update HttpListenerHost.cs --- Emby.Server.Implementations/HttpServer/HttpListenerHost.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs index 7c0d06fb2..c3428ee62 100644 --- a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs +++ b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs @@ -106,7 +106,7 @@ namespace Emby.Server.Implementations.HttpServer { return _appHost.CreateInstance(type); } - + private static string NormalizeUrlPath(string path) { if (path.Length > 0 && path[0] == '/') From 912847ae8c9bf1bc951a0d1d293c05b9ff06bb0a Mon Sep 17 00:00:00 2001 From: BaronGreenback Date: Fri, 17 Jul 2020 12:54:28 +0100 Subject: [PATCH 07/20] Update ServiceController.cs --- Emby.Server.Implementations/Services/ServiceController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Emby.Server.Implementations/Services/ServiceController.cs b/Emby.Server.Implementations/Services/ServiceController.cs index b1f2a6827..d884d4f37 100644 --- a/Emby.Server.Implementations/Services/ServiceController.cs +++ b/Emby.Server.Implementations/Services/ServiceController.cs @@ -177,7 +177,7 @@ namespace Emby.Server.Implementations.Services var serviceType = httpHost.GetServiceTypeByRequest(requestType); - var service = httpHost.CreateInstance(serviceType, req); + var service = httpHost.CreateInstance(serviceType); var serviceRequiresContext = service as IRequiresRequest; if (serviceRequiresContext != null) From e33c6f6b29add0d5d19cf9d1607d9afd59151a2a Mon Sep 17 00:00:00 2001 From: BaronGreenback Date: Fri, 17 Jul 2020 12:54:55 +0100 Subject: [PATCH 08/20] Update IApplicationHost.cs --- MediaBrowser.Common/IApplicationHost.cs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/MediaBrowser.Common/IApplicationHost.cs b/MediaBrowser.Common/IApplicationHost.cs index cf4954eef..e8d9282e4 100644 --- a/MediaBrowser.Common/IApplicationHost.cs +++ b/MediaBrowser.Common/IApplicationHost.cs @@ -125,13 +125,5 @@ namespace MediaBrowser.Common /// The type. /// System.Object. object CreateInstance(Type type); - - /// - /// Creates a new instance of a class. - /// - /// The type to create. - /// An addtional parameter. - /// Created instance. - object CreateInstance(Type type, object parameter); } } From 06beecc4f84971c75f4b1f015dd5ed74a55fe5df Mon Sep 17 00:00:00 2001 From: BaronGreenback Date: Fri, 17 Jul 2020 12:56:52 +0100 Subject: [PATCH 09/20] Update ServiceHandler.cs --- Emby.Server.Implementations/Services/ServiceHandler.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Emby.Server.Implementations/Services/ServiceHandler.cs b/Emby.Server.Implementations/Services/ServiceHandler.cs index a42f88ea0..c544c86f5 100644 --- a/Emby.Server.Implementations/Services/ServiceHandler.cs +++ b/Emby.Server.Implementations/Services/ServiceHandler.cs @@ -78,7 +78,8 @@ namespace Emby.Server.Implementations.Services var request = await CreateRequest(httpHost, httpReq, _restPath, logger).ConfigureAwait(false); httpHost.ApplyRequestFilters(httpReq, httpRes, request); - + + httpRes.HttpContext.Items["ServiceStackRequest"] = httpReq; var response = await httpHost.ServiceController.Execute(httpHost, request, httpReq).ConfigureAwait(false); // Apply response filters From d9f94129555d3360eac4f18fe15fdb59c65a83d5 Mon Sep 17 00:00:00 2001 From: BaronGreenback Date: Fri, 17 Jul 2020 12:58:23 +0100 Subject: [PATCH 10/20] Update DlnaServerService.cs --- Emby.Dlna/Api/DlnaServerService.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Emby.Dlna/Api/DlnaServerService.cs b/Emby.Dlna/Api/DlnaServerService.cs index 7fba2184a..167996eeb 100644 --- a/Emby.Dlna/Api/DlnaServerService.cs +++ b/Emby.Dlna/Api/DlnaServerService.cs @@ -127,11 +127,14 @@ namespace Emby.Dlna.Api public DlnaServerService( IDlnaManager dlnaManager, IHttpResultFactory httpResultFactory, - IServerConfigurationManager configurationManager) + IServerConfigurationManager configurationManager, + IHttpContextAccessor httpContextAccessor) { _dlnaManager = dlnaManager; _resultFactory = httpResultFactory; _configurationManager = configurationManager; + object request = httpContextAccessor?.HttpContext.Items["ServiceStackRequest"] ?? throw new ArgumentNullException(nameof(httpContextAccessor)); + Request = (IRequest)request; } private string GetHeader(string name) From 62eb1b1a388f95d2b8a88941c8d064fa09b6990f Mon Sep 17 00:00:00 2001 From: BaronGreenback Date: Fri, 17 Jul 2020 12:59:16 +0100 Subject: [PATCH 11/20] Update ServiceController.cs From fd2f18899b8ea4db5152d98d9822d6cff6d7d892 Mon Sep 17 00:00:00 2001 From: BaronGreenback Date: Fri, 17 Jul 2020 16:06:32 +0100 Subject: [PATCH 12/20] Update ServiceHandler.cs --- Emby.Server.Implementations/Services/ServiceHandler.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Emby.Server.Implementations/Services/ServiceHandler.cs b/Emby.Server.Implementations/Services/ServiceHandler.cs index c544c86f5..3997a5ddb 100644 --- a/Emby.Server.Implementations/Services/ServiceHandler.cs +++ b/Emby.Server.Implementations/Services/ServiceHandler.cs @@ -79,7 +79,7 @@ namespace Emby.Server.Implementations.Services httpHost.ApplyRequestFilters(httpReq, httpRes, request); - httpRes.HttpContext.Items["ServiceStackRequest"] = httpReq; + httpRes.HttpContext.SetServiceStackRequest(httpReq); var response = await httpHost.ServiceController.Execute(httpHost, request, httpReq).ConfigureAwait(false); // Apply response filters From 24c1776ff61481b85b016cc0fcfef0a319589fdc Mon Sep 17 00:00:00 2001 From: BaronGreenback Date: Fri, 17 Jul 2020 16:06:52 +0100 Subject: [PATCH 13/20] Add files via upload --- .../Services/HttpContextExtension.cs | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Emby.Server.Implementations/Services/HttpContextExtension.cs diff --git a/Emby.Server.Implementations/Services/HttpContextExtension.cs b/Emby.Server.Implementations/Services/HttpContextExtension.cs new file mode 100644 index 000000000..6d3a600ab --- /dev/null +++ b/Emby.Server.Implementations/Services/HttpContextExtension.cs @@ -0,0 +1,33 @@ +using MediaBrowser.Model.Services; +using Microsoft.AspNetCore.Http; + +namespace Emby.Server.Implementations.Services +{ + /// + /// Extention to enable the service stack request to be stored in the HttpRequest object. + /// + public static class HttpContextExtension + { + private const string SERVICESTACKREQUEST = "ServiceRequestStack"; + + /// + /// Set the service stack request. + /// + /// The HttpContext instance. + /// The IRequest instance. + public static void SetServiceStackRequest(this HttpContext httpContext, IRequest request) + { + httpContext.Items[SERVICESTACKREQUEST] = request; + } + + /// + /// Get the service stack request. + /// + /// The HttpContext instance. + /// The service stack request instance. + public static IRequest GetServiceStack(this HttpContext httpContext) + { + return (IRequest)httpContext.Items[SERVICESTACKREQUEST]; + } + } +} From c7c28db17beaf67be68feb769e88ac5bf14dc534 Mon Sep 17 00:00:00 2001 From: BaronGreenback Date: Fri, 17 Jul 2020 16:08:26 +0100 Subject: [PATCH 14/20] Update DlnaServerService.cs --- Emby.Dlna/Api/DlnaServerService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Emby.Dlna/Api/DlnaServerService.cs b/Emby.Dlna/Api/DlnaServerService.cs index 167996eeb..049b201bb 100644 --- a/Emby.Dlna/Api/DlnaServerService.cs +++ b/Emby.Dlna/Api/DlnaServerService.cs @@ -108,7 +108,7 @@ namespace Emby.Dlna.Api public string Filename { get; set; } } - public class DlnaServerService : IService, IRequiresRequest + public class DlnaServerService : IService { private const string XMLContentType = "text/xml; charset=UTF-8"; From 0f696104aca3309145b2e7f4169c4cf1be8ad81a Mon Sep 17 00:00:00 2001 From: BaronGreenback Date: Fri, 17 Jul 2020 16:23:12 +0100 Subject: [PATCH 15/20] using missing. --- Emby.Dlna/Api/DlnaServerService.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Emby.Dlna/Api/DlnaServerService.cs b/Emby.Dlna/Api/DlnaServerService.cs index 049b201bb..7e5eb8f90 100644 --- a/Emby.Dlna/Api/DlnaServerService.cs +++ b/Emby.Dlna/Api/DlnaServerService.cs @@ -11,6 +11,7 @@ using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Dlna; using MediaBrowser.Controller.Net; using MediaBrowser.Model.Services; +using Microsoft.AspNetCore.Http; namespace Emby.Dlna.Api { From f9b0816b80793965ef044f6871a7ffd80e91d303 Mon Sep 17 00:00:00 2001 From: BaronGreenback Date: Sat, 18 Jul 2020 16:54:23 +0100 Subject: [PATCH 16/20] Changes a suggested. --- Emby.Dlna/Api/DlnaServerService.cs | 3 +-- .../Services/ServiceHandler.cs | 1 + .../Extensions/HttpContextExtensions.cs | 13 +++++++------ 3 files changed, 9 insertions(+), 8 deletions(-) rename Emby.Server.Implementations/Services/HttpContextExtension.cs => MediaBrowser.Common/Extensions/HttpContextExtensions.cs (68%) diff --git a/Emby.Dlna/Api/DlnaServerService.cs b/Emby.Dlna/Api/DlnaServerService.cs index 7e5eb8f90..a61a8d5ab 100644 --- a/Emby.Dlna/Api/DlnaServerService.cs +++ b/Emby.Dlna/Api/DlnaServerService.cs @@ -134,8 +134,7 @@ namespace Emby.Dlna.Api _dlnaManager = dlnaManager; _resultFactory = httpResultFactory; _configurationManager = configurationManager; - object request = httpContextAccessor?.HttpContext.Items["ServiceStackRequest"] ?? throw new ArgumentNullException(nameof(httpContextAccessor)); - Request = (IRequest)request; + Request = httpContextAccessor?.HttpContext.GetServiceStack() ?? throw new ArgumentNullException(nameof(httpContextAccessor)); } private string GetHeader(string name) diff --git a/Emby.Server.Implementations/Services/ServiceHandler.cs b/Emby.Server.Implementations/Services/ServiceHandler.cs index 3997a5ddb..3d4e1ca77 100644 --- a/Emby.Server.Implementations/Services/ServiceHandler.cs +++ b/Emby.Server.Implementations/Services/ServiceHandler.cs @@ -6,6 +6,7 @@ using System.Reflection; using System.Threading; using System.Threading.Tasks; using Emby.Server.Implementations.HttpServer; +using MediaBrowser.Common.Extensions; using MediaBrowser.Model.Services; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; diff --git a/Emby.Server.Implementations/Services/HttpContextExtension.cs b/MediaBrowser.Common/Extensions/HttpContextExtensions.cs similarity index 68% rename from Emby.Server.Implementations/Services/HttpContextExtension.cs rename to MediaBrowser.Common/Extensions/HttpContextExtensions.cs index 6d3a600ab..4bab42cc1 100644 --- a/Emby.Server.Implementations/Services/HttpContextExtension.cs +++ b/MediaBrowser.Common/Extensions/HttpContextExtensions.cs @@ -1,27 +1,28 @@ using MediaBrowser.Model.Services; using Microsoft.AspNetCore.Http; -namespace Emby.Server.Implementations.Services +namespace MediaBrowser.Common.Extensions { /// /// Extention to enable the service stack request to be stored in the HttpRequest object. + /// Static class containing extension methods for . /// - public static class HttpContextExtension + public static class HttpContextExtensions { - private const string SERVICESTACKREQUEST = "ServiceRequestStack"; + private const string SERVICESTACKREQUEST = "ServiceStackRequest"; /// - /// Set the service stack request. + /// Set the ServiceStack request. /// /// The HttpContext instance. - /// The IRequest instance. + /// The service stack request instance. public static void SetServiceStackRequest(this HttpContext httpContext, IRequest request) { httpContext.Items[SERVICESTACKREQUEST] = request; } /// - /// Get the service stack request. + /// Get the ServiceStack request. /// /// The HttpContext instance. /// The service stack request instance. From 69ba385782338723a83a2a107857f315ab014f79 Mon Sep 17 00:00:00 2001 From: BaronGreenback Date: Sat, 18 Jul 2020 16:55:46 +0100 Subject: [PATCH 17/20] Corrected comment --- MediaBrowser.Common/Extensions/HttpContextExtensions.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/MediaBrowser.Common/Extensions/HttpContextExtensions.cs b/MediaBrowser.Common/Extensions/HttpContextExtensions.cs index 4bab42cc1..142935c1a 100644 --- a/MediaBrowser.Common/Extensions/HttpContextExtensions.cs +++ b/MediaBrowser.Common/Extensions/HttpContextExtensions.cs @@ -4,7 +4,6 @@ using Microsoft.AspNetCore.Http; namespace MediaBrowser.Common.Extensions { /// - /// Extention to enable the service stack request to be stored in the HttpRequest object. /// Static class containing extension methods for . /// public static class HttpContextExtensions From 672a35db94b147fc1479a4815f07b119f6a670b6 Mon Sep 17 00:00:00 2001 From: BaronGreenback Date: Sun, 19 Jul 2020 17:54:09 +0100 Subject: [PATCH 18/20] Update DlnaServerService.cs --- Emby.Dlna/Api/DlnaServerService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Emby.Dlna/Api/DlnaServerService.cs b/Emby.Dlna/Api/DlnaServerService.cs index a61a8d5ab..d9c1669b0 100644 --- a/Emby.Dlna/Api/DlnaServerService.cs +++ b/Emby.Dlna/Api/DlnaServerService.cs @@ -134,7 +134,7 @@ namespace Emby.Dlna.Api _dlnaManager = dlnaManager; _resultFactory = httpResultFactory; _configurationManager = configurationManager; - Request = httpContextAccessor?.HttpContext.GetServiceStack() ?? throw new ArgumentNullException(nameof(httpContextAccessor)); + Request = httpContextAccessor?.HttpContext.GetServiceStackRequest() ?? throw new ArgumentNullException(nameof(httpContextAccessor)); } private string GetHeader(string name) From 7becef73df136e3373d75ebdaa071da3aaf0d0da Mon Sep 17 00:00:00 2001 From: BaronGreenback Date: Sun, 19 Jul 2020 17:54:29 +0100 Subject: [PATCH 19/20] Update MediaBrowser.Common/Extensions/HttpContextExtensions.cs Co-authored-by: Mark Monteiro --- MediaBrowser.Common/Extensions/HttpContextExtensions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MediaBrowser.Common/Extensions/HttpContextExtensions.cs b/MediaBrowser.Common/Extensions/HttpContextExtensions.cs index 142935c1a..da14ebac6 100644 --- a/MediaBrowser.Common/Extensions/HttpContextExtensions.cs +++ b/MediaBrowser.Common/Extensions/HttpContextExtensions.cs @@ -25,7 +25,7 @@ namespace MediaBrowser.Common.Extensions /// /// The HttpContext instance. /// The service stack request instance. - public static IRequest GetServiceStack(this HttpContext httpContext) + public static IRequest GetServiceStackRequest(this HttpContext httpContext) { return (IRequest)httpContext.Items[SERVICESTACKREQUEST]; } From 301ddc1dacb1f7a8c67c62e1ebeeb9badc478bb8 Mon Sep 17 00:00:00 2001 From: BaronGreenback Date: Sun, 19 Jul 2020 22:19:17 +0100 Subject: [PATCH 20/20] Update HttpContextExtensions.cs --- MediaBrowser.Common/Extensions/HttpContextExtensions.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MediaBrowser.Common/Extensions/HttpContextExtensions.cs b/MediaBrowser.Common/Extensions/HttpContextExtensions.cs index da14ebac6..d746207c7 100644 --- a/MediaBrowser.Common/Extensions/HttpContextExtensions.cs +++ b/MediaBrowser.Common/Extensions/HttpContextExtensions.cs @@ -8,7 +8,7 @@ namespace MediaBrowser.Common.Extensions /// public static class HttpContextExtensions { - private const string SERVICESTACKREQUEST = "ServiceStackRequest"; + private const string ServiceStackRequest = "ServiceStackRequest"; /// /// Set the ServiceStack request. @@ -17,7 +17,7 @@ namespace MediaBrowser.Common.Extensions /// The service stack request instance. public static void SetServiceStackRequest(this HttpContext httpContext, IRequest request) { - httpContext.Items[SERVICESTACKREQUEST] = request; + httpContext.Items[ServiceStackRequest] = request; } /// @@ -27,7 +27,7 @@ namespace MediaBrowser.Common.Extensions /// The service stack request instance. public static IRequest GetServiceStackRequest(this HttpContext httpContext) { - return (IRequest)httpContext.Items[SERVICESTACKREQUEST]; + return (IRequest)httpContext.Items[ServiceStackRequest]; } } }