diff --git a/MediaBrowser.Api/StartupWizardService.cs b/MediaBrowser.Api/StartupWizardService.cs index e4949b4d83..93c9f8b9f5 100644 --- a/MediaBrowser.Api/StartupWizardService.cs +++ b/MediaBrowser.Api/StartupWizardService.cs @@ -69,9 +69,9 @@ namespace MediaBrowser.Api _config.SaveConfiguration(); } - public object Get(GetStartupInfo request) + public async Task Get(GetStartupInfo request) { - var info = _appHost.GetSystemInfo(); + var info = await _appHost.GetSystemInfo().ConfigureAwait(false); return new StartupInfo { diff --git a/MediaBrowser.Api/System/SystemInfoWebSocketListener.cs b/MediaBrowser.Api/System/SystemInfoWebSocketListener.cs index 9ab7770ed6..a53bfac276 100644 --- a/MediaBrowser.Api/System/SystemInfoWebSocketListener.cs +++ b/MediaBrowser.Api/System/SystemInfoWebSocketListener.cs @@ -43,7 +43,7 @@ namespace MediaBrowser.Api.System /// Task{SystemInfo}. protected override Task GetDataToSend(WebSocketListenerState state) { - return Task.FromResult(_appHost.GetSystemInfo()); + return _appHost.GetSystemInfo(); } } } diff --git a/MediaBrowser.Api/System/SystemService.cs b/MediaBrowser.Api/System/SystemService.cs index 1610be85d6..346f6b32ab 100644 --- a/MediaBrowser.Api/System/SystemService.cs +++ b/MediaBrowser.Api/System/SystemService.cs @@ -157,16 +157,16 @@ namespace MediaBrowser.Api.System /// /// The request. /// System.Object. - public object Get(GetSystemInfo request) + public async Task Get(GetSystemInfo request) { - var result = _appHost.GetSystemInfo(); + var result = await _appHost.GetSystemInfo().ConfigureAwait(false); return ToOptimizedResult(result); } - public object Get(GetPublicSystemInfo request) + public async Task Get(GetPublicSystemInfo request) { - var result = _appHost.GetSystemInfo(); + var result = await _appHost.GetSystemInfo().ConfigureAwait(false); var publicInfo = new PublicSystemInfo { diff --git a/MediaBrowser.Controller/IServerApplicationHost.cs b/MediaBrowser.Controller/IServerApplicationHost.cs index 78b7d2ccd4..f4c0e76581 100644 --- a/MediaBrowser.Controller/IServerApplicationHost.cs +++ b/MediaBrowser.Controller/IServerApplicationHost.cs @@ -18,7 +18,7 @@ namespace MediaBrowser.Controller /// Gets the system info. /// /// SystemInfo. - SystemInfo GetSystemInfo(); + Task GetSystemInfo(); /// /// Gets a value indicating whether [supports automatic run at startup]. diff --git a/MediaBrowser.Server.Implementations/HttpServer/RangeRequestWriter.cs b/MediaBrowser.Server.Implementations/HttpServer/RangeRequestWriter.cs index 020856886d..fb4397462b 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/RangeRequestWriter.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/RangeRequestWriter.cs @@ -39,6 +39,9 @@ namespace MediaBrowser.Server.Implementations.HttpServer /// private static readonly CultureInfo UsCulture = new CultureInfo("en-US"); + public Func ResultScope { get; set; } + public List Cookies { get; private set; } + /// /// Additional HTTP Headers /// @@ -81,6 +84,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer Options["Accept-Ranges"] = "bytes"; StatusCode = HttpStatusCode.PartialContent; + Cookies = new List(); SetRangeValues(); } diff --git a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/RequestMono.cs b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/RequestMono.cs index ed9e17b6b5..efa8509221 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/RequestMono.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/RequestMono.cs @@ -4,6 +4,7 @@ using System.Globalization; using System.IO; using System.Text; using System.Web; +using ServiceStack; using ServiceStack.Web; namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp @@ -116,6 +117,21 @@ namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp } } + public string Accept + { + get + { + return string.IsNullOrEmpty(request.Headers[HttpHeaders.Accept]) ? null : request.Headers[HttpHeaders.Accept]; + } + } + + public string Authorization + { + get + { + return string.IsNullOrEmpty(request.Headers[HttpHeaders.Authorization]) ? null : request.Headers[HttpHeaders.Authorization]; + } + } protected bool validate_cookies, validate_query_string, validate_form; protected bool checked_cookies, checked_query_string, checked_form; diff --git a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpRequest.cs b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpRequest.cs index 30849d4418..c7d889505b 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpRequest.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpRequest.cs @@ -22,7 +22,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp this.OperationName = operationName; this.RequestAttributes = requestAttributes; this.request = httpContext.Request; - this.response = new WebSocketSharpResponse(logger, httpContext.Response); + this.response = new WebSocketSharpResponse(logger, httpContext.Response, this); this.RequestPreferences = new RequestPreferences(this); } diff --git a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpResponse.cs b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpResponse.cs index 171dacb221..e08be8bd19 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpResponse.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpResponse.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.IO; using System.Net; using MediaBrowser.Model.Logging; @@ -14,14 +15,17 @@ namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp private readonly ILogger _logger; private readonly HttpListenerResponse response; - public WebSocketSharpResponse(ILogger logger, HttpListenerResponse response) + public WebSocketSharpResponse(ILogger logger, HttpListenerResponse response, IRequest request) { _logger = logger; this.response = response; + Items = new Dictionary(); + Request = request; } + public IRequest Request { get; private set; } public bool UseBufferedStream { get; set; } - + public Dictionary Items { get; private set; } public object OriginalResponse { get { return response; } @@ -58,6 +62,11 @@ namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp response.AddHeader(name, value); } + public string GetHeader(string name) + { + return response.Headers[name]; + } + public void Redirect(string url) { response.Redirect(url); @@ -142,5 +151,9 @@ namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp } public bool KeepAlive { get; set; } + + public void ClearCookies() + { + } } } diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj index c69c788c8f..cfe0564fbd 100644 --- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj +++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj @@ -392,7 +392,103 @@ + + swagger-ui\lib\backbone-min.js + PreserveNewest + + + swagger-ui\lib\handlebars-2.0.0.js + PreserveNewest + + + swagger-ui\lib\highlight.7.3.pack.js + PreserveNewest + + + swagger-ui\lib\jquery-1.8.0.min.js + PreserveNewest + + + swagger-ui\lib\jquery.ba-bbq.min.js + PreserveNewest + + + swagger-ui\lib\jquery.slideto.min.js + PreserveNewest + + + swagger-ui\lib\jquery.wiggle.min.js + PreserveNewest + + + swagger-ui\lib\marked.js + PreserveNewest + + + swagger-ui\lib\shred.bundle.js + PreserveNewest + + + swagger-ui\lib\swagger-client.js + PreserveNewest + + + swagger-ui\lib\swagger-oauth.js + PreserveNewest + + + swagger-ui\lib\underscore-min.js + PreserveNewest + + + swagger-ui\o2c.html + PreserveNewest + + + swagger-ui\patch.js + PreserveNewest + + + swagger-ui\swagger-ui.js + PreserveNewest + + + swagger-ui\swagger-ui.min.js + PreserveNewest + + + swagger-ui\fonts\droid-sans-v6-latin-700.eot + PreserveNewest + + + swagger-ui\fonts\droid-sans-v6-latin-700.ttf + PreserveNewest + + + swagger-ui\fonts\droid-sans-v6-latin-700.woff + PreserveNewest + + + swagger-ui\fonts\droid-sans-v6-latin-700.woff2 + PreserveNewest + + + swagger-ui\fonts\droid-sans-v6-latin-regular.eot + PreserveNewest + + + swagger-ui\fonts\droid-sans-v6-latin-regular.ttf + PreserveNewest + + + swagger-ui\fonts\droid-sans-v6-latin-regular.woff + PreserveNewest + + + swagger-ui\fonts\droid-sans-v6-latin-regular.woff2 + PreserveNewest + @@ -609,10 +705,30 @@ + + swagger-ui\css\reset.css + PreserveNewest + swagger-ui\css\screen.css PreserveNewest + + swagger-ui\css\typography.css + PreserveNewest + + + swagger-ui\fonts\droid-sans-v6-latin-700.svg + PreserveNewest + + + swagger-ui\fonts\droid-sans-v6-latin-regular.svg + PreserveNewest + + + swagger-ui\images\explorer_icons.png + PreserveNewest + swagger-ui\images\logo_small.png PreserveNewest @@ -633,58 +749,10 @@ swagger-ui\index.html PreserveNewest - - swagger-ui\lib\backbone-min.js - PreserveNewest - - - swagger-ui\lib\handlebars-1.0.0.js - PreserveNewest - - - swagger-ui\lib\highlight.7.3.pack.js - PreserveNewest - - - swagger-ui\lib\jquery-1.8.0.min.js - PreserveNewest - - - swagger-ui\lib\jquery.ba-bbq.min.js - PreserveNewest - - - swagger-ui\lib\jquery.slideto.min.js - PreserveNewest - - - swagger-ui\lib\jquery.wiggle.min.js - PreserveNewest - - - swagger-ui\lib\shred.bundle.js - PreserveNewest - swagger-ui\lib\shred\content.js PreserveNewest - - swagger-ui\lib\swagger.js - PreserveNewest - - - swagger-ui\lib\underscore-min.js - PreserveNewest - - - swagger-ui\swagger-ui.js - PreserveNewest - - - swagger-ui\swagger-ui.min.js - PreserveNewest - diff --git a/MediaBrowser.Server.Implementations/Session/SessionManager.cs b/MediaBrowser.Server.Implementations/Session/SessionManager.cs index a54fa0a29a..84aab5e1f8 100644 --- a/MediaBrowser.Server.Implementations/Session/SessionManager.cs +++ b/MediaBrowser.Server.Implementations/Session/SessionManager.cs @@ -1134,11 +1134,11 @@ namespace MediaBrowser.Server.Implementations.Session /// /// The cancellation token. /// Task. - public Task SendRestartRequiredNotification(CancellationToken cancellationToken) + public async Task SendRestartRequiredNotification(CancellationToken cancellationToken) { var sessions = Sessions.Where(i => i.IsActive && i.SessionController != null).ToList(); - var info = _appHost.GetSystemInfo(); + var info = await _appHost.GetSystemInfo().ConfigureAwait(false); var tasks = sessions.Select(session => Task.Run(async () => { @@ -1153,7 +1153,7 @@ namespace MediaBrowser.Server.Implementations.Session }, cancellationToken)); - return Task.WhenAll(tasks); + await Task.WhenAll(tasks).ConfigureAwait(false); } /// diff --git a/MediaBrowser.Server.Implementations/Social/SharingManager.cs b/MediaBrowser.Server.Implementations/Social/SharingManager.cs index 2ffd33ca47..95f0ece0c2 100644 --- a/MediaBrowser.Server.Implementations/Social/SharingManager.cs +++ b/MediaBrowser.Server.Implementations/Social/SharingManager.cs @@ -43,7 +43,7 @@ namespace MediaBrowser.Server.Implementations.Social throw new ResourceNotFoundException(); } - var externalUrl = _appHost.GetSystemInfo().WanAddress; + var externalUrl = (await _appHost.GetSystemInfo().ConfigureAwait(false)).WanAddress; if (string.IsNullOrWhiteSpace(externalUrl)) { @@ -58,7 +58,7 @@ namespace MediaBrowser.Server.Implementations.Social UserId = userId }; - AddShareInfo(info); + AddShareInfo(info, externalUrl); await _repository.CreateShare(info).ConfigureAwait(false); @@ -74,15 +74,13 @@ namespace MediaBrowser.Server.Implementations.Social { var info = _repository.GetShareInfo(id); - AddShareInfo(info); + AddShareInfo(info, _appHost.GetSystemInfo().Result.WanAddress); return info; } - private void AddShareInfo(SocialShareInfo info) + private void AddShareInfo(SocialShareInfo info, string externalUrl) { - var externalUrl = _appHost.GetSystemInfo().WanAddress; - info.ImageUrl = externalUrl + "/Social/Shares/Public/" + info.Id + "/Image"; info.Url = externalUrl + "/emby/web/shared.html?id=" + info.Id; diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs index 642ae1bf09..7341f56cbd 100644 --- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs +++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs @@ -1098,8 +1098,10 @@ namespace MediaBrowser.Server.Startup.Common /// Gets the system status. /// /// SystemInfo. - public SystemInfo GetSystemInfo() + public async Task GetSystemInfo() { + var localAddress = await GetLocalApiUrl().ConfigureAwait(false); + return new SystemInfo { HasPendingRestart = HasPendingRestart, @@ -1130,7 +1132,7 @@ namespace MediaBrowser.Server.Startup.Common IsRunningAsService = IsRunningAsService, SupportsRunningAsService = SupportsRunningAsService, ServerName = FriendlyName, - LocalAddress = GetLocalApiUrl().Result, + LocalAddress = localAddress, SupportsLibraryMonitor = SupportsLibraryMonitor }; }