pull/702/head
Luke Pulverenti 8 years ago
parent a8b340cbb2
commit e8c70da2b6

@ -29,8 +29,9 @@ namespace Emby.Server.Implementations.HttpServer.SocketSharp
private readonly ICryptoProvider _cryptoProvider;
private readonly IStreamFactory _streamFactory;
private readonly Func<HttpListenerContext, IHttpRequest> _httpRequestFactory;
private readonly bool _enableDualMode;
public WebSocketSharpListener(ILogger logger, ICertificate certificate, IMemoryStreamFactory memoryStreamProvider, ITextEncoding textEncoding, INetworkManager networkManager, ISocketFactory socketFactory, ICryptoProvider cryptoProvider, IStreamFactory streamFactory, Func<HttpListenerContext, IHttpRequest> httpRequestFactory)
public WebSocketSharpListener(ILogger logger, ICertificate certificate, IMemoryStreamFactory memoryStreamProvider, ITextEncoding textEncoding, INetworkManager networkManager, ISocketFactory socketFactory, ICryptoProvider cryptoProvider, IStreamFactory streamFactory, bool enableDualMode, Func<HttpListenerContext, IHttpRequest> httpRequestFactory)
{
_logger = logger;
_certificate = certificate;
@ -40,6 +41,7 @@ namespace Emby.Server.Implementations.HttpServer.SocketSharp
_socketFactory = socketFactory;
_cryptoProvider = cryptoProvider;
_streamFactory = streamFactory;
_enableDualMode = enableDualMode;
_httpRequestFactory = httpRequestFactory;
}
@ -55,6 +57,8 @@ namespace Emby.Server.Implementations.HttpServer.SocketSharp
if (_listener == null)
_listener = new HttpListener(new PatternsLogger(_logger), _cryptoProvider, _streamFactory, _socketFactory, _networkManager, _textEncoding, _memoryStreamProvider);
_listener.EnableDualMode = _enableDualMode;
if (_certificate != null)
{
_listener.LoadCert(_certificate);

@ -2496,10 +2496,12 @@ namespace Emby.Server.Implementations.Library
}).OrderBy(i => i.Path).ToList();
}
private static readonly string[] ExtrasSubfolderNames = new[] { "extras", "specials", "shorts", "scenes", "featurettes", "behind the scenes", "deleted scenes" };
public IEnumerable<Video> FindExtras(BaseItem owner, List<FileSystemMetadata> fileSystemChildren, IDirectoryService directoryService)
{
var files = fileSystemChildren.Where(i => i.IsDirectory)
.Where(i => string.Equals(i.Name, "extras", StringComparison.OrdinalIgnoreCase) || string.Equals(i.Name, "specials", StringComparison.OrdinalIgnoreCase))
.Where(i => ExtrasSubfolderNames.Contains(i.Name ?? string.Empty, StringComparer.OrdinalIgnoreCase))
.SelectMany(i => _fileSystem.GetFiles(i.FullName, false))
.ToList();
@ -2788,7 +2790,7 @@ namespace Emby.Server.Implementations.Library
{
var path = Path.Combine(virtualFolderPath, collectionType + ".collection");
_fileSystem.WriteAllBytes(path, new byte[] {});
_fileSystem.WriteAllBytes(path, new byte[] { });
}
CollectionFolder.SaveLibraryOptions(virtualFolderPath, options);

@ -7,7 +7,7 @@ namespace MediaBrowser.Model.Net
public static IpAddressInfo Any = new IpAddressInfo("0.0.0.0", IpAddressFamily.InterNetwork);
public static IpAddressInfo IPv6Any = new IpAddressInfo("00000000000000000000", IpAddressFamily.InterNetworkV6);
public static IpAddressInfo Loopback = new IpAddressInfo("127.0.0.1", IpAddressFamily.InterNetwork);
public static IpAddressInfo IPv6Loopback = new IpAddressInfo("IPv6Loopback", IpAddressFamily.InterNetworkV6);
public static IpAddressInfo IPv6Loopback = new IpAddressInfo("::1", IpAddressFamily.InterNetworkV6);
public string Address { get; set; }
public IpAddressFamily AddressFamily { get; set; }

@ -106,27 +106,12 @@ namespace MediaBrowser.Server.Implementations.HttpServer
{typeof (NotSupportedException), 500}
};
HostConfig.Instance.GlobalResponseHeaders = new Dictionary<string, string>();
// The Markdown feature causes slow startup times (5 mins+) on cold boots for some users
// Custom format allows images
HostConfig.Instance.EnableFeatures = Feature.Html | Feature.Json | Feature.Xml | Feature.CustomFormat;
Container.Adapter = _containerAdapter;
//Plugins.Add(new AuthFeature(() => new AuthUserSession(), new IAuthProvider[] {
// new SessionAuthProvider(_containerAdapter.Resolve<ISessionContext>()),
//}));
//PreRequestFilters.Add((httpReq, httpRes) =>
//{
// //Handles Request and closes Responses after emitting global HTTP Headers
// if (string.Equals(httpReq.Verb, "OPTIONS", StringComparison.OrdinalIgnoreCase))
// {
// httpRes.EndRequest(); //add a 'using ServiceStack;'
// }
//});
var requestFilters = _appHost.GetExports<IRequestFilter>().ToList();
foreach (var filter in requestFilters)
{
@ -144,13 +129,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer
}
}
public override void OnAfterInit()
{
SetAppDomainData();
base.OnAfterInit();
}
public override void OnConfigLoad()
{
base.OnConfigLoad();
@ -167,23 +145,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer
return new ServiceController(this, () => types);
}
public virtual void SetAppDomainData()
{
//Required for Mono to resolve VirtualPathUtility and Url.Content urls
var domain = Thread.GetDomain(); // or AppDomain.Current
domain.SetData(".appDomain", "1");
domain.SetData(".appVPath", "/");
domain.SetData(".appPath", domain.BaseDirectory);
if (string.IsNullOrEmpty(domain.GetData(".appId") as string))
{
domain.SetData(".appId", "1");
}
if (string.IsNullOrEmpty(domain.GetData(".domainId") as string))
{
domain.SetData(".domainId", "1");
}
}
public override ServiceStackHost Start(string listeningAtUrlBase)
{
StartListener();
@ -225,7 +186,9 @@ namespace MediaBrowser.Server.Implementations.HttpServer
? GetCert(CertificatePath) :
null;
return new WebSocketSharpListener(_logger, cert, _memoryStreamProvider, _textEncoding, _networkManager, _socketFactory, _cryptoProvider, new StreamFactory(), GetRequest);
var enableDualMode = Environment.OSVersion.Platform == PlatformID.Win32NT;
return new WebSocketSharpListener(_logger, cert, _memoryStreamProvider, _textEncoding, _networkManager, _socketFactory, _cryptoProvider, new StreamFactory(), enableDualMode, GetRequest);
}
public static ICertificate GetCert(string certificateLocation)

Loading…
Cancel
Save