diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2016-11-10 20:37:20 -0500 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2016-11-10 20:37:20 -0500 |
| commit | 01fc207b62151a858c0d7edb802a24690505bb95 (patch) | |
| tree | 7af904c00c9eff2880257a178a5d0290967123f1 /MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpRequest.cs | |
| parent | 2c64cc7d7d2471f52a7ce1dbd909564215504974 (diff) | |
update portable components
Diffstat (limited to 'MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpRequest.cs')
| -rw-r--r-- | MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpRequest.cs | 32 |
1 files changed, 11 insertions, 21 deletions
diff --git a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpRequest.cs b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpRequest.cs index 95b2ccaba..628e5cc7e 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpRequest.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpRequest.cs @@ -2,12 +2,12 @@ using System.Collections.Generic; using System.IO; using System.Text; +using Emby.Server.Implementations.HttpServer; using Emby.Server.Implementations.HttpServer.SocketSharp; using MediaBrowser.Model.IO; using MediaBrowser.Model.Logging; using MediaBrowser.Model.Services; using ServiceStack; -using ServiceStack.Host; using SocketHttpListener.Net; using IHttpFile = MediaBrowser.Model.Services.IHttpFile; using IHttpRequest = MediaBrowser.Model.Services.IHttpRequest; @@ -244,14 +244,15 @@ namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp var specifiedContentType = GetQueryStringContentType(httpReq); if (!string.IsNullOrEmpty(specifiedContentType)) return specifiedContentType; + var serverDefaultContentType = "application/json"; + var acceptContentTypes = httpReq.AcceptTypes; var defaultContentType = httpReq.ContentType; if (HasAnyOfContentTypes(httpReq, FormUrlEncoded, MultiPartFormData)) { - defaultContentType = HostContext.Config.DefaultContentType; + defaultContentType = serverDefaultContentType; } - var customContentTypes = ContentTypes.Instance.ContentTypeFormats.Values; var preferredContentTypes = new string[] {}; var acceptsAnything = false; @@ -261,7 +262,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp var hasPreferredContentTypes = new bool[preferredContentTypes.Length]; foreach (var acceptsType in acceptContentTypes) { - var contentType = ContentFormat.GetRealContentType(acceptsType); + var contentType = HttpResultFactory.GetRealContentType(acceptsType); acceptsAnything = acceptsAnything || contentType == "*/*"; for (var i = 0; i < preferredContentTypes.Length; i++) @@ -285,17 +286,8 @@ namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp { if (hasDefaultContentType) return defaultContentType; - if (HostContext.Config.DefaultContentType != null) - return HostContext.Config.DefaultContentType; - } - - foreach (var contentType in acceptContentTypes) - { - foreach (var customContentType in customContentTypes) - { - if (contentType.StartsWith(customContentType, StringComparison.OrdinalIgnoreCase)) - return customContentType; - } + if (serverDefaultContentType != null) + return serverDefaultContentType; } } @@ -305,8 +297,9 @@ namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp } //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 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("xml")) return Xml; - string contentType; - ContentTypes.Instance.ContentTypeFormats.TryGetValue(format, out contentType); - - return contentType; + return null; } public bool HasExplicitResponseContentType { get; private set; } @@ -357,7 +347,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp { if (this.pathInfo == null) { - var mode = HostContext.Config.HandlerFactoryPath; + var mode = HttpListenerHost.HandlerFactoryPath; var pos = request.RawUrl.IndexOf("?"); if (pos != -1) |
