mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
update portable components
This commit is contained in:
parent
2c64cc7d7d
commit
01fc207b62
@ -4,7 +4,7 @@ using MediaBrowser.Model.IO;
|
|||||||
using MediaBrowser.Model.Logging;
|
using MediaBrowser.Model.Logging;
|
||||||
using MediaBrowser.Model.Serialization;
|
using MediaBrowser.Model.Serialization;
|
||||||
|
|
||||||
namespace MediaBrowser.Server.Implementations.Serialization
|
namespace Emby.Common.Implementations.Serialization
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Provides a wrapper around third party json serialization.
|
/// Provides a wrapper around third party json serialization.
|
@ -2,7 +2,7 @@
|
|||||||
"version": "1.0.0-*",
|
"version": "1.0.0-*",
|
||||||
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
"frameworks": {
|
"frameworks": {
|
||||||
@ -19,46 +19,49 @@
|
|||||||
"System.Text.Encoding": "4.0.0.0",
|
"System.Text.Encoding": "4.0.0.0",
|
||||||
"System.Threading": "4.0.0.0",
|
"System.Threading": "4.0.0.0",
|
||||||
"System.Threading.Tasks": "4.0.0.0",
|
"System.Threading.Tasks": "4.0.0.0",
|
||||||
"System.Xml.ReaderWriter": "4.0.0"
|
"System.Xml.ReaderWriter": "4.0.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"SimpleInjector": "3.2.4",
|
"SimpleInjector": "3.2.4",
|
||||||
|
"ServiceStack.Text": "4.5.4",
|
||||||
"NLog": "4.4.0-betaV15",
|
"NLog": "4.4.0-betaV15",
|
||||||
"MediaBrowser.Model": {
|
"MediaBrowser.Model": {
|
||||||
"target": "project"
|
"target": "project"
|
||||||
},
|
},
|
||||||
"MediaBrowser.Common": {
|
"MediaBrowser.Common": {
|
||||||
"target": "project"
|
"target": "project"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"netstandard1.6": {
|
"netstandard1.6": {
|
||||||
"imports": "dnxcore50",
|
"imports": "dnxcore50",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"NETStandard.Library": "1.6.0",
|
"NETStandard.Library": "1.6.0",
|
||||||
"System.IO.FileSystem.DriveInfo": "4.0.0",
|
"System.IO.FileSystem.DriveInfo": "4.0.0",
|
||||||
"System.Diagnostics.Process": "4.1.0",
|
"System.Diagnostics.Process": "4.1.0",
|
||||||
"System.Threading.Timer": "4.0.1",
|
"System.Threading.Timer": "4.0.1",
|
||||||
"System.Net.Requests": "4.0.11",
|
"System.Net.Requests": "4.0.11",
|
||||||
"System.Xml.ReaderWriter": "4.0.11",
|
"System.Xml.ReaderWriter": "4.0.11",
|
||||||
"System.Xml.XmlSerializer": "4.0.11",
|
"System.Xml.XmlSerializer": "4.0.11",
|
||||||
"System.Net.Http": "4.1.0",
|
"System.Net.Http": "4.1.0",
|
||||||
"System.Net.Primitives": "4.0.11",
|
"System.Net.Primitives": "4.0.11",
|
||||||
"System.Net.Sockets": "4.1.0",
|
"System.Net.Sockets": "4.1.0",
|
||||||
"System.Net.NetworkInformation": "4.1.0",
|
"System.Net.NetworkInformation": "4.1.0",
|
||||||
"System.Net.NameResolution": "4.0.0",
|
"System.Net.NameResolution": "4.0.0",
|
||||||
"System.Runtime.InteropServices.RuntimeInformation": "4.0.0",
|
"System.Runtime.InteropServices.RuntimeInformation": "4.0.0",
|
||||||
"System.Reflection": "4.1.0",
|
"System.Reflection": "4.1.0",
|
||||||
"System.Reflection.Primitives": "4.0.1",
|
"System.Reflection.Primitives": "4.0.1",
|
||||||
"System.Runtime.Loader": "4.0.0",
|
"System.Runtime.Loader": "4.0.0",
|
||||||
"SimpleInjector": "3.2.4",
|
"SimpleInjector": "3.2.4",
|
||||||
|
"ServiceStack.Text.Core": "1.0.27",
|
||||||
"NLog": "4.4.0-betaV15",
|
"NLog": "4.4.0-betaV15",
|
||||||
"MediaBrowser.Model": {
|
"MediaBrowser.Model": {
|
||||||
"target": "project"
|
"target": "project"
|
||||||
},
|
},
|
||||||
"MediaBrowser.Common": {
|
"MediaBrowser.Common": {
|
||||||
"target": "project"
|
"target": "project"
|
||||||
} }
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,6 +69,7 @@
|
|||||||
<Compile Include="FileOrganization\OrganizerScheduledTask.cs" />
|
<Compile Include="FileOrganization\OrganizerScheduledTask.cs" />
|
||||||
<Compile Include="FileOrganization\TvFolderOrganizer.cs" />
|
<Compile Include="FileOrganization\TvFolderOrganizer.cs" />
|
||||||
<Compile Include="HttpServer\GetSwaggerResource.cs" />
|
<Compile Include="HttpServer\GetSwaggerResource.cs" />
|
||||||
|
<Compile Include="HttpServer\HttpResultFactory.cs" />
|
||||||
<Compile Include="HttpServer\LoggerUtils.cs" />
|
<Compile Include="HttpServer\LoggerUtils.cs" />
|
||||||
<Compile Include="HttpServer\RangeRequestWriter.cs" />
|
<Compile Include="HttpServer\RangeRequestWriter.cs" />
|
||||||
<Compile Include="HttpServer\ResponseFilter.cs" />
|
<Compile Include="HttpServer\ResponseFilter.cs" />
|
||||||
@ -263,6 +264,9 @@
|
|||||||
<Project>{442b5058-dcaf-4263-bb6a-f21e31120a1b}</Project>
|
<Project>{442b5058-dcaf-4263-bb6a-f21e31120a1b}</Project>
|
||||||
<Name>MediaBrowser.Providers</Name>
|
<Name>MediaBrowser.Providers</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
|
<Reference Include="ServiceStack">
|
||||||
|
<HintPath>..\ThirdParty\ServiceStack\ServiceStack.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="SocketHttpListener.Portable">
|
<Reference Include="SocketHttpListener.Portable">
|
||||||
<HintPath>..\ThirdParty\emby\SocketHttpListener.Portable.dll</HintPath>
|
<HintPath>..\ThirdParty\emby\SocketHttpListener.Portable.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
@ -21,7 +21,7 @@ using IRequest = MediaBrowser.Model.Services.IRequest;
|
|||||||
using MimeTypes = MediaBrowser.Model.Net.MimeTypes;
|
using MimeTypes = MediaBrowser.Model.Net.MimeTypes;
|
||||||
using StreamWriter = Emby.Server.Implementations.HttpServer.StreamWriter;
|
using StreamWriter = Emby.Server.Implementations.HttpServer.StreamWriter;
|
||||||
|
|
||||||
namespace MediaBrowser.Server.Implementations.HttpServer
|
namespace Emby.Server.Implementations.HttpServer
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Class HttpResultFactory
|
/// Class HttpResultFactory
|
||||||
@ -161,13 +161,16 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
|||||||
|
|
||||||
public static string GetCompressionType(IRequest request)
|
public static string GetCompressionType(IRequest request)
|
||||||
{
|
{
|
||||||
var prefs = new RequestPreferences(request);
|
var acceptEncoding = request.Headers["Accept-Encoding"];
|
||||||
|
|
||||||
if (prefs.AcceptsDeflate)
|
if (!string.IsNullOrWhiteSpace(acceptEncoding))
|
||||||
return "deflate";
|
{
|
||||||
|
if (acceptEncoding.Contains("deflate"))
|
||||||
|
return "deflate";
|
||||||
|
|
||||||
if (prefs.AcceptsGzip)
|
if (acceptEncoding.Contains("gzip"))
|
||||||
return "gzip";
|
return "gzip";
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -187,14 +190,16 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
|||||||
if (compressionType == null)
|
if (compressionType == null)
|
||||||
{
|
{
|
||||||
var contentType = request.ResponseContentType;
|
var contentType = request.ResponseContentType;
|
||||||
var contentTypeAttr = ContentFormat.GetEndpointAttributes(contentType);
|
|
||||||
|
|
||||||
switch (contentTypeAttr)
|
switch (GetRealContentType(contentType))
|
||||||
{
|
{
|
||||||
case RequestAttributes.Xml:
|
case "application/xml":
|
||||||
|
case "text/xml":
|
||||||
|
case "text/xml; charset=utf-8": //"text/xml; charset=utf-8" also matches xml
|
||||||
return SerializeToXmlString(dto);
|
return SerializeToXmlString(dto);
|
||||||
|
|
||||||
case RequestAttributes.Json:
|
case "application/json":
|
||||||
|
case "text/json":
|
||||||
return _jsonSerializer.SerializeToString(dto);
|
return _jsonSerializer.SerializeToString(dto);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -204,7 +209,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
|||||||
using (var compressionStream = GetCompressionStream(ms, compressionType))
|
using (var compressionStream = GetCompressionStream(ms, compressionType))
|
||||||
{
|
{
|
||||||
ContentTypes.Instance.SerializeToStream(request, dto, compressionStream);
|
ContentTypes.Instance.SerializeToStream(request, dto, compressionStream);
|
||||||
compressionStream.Close();
|
compressionStream.Dispose();
|
||||||
|
|
||||||
var compressedBytes = ms.ToArray();
|
var compressedBytes = ms.ToArray();
|
||||||
|
|
||||||
@ -221,6 +226,13 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string GetRealContentType(string contentType)
|
||||||
|
{
|
||||||
|
return contentType == null
|
||||||
|
? null
|
||||||
|
: contentType.Split(';')[0].ToLower().Trim();
|
||||||
|
}
|
||||||
|
|
||||||
public static string SerializeToXmlString(object from)
|
public static string SerializeToXmlString(object from)
|
||||||
{
|
{
|
||||||
using (var ms = new MemoryStream())
|
using (var ms = new MemoryStream())
|
||||||
@ -520,7 +532,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
|||||||
private bool ShouldCompressResponse(IRequest requestContext, string contentType)
|
private bool ShouldCompressResponse(IRequest requestContext, string contentType)
|
||||||
{
|
{
|
||||||
// It will take some work to support compression with byte range requests
|
// It will take some work to support compression with byte range requests
|
||||||
if (!string.IsNullOrEmpty(requestContext.GetHeader("Range")))
|
if (!string.IsNullOrEmpty(requestContext.Headers.Get("Range")))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -573,7 +585,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
|||||||
|
|
||||||
if (!compress || string.IsNullOrEmpty(requestedCompressionType))
|
if (!compress || string.IsNullOrEmpty(requestedCompressionType))
|
||||||
{
|
{
|
||||||
var rangeHeader = requestContext.GetHeader("Range");
|
var rangeHeader = requestContext.Headers.Get("Range");
|
||||||
|
|
||||||
var stream = await factoryFn().ConfigureAwait(false);
|
var stream = await factoryFn().ConfigureAwait(false);
|
||||||
|
|
||||||
@ -648,7 +660,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
|||||||
using (var zipStream = new DeflateStream(ms, CompressionMode.Compress))
|
using (var zipStream = new DeflateStream(ms, CompressionMode.Compress))
|
||||||
{
|
{
|
||||||
zipStream.Write(bytes, 0, bytes.Length);
|
zipStream.Write(bytes, 0, bytes.Length);
|
||||||
zipStream.Close();
|
zipStream.Dispose();
|
||||||
|
|
||||||
return ms.ToArray();
|
return ms.ToArray();
|
||||||
}
|
}
|
||||||
@ -665,7 +677,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
|||||||
using (var zipStream = new GZipStream(ms, CompressionMode.Compress))
|
using (var zipStream = new GZipStream(ms, CompressionMode.Compress))
|
||||||
{
|
{
|
||||||
zipStream.Write(buffer, 0, buffer.Length);
|
zipStream.Write(buffer, 0, buffer.Length);
|
||||||
zipStream.Close();
|
zipStream.Dispose();
|
||||||
|
|
||||||
return ms.ToArray();
|
return ms.ToArray();
|
||||||
}
|
}
|
||||||
@ -747,7 +759,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
|||||||
{
|
{
|
||||||
var isNotModified = true;
|
var isNotModified = true;
|
||||||
|
|
||||||
var ifModifiedSinceHeader = requestContext.GetHeader("If-Modified-Since");
|
var ifModifiedSinceHeader = requestContext.Headers.Get("If-Modified-Since");
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(ifModifiedSinceHeader))
|
if (!string.IsNullOrEmpty(ifModifiedSinceHeader))
|
||||||
{
|
{
|
||||||
@ -759,7 +771,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var ifNoneMatchHeader = requestContext.GetHeader("If-None-Match");
|
var ifNoneMatchHeader = requestContext.Headers.Get("If-None-Match");
|
||||||
|
|
||||||
// Validate If-None-Match
|
// Validate If-None-Match
|
||||||
if (isNotModified && (cacheKey.HasValue || !string.IsNullOrEmpty(ifNoneMatchHeader)))
|
if (isNotModified && (cacheKey.HasValue || !string.IsNullOrEmpty(ifNoneMatchHeader)))
|
@ -127,23 +127,7 @@ namespace Emby.Server.Implementations.Library.Validators
|
|||||||
{
|
{
|
||||||
var item = _libraryManager.GetPerson(person.Key);
|
var item = _libraryManager.GetPerson(person.Key);
|
||||||
|
|
||||||
var hasMetdata = !string.IsNullOrWhiteSpace(item.Overview);
|
var options = new MetadataRefreshOptions(_fileSystem);
|
||||||
var performFullRefresh = !hasMetdata && (DateTime.UtcNow - item.DateLastRefreshed).TotalDays >= 30;
|
|
||||||
|
|
||||||
var defaultMetadataRefreshMode = performFullRefresh
|
|
||||||
? MetadataRefreshMode.FullRefresh
|
|
||||||
: MetadataRefreshMode.Default;
|
|
||||||
|
|
||||||
var imageRefreshMode = performFullRefresh
|
|
||||||
? ImageRefreshMode.FullRefresh
|
|
||||||
: ImageRefreshMode.Default;
|
|
||||||
|
|
||||||
var options = new MetadataRefreshOptions(_fileSystem)
|
|
||||||
{
|
|
||||||
MetadataRefreshMode = person.Value ? defaultMetadataRefreshMode : MetadataRefreshMode.ValidationOnly,
|
|
||||||
ImageRefreshMode = person.Value ? imageRefreshMode : ImageRefreshMode.ValidationOnly,
|
|
||||||
ForceSave = performFullRefresh
|
|
||||||
};
|
|
||||||
|
|
||||||
await item.RefreshMetadata(options, cancellationToken).ConfigureAwait(false);
|
await item.RefreshMetadata(options, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@ using MediaBrowser.Model.Net;
|
|||||||
using MediaBrowser.Model.Serialization;
|
using MediaBrowser.Model.Serialization;
|
||||||
using MediaBrowser.Model.Services;
|
using MediaBrowser.Model.Services;
|
||||||
using MediaBrowser.Model.Text;
|
using MediaBrowser.Model.Text;
|
||||||
|
using ServiceStack.Text.Jsv;
|
||||||
using SocketHttpListener.Net;
|
using SocketHttpListener.Net;
|
||||||
using SocketHttpListener.Primitives;
|
using SocketHttpListener.Primitives;
|
||||||
|
|
||||||
@ -87,9 +88,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
|||||||
|
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
HostConfig.Instance.DefaultRedirectPath = DefaultRedirectPath;
|
var mapExceptionToStatusCode = new Dictionary<Type, int>
|
||||||
|
|
||||||
HostConfig.Instance.MapExceptionToStatusCode = new Dictionary<Type, int>
|
|
||||||
{
|
{
|
||||||
{typeof (InvalidOperationException), 500},
|
{typeof (InvalidOperationException), 500},
|
||||||
{typeof (NotImplementedException), 500},
|
{typeof (NotImplementedException), 500},
|
||||||
@ -126,6 +125,16 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
|||||||
return _appHost.Resolve<T>();
|
return _appHost.Resolve<T>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override Type[] GetGenericArguments(Type type)
|
||||||
|
{
|
||||||
|
return type.GetGenericArguments();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool IsAssignableFrom(Type type1, Type type2)
|
||||||
|
{
|
||||||
|
return type1.IsAssignableFrom(type2);
|
||||||
|
}
|
||||||
|
|
||||||
public override T TryResolve<T>()
|
public override T TryResolve<T>()
|
||||||
{
|
{
|
||||||
return _appHost.TryResolve<T>();
|
return _appHost.TryResolve<T>();
|
||||||
@ -136,13 +145,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
|||||||
return _appHost.CreateInstance(type);
|
return _appHost.CreateInstance(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnConfigLoad()
|
|
||||||
{
|
|
||||||
base.OnConfigLoad();
|
|
||||||
|
|
||||||
Config.HandlerFactoryPath = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override ServiceController CreateServiceController(params Assembly[] assembliesWithServices)
|
protected override ServiceController CreateServiceController(params Assembly[] assembliesWithServices)
|
||||||
{
|
{
|
||||||
var types = _restServices.Select(r => r.GetType()).ToArray();
|
var types = _restServices.Select(r => r.GetType()).ToArray();
|
||||||
@ -156,12 +158,14 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string HandlerFactoryPath;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Starts the Web Service
|
/// Starts the Web Service
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void StartListener()
|
private void StartListener()
|
||||||
{
|
{
|
||||||
HostContext.Config.HandlerFactoryPath = GetHandlerPathIfAny(UrlPrefixes.First());
|
HandlerFactoryPath = GetHandlerPathIfAny(UrlPrefixes.First());
|
||||||
|
|
||||||
_listener = GetListener();
|
_listener = GetListener();
|
||||||
|
|
||||||
@ -610,6 +614,40 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
|||||||
return routes.ToArray();
|
return routes.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override object GetTaskResult(Task task, string requestName)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var taskObject = task as Task<object>;
|
||||||
|
if (taskObject != null)
|
||||||
|
{
|
||||||
|
return taskObject.Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
task.Wait();
|
||||||
|
|
||||||
|
var type = task.GetType();
|
||||||
|
if (!type.IsGenericType)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Logger.Warn("Getting task result from " + requestName + " using reflection. For better performance have your api return Task<object>");
|
||||||
|
return type.GetProperty("Result").GetValue(task);
|
||||||
|
}
|
||||||
|
catch (TypeAccessException)
|
||||||
|
{
|
||||||
|
return null; //return null for void Task's
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Func<string, object> GetParseFn(Type propertyType)
|
||||||
|
{
|
||||||
|
var fn = JsvReader.GetParseFn(propertyType);
|
||||||
|
|
||||||
|
return s => fn(s);
|
||||||
|
}
|
||||||
|
|
||||||
public override void SerializeToJson(object o, Stream stream)
|
public override void SerializeToJson(object o, Stream stream)
|
||||||
{
|
{
|
||||||
_jsonSerializer.SerializeToStream(o, stream);
|
_jsonSerializer.SerializeToStream(o, stream);
|
||||||
|
@ -2,12 +2,12 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using Emby.Server.Implementations.HttpServer;
|
||||||
using Emby.Server.Implementations.HttpServer.SocketSharp;
|
using Emby.Server.Implementations.HttpServer.SocketSharp;
|
||||||
using MediaBrowser.Model.IO;
|
using MediaBrowser.Model.IO;
|
||||||
using MediaBrowser.Model.Logging;
|
using MediaBrowser.Model.Logging;
|
||||||
using MediaBrowser.Model.Services;
|
using MediaBrowser.Model.Services;
|
||||||
using ServiceStack;
|
using ServiceStack;
|
||||||
using ServiceStack.Host;
|
|
||||||
using SocketHttpListener.Net;
|
using SocketHttpListener.Net;
|
||||||
using IHttpFile = MediaBrowser.Model.Services.IHttpFile;
|
using IHttpFile = MediaBrowser.Model.Services.IHttpFile;
|
||||||
using IHttpRequest = MediaBrowser.Model.Services.IHttpRequest;
|
using IHttpRequest = MediaBrowser.Model.Services.IHttpRequest;
|
||||||
@ -244,14 +244,15 @@ namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp
|
|||||||
var specifiedContentType = GetQueryStringContentType(httpReq);
|
var specifiedContentType = GetQueryStringContentType(httpReq);
|
||||||
if (!string.IsNullOrEmpty(specifiedContentType)) return specifiedContentType;
|
if (!string.IsNullOrEmpty(specifiedContentType)) return specifiedContentType;
|
||||||
|
|
||||||
|
var serverDefaultContentType = "application/json";
|
||||||
|
|
||||||
var acceptContentTypes = httpReq.AcceptTypes;
|
var acceptContentTypes = httpReq.AcceptTypes;
|
||||||
var defaultContentType = httpReq.ContentType;
|
var defaultContentType = httpReq.ContentType;
|
||||||
if (HasAnyOfContentTypes(httpReq, FormUrlEncoded, MultiPartFormData))
|
if (HasAnyOfContentTypes(httpReq, FormUrlEncoded, MultiPartFormData))
|
||||||
{
|
{
|
||||||
defaultContentType = HostContext.Config.DefaultContentType;
|
defaultContentType = serverDefaultContentType;
|
||||||
}
|
}
|
||||||
|
|
||||||
var customContentTypes = ContentTypes.Instance.ContentTypeFormats.Values;
|
|
||||||
var preferredContentTypes = new string[] {};
|
var preferredContentTypes = new string[] {};
|
||||||
|
|
||||||
var acceptsAnything = false;
|
var acceptsAnything = false;
|
||||||
@ -261,7 +262,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp
|
|||||||
var hasPreferredContentTypes = new bool[preferredContentTypes.Length];
|
var hasPreferredContentTypes = new bool[preferredContentTypes.Length];
|
||||||
foreach (var acceptsType in acceptContentTypes)
|
foreach (var acceptsType in acceptContentTypes)
|
||||||
{
|
{
|
||||||
var contentType = ContentFormat.GetRealContentType(acceptsType);
|
var contentType = HttpResultFactory.GetRealContentType(acceptsType);
|
||||||
acceptsAnything = acceptsAnything || contentType == "*/*";
|
acceptsAnything = acceptsAnything || contentType == "*/*";
|
||||||
|
|
||||||
for (var i = 0; i < preferredContentTypes.Length; i++)
|
for (var i = 0; i < preferredContentTypes.Length; i++)
|
||||||
@ -285,17 +286,8 @@ namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp
|
|||||||
{
|
{
|
||||||
if (hasDefaultContentType)
|
if (hasDefaultContentType)
|
||||||
return defaultContentType;
|
return defaultContentType;
|
||||||
if (HostContext.Config.DefaultContentType != null)
|
if (serverDefaultContentType != null)
|
||||||
return HostContext.Config.DefaultContentType;
|
return serverDefaultContentType;
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var contentType in acceptContentTypes)
|
|
||||||
{
|
|
||||||
foreach (var customContentType in customContentTypes)
|
|
||||||
{
|
|
||||||
if (contentType.StartsWith(customContentType, StringComparison.OrdinalIgnoreCase))
|
|
||||||
return customContentType;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -305,8 +297,9 @@ namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp
|
|||||||
}
|
}
|
||||||
|
|
||||||
//We could also send a '406 Not Acceptable', but this is allowed also
|
//We could also send a '406 Not Acceptable', but this is allowed also
|
||||||
return HostContext.Config.DefaultContentType;
|
return serverDefaultContentType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public const string Soap11 = "text/xml; charset=utf-8";
|
public const string Soap11 = "text/xml; charset=utf-8";
|
||||||
|
|
||||||
public static bool HasAnyOfContentTypes(IRequest request, params string[] contentTypes)
|
public static bool HasAnyOfContentTypes(IRequest request, params string[] contentTypes)
|
||||||
@ -342,10 +335,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp
|
|||||||
if (format.Contains("json")) return "application/json";
|
if (format.Contains("json")) return "application/json";
|
||||||
if (format.Contains("xml")) return Xml;
|
if (format.Contains("xml")) return Xml;
|
||||||
|
|
||||||
string contentType;
|
return null;
|
||||||
ContentTypes.Instance.ContentTypeFormats.TryGetValue(format, out contentType);
|
|
||||||
|
|
||||||
return contentType;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool HasExplicitResponseContentType { get; private set; }
|
public bool HasExplicitResponseContentType { get; private set; }
|
||||||
@ -357,7 +347,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp
|
|||||||
{
|
{
|
||||||
if (this.pathInfo == null)
|
if (this.pathInfo == null)
|
||||||
{
|
{
|
||||||
var mode = HostContext.Config.HandlerFactoryPath;
|
var mode = HttpListenerHost.HandlerFactoryPath;
|
||||||
|
|
||||||
var pos = request.RawUrl.IndexOf("?");
|
var pos = request.RawUrl.IndexOf("?");
|
||||||
if (pos != -1)
|
if (pos != -1)
|
||||||
|
@ -69,6 +69,10 @@
|
|||||||
<HintPath>..\packages\Patterns.Logging.1.0.0.6\lib\portable-net45+win8\Patterns.Logging.dll</HintPath>
|
<HintPath>..\packages\Patterns.Logging.1.0.0.6\lib\portable-net45+win8\Patterns.Logging.dll</HintPath>
|
||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="ServiceStack.Text, Version=4.5.4.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\ServiceStack.Text.4.5.4\lib\net45\ServiceStack.Text.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
<Reference Include="SharpCompress, Version=0.10.3.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="SharpCompress, Version=0.10.3.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\ThirdParty\SharpCompress\SharpCompress.dll</HintPath>
|
<HintPath>..\ThirdParty\SharpCompress\SharpCompress.dll</HintPath>
|
||||||
@ -88,9 +92,6 @@
|
|||||||
<Reference Include="ServiceStack">
|
<Reference Include="ServiceStack">
|
||||||
<HintPath>..\ThirdParty\ServiceStack\ServiceStack.dll</HintPath>
|
<HintPath>..\ThirdParty\ServiceStack\ServiceStack.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="ServiceStack.Text">
|
|
||||||
<HintPath>..\ThirdParty\ServiceStack.Text\ServiceStack.Text.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="System.Xml.Linq" />
|
<Reference Include="System.Xml.Linq" />
|
||||||
<Reference Include="UniversalDetector, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="UniversalDetector, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\UniversalDetector.1.0.1\lib\portable-net45+sl4+wp71+win8+wpa81\UniversalDetector.dll</HintPath>
|
<HintPath>..\packages\UniversalDetector.1.0.1\lib\portable-net45+sl4+wp71+win8+wpa81\UniversalDetector.dll</HintPath>
|
||||||
@ -109,7 +110,6 @@
|
|||||||
<Compile Include="Devices\CameraUploadsFolder.cs" />
|
<Compile Include="Devices\CameraUploadsFolder.cs" />
|
||||||
<Compile Include="EntryPoints\ExternalPortForwarding.cs" />
|
<Compile Include="EntryPoints\ExternalPortForwarding.cs" />
|
||||||
<Compile Include="HttpServer\HttpListenerHost.cs" />
|
<Compile Include="HttpServer\HttpListenerHost.cs" />
|
||||||
<Compile Include="HttpServer\HttpResultFactory.cs" />
|
|
||||||
<Compile Include="HttpServer\ServerFactory.cs" />
|
<Compile Include="HttpServer\ServerFactory.cs" />
|
||||||
<Compile Include="HttpServer\SocketSharp\RequestMono.cs" />
|
<Compile Include="HttpServer\SocketSharp\RequestMono.cs" />
|
||||||
<Compile Include="HttpServer\SocketSharp\WebSocketSharpRequest.cs" />
|
<Compile Include="HttpServer\SocketSharp\WebSocketSharpRequest.cs" />
|
||||||
@ -141,7 +141,6 @@
|
|||||||
<Compile Include="Persistence\DataExtensions.cs" />
|
<Compile Include="Persistence\DataExtensions.cs" />
|
||||||
<Compile Include="Persistence\IDbConnector.cs" />
|
<Compile Include="Persistence\IDbConnector.cs" />
|
||||||
<Compile Include="Persistence\MediaStreamColumns.cs" />
|
<Compile Include="Persistence\MediaStreamColumns.cs" />
|
||||||
<Compile Include="Serialization\JsonSerializer.cs" />
|
|
||||||
<Compile Include="Social\SharingRepository.cs" />
|
<Compile Include="Social\SharingRepository.cs" />
|
||||||
<Compile Include="Persistence\SqliteFileOrganizationRepository.cs" />
|
<Compile Include="Persistence\SqliteFileOrganizationRepository.cs" />
|
||||||
<Compile Include="Notifications\SqliteNotificationsRepository.cs" />
|
<Compile Include="Notifications\SqliteNotificationsRepository.cs" />
|
||||||
@ -351,7 +350,9 @@
|
|||||||
<None Include="LiveTv\TunerHosts\SatIp\ini\satellite\3594.ini" />
|
<None Include="LiveTv\TunerHosts\SatIp\ini\satellite\3594.ini" />
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup />
|
<ItemGroup>
|
||||||
|
<Folder Include="Serialization\" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
@ -5,5 +5,6 @@
|
|||||||
<package id="MediaBrowser.Naming" version="1.0.0.59" targetFramework="net46" />
|
<package id="MediaBrowser.Naming" version="1.0.0.59" targetFramework="net46" />
|
||||||
<package id="Microsoft.IO.RecyclableMemoryStream" version="1.1.0.0" targetFramework="net46" />
|
<package id="Microsoft.IO.RecyclableMemoryStream" version="1.1.0.0" targetFramework="net46" />
|
||||||
<package id="Patterns.Logging" version="1.0.0.6" targetFramework="net46" />
|
<package id="Patterns.Logging" version="1.0.0.6" targetFramework="net46" />
|
||||||
|
<package id="ServiceStack.Text" version="4.5.4" targetFramework="net46" />
|
||||||
<package id="UniversalDetector" version="1.0.1" targetFramework="net46" />
|
<package id="UniversalDetector" version="1.0.1" targetFramework="net46" />
|
||||||
</packages>
|
</packages>
|
@ -77,6 +77,7 @@ using System.Threading.Tasks;
|
|||||||
using Emby.Common.Implementations;
|
using Emby.Common.Implementations;
|
||||||
using Emby.Common.Implementations.Networking;
|
using Emby.Common.Implementations.Networking;
|
||||||
using Emby.Common.Implementations.Reflection;
|
using Emby.Common.Implementations.Reflection;
|
||||||
|
using Emby.Common.Implementations.Serialization;
|
||||||
using Emby.Common.Implementations.TextEncoding;
|
using Emby.Common.Implementations.TextEncoding;
|
||||||
using Emby.Common.Implementations.Updates;
|
using Emby.Common.Implementations.Updates;
|
||||||
using Emby.Common.Implementations.Xml;
|
using Emby.Common.Implementations.Xml;
|
||||||
@ -103,6 +104,7 @@ using Emby.Server.Implementations.Devices;
|
|||||||
using Emby.Server.Implementations.Dto;
|
using Emby.Server.Implementations.Dto;
|
||||||
using Emby.Server.Implementations.EntryPoints;
|
using Emby.Server.Implementations.EntryPoints;
|
||||||
using Emby.Server.Implementations.FileOrganization;
|
using Emby.Server.Implementations.FileOrganization;
|
||||||
|
using Emby.Server.Implementations.HttpServer;
|
||||||
using Emby.Server.Implementations.HttpServer.Security;
|
using Emby.Server.Implementations.HttpServer.Security;
|
||||||
using Emby.Server.Implementations.Library;
|
using Emby.Server.Implementations.Library;
|
||||||
using Emby.Server.Implementations.LiveTv;
|
using Emby.Server.Implementations.LiveTv;
|
||||||
@ -131,7 +133,6 @@ using MediaBrowser.Model.Social;
|
|||||||
using MediaBrowser.Model.Text;
|
using MediaBrowser.Model.Text;
|
||||||
using MediaBrowser.Model.Xml;
|
using MediaBrowser.Model.Xml;
|
||||||
using MediaBrowser.Server.Implementations.Archiving;
|
using MediaBrowser.Server.Implementations.Archiving;
|
||||||
using MediaBrowser.Server.Implementations.Serialization;
|
|
||||||
using OpenSubtitlesHandler;
|
using OpenSubtitlesHandler;
|
||||||
using ServiceStack;
|
using ServiceStack;
|
||||||
using StringExtensions = MediaBrowser.Controller.Extensions.StringExtensions;
|
using StringExtensions = MediaBrowser.Controller.Extensions.StringExtensions;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user