Merge pull request #3508 from BaronGreenback/nullable
Part 1: nullable Emby.DLNA
This commit is contained in:
commit
89ff865d40
|
@ -11,6 +11,7 @@ using MediaBrowser.Controller.Configuration;
|
||||||
using MediaBrowser.Controller.Dlna;
|
using MediaBrowser.Controller.Dlna;
|
||||||
using MediaBrowser.Controller.Net;
|
using MediaBrowser.Controller.Net;
|
||||||
using MediaBrowser.Model.Services;
|
using MediaBrowser.Model.Services;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
|
||||||
namespace Emby.Dlna.Api
|
namespace Emby.Dlna.Api
|
||||||
{
|
{
|
||||||
|
@ -108,7 +109,7 @@ namespace Emby.Dlna.Api
|
||||||
public string Filename { get; set; }
|
public string Filename { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DlnaServerService : IService, IRequiresRequest
|
public class DlnaServerService : IService
|
||||||
{
|
{
|
||||||
private const string XMLContentType = "text/xml; charset=UTF-8";
|
private const string XMLContentType = "text/xml; charset=UTF-8";
|
||||||
|
|
||||||
|
@ -127,11 +128,13 @@ namespace Emby.Dlna.Api
|
||||||
public DlnaServerService(
|
public DlnaServerService(
|
||||||
IDlnaManager dlnaManager,
|
IDlnaManager dlnaManager,
|
||||||
IHttpResultFactory httpResultFactory,
|
IHttpResultFactory httpResultFactory,
|
||||||
IServerConfigurationManager configurationManager)
|
IServerConfigurationManager configurationManager,
|
||||||
|
IHttpContextAccessor httpContextAccessor)
|
||||||
{
|
{
|
||||||
_dlnaManager = dlnaManager;
|
_dlnaManager = dlnaManager;
|
||||||
_resultFactory = httpResultFactory;
|
_resultFactory = httpResultFactory;
|
||||||
_configurationManager = configurationManager;
|
_configurationManager = configurationManager;
|
||||||
|
Request = httpContextAccessor?.HttpContext.GetServiceStackRequest() ?? throw new ArgumentNullException(nameof(httpContextAccessor));
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetHeader(string name)
|
private string GetHeader(string name)
|
||||||
|
|
|
@ -189,5 +189,4 @@ namespace Emby.Server.Implementations.Services
|
||||||
return ServiceExecGeneral.Execute(serviceType, req, service, requestDto, requestType.GetMethodName());
|
return ServiceExecGeneral.Execute(serviceType, req, service, requestDto, requestType.GetMethodName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ using System.Reflection;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Emby.Server.Implementations.HttpServer;
|
using Emby.Server.Implementations.HttpServer;
|
||||||
|
using MediaBrowser.Common.Extensions;
|
||||||
using MediaBrowser.Model.Services;
|
using MediaBrowser.Model.Services;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
@ -79,6 +80,7 @@ namespace Emby.Server.Implementations.Services
|
||||||
|
|
||||||
httpHost.ApplyRequestFilters(httpReq, httpRes, request);
|
httpHost.ApplyRequestFilters(httpReq, httpRes, request);
|
||||||
|
|
||||||
|
httpRes.HttpContext.SetServiceStackRequest(httpReq);
|
||||||
var response = await httpHost.ServiceController.Execute(httpHost, request, httpReq).ConfigureAwait(false);
|
var response = await httpHost.ServiceController.Execute(httpHost, request, httpReq).ConfigureAwait(false);
|
||||||
|
|
||||||
// Apply response filters
|
// Apply response filters
|
||||||
|
|
33
MediaBrowser.Common/Extensions/HttpContextExtensions.cs
Normal file
33
MediaBrowser.Common/Extensions/HttpContextExtensions.cs
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
using MediaBrowser.Model.Services;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
|
||||||
|
namespace MediaBrowser.Common.Extensions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Static class containing extension methods for <see cref="HttpContext"/>.
|
||||||
|
/// </summary>
|
||||||
|
public static class HttpContextExtensions
|
||||||
|
{
|
||||||
|
private const string ServiceStackRequest = "ServiceStackRequest";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set the ServiceStack request.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="httpContext">The HttpContext instance.</param>
|
||||||
|
/// <param name="request">The service stack request instance.</param>
|
||||||
|
public static void SetServiceStackRequest(this HttpContext httpContext, IRequest request)
|
||||||
|
{
|
||||||
|
httpContext.Items[ServiceStackRequest] = request;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the ServiceStack request.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="httpContext">The HttpContext instance.</param>
|
||||||
|
/// <returns>The service stack request instance.</returns>
|
||||||
|
public static IRequest GetServiceStackRequest(this HttpContext httpContext)
|
||||||
|
{
|
||||||
|
return (IRequest)httpContext.Items[ServiceStackRequest];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user