diff --git a/MediaBrowser.Api/Library/LibraryService.cs b/MediaBrowser.Api/Library/LibraryService.cs index 56f66bd6b..0476927d7 100644 --- a/MediaBrowser.Api/Library/LibraryService.cs +++ b/MediaBrowser.Api/Library/LibraryService.cs @@ -466,24 +466,10 @@ namespace MediaBrowser.Api.Library /// Deletes the specified request. /// /// The request. - public void Delete(DeleteItem request) - { - var task = DeleteItem(request); - - Task.WaitAll(task); - } - - private Task DeleteItem(DeleteItem request) + public Task Delete(DeleteItem request) { var item = _libraryManager.GetItemById(request.Id); - var session = GetSession(); - - if (!session.UserId.HasValue || !_userManager.GetUserById(session.UserId.Value).Configuration.EnableContentDeletion) - { - throw new UnauthorizedAccessException("This operation requires a logged in user with delete access."); - } - return _libraryManager.DeleteItem(item); } diff --git a/MediaBrowser.Api/Session/SessionsService.cs b/MediaBrowser.Api/Session/SessionsService.cs index e2c95eba9..8e97e2f3e 100644 --- a/MediaBrowser.Api/Session/SessionsService.cs +++ b/MediaBrowser.Api/Session/SessionsService.cs @@ -297,9 +297,9 @@ namespace MediaBrowser.Api.Session Task.WaitAll(task); } - public void Post(CreateKey request) + public Task Post(CreateKey request) { - var task = _authRepo.Create(new AuthenticationInfo + return _authRepo.Create(new AuthenticationInfo { AppName = request.App, IsActive = true, @@ -307,8 +307,6 @@ namespace MediaBrowser.Api.Session DateCreated = DateTime.UtcNow }, CancellationToken.None); - - Task.WaitAll(task); } public void Post(ReportSessionEnded request) @@ -357,7 +355,7 @@ namespace MediaBrowser.Api.Session return ToOptimizedResult(result.Select(_sessionManager.GetSessionInfoDto).ToList()); } - public void Post(SendPlaystateCommand request) + public Task Post(SendPlaystateCommand request) { var command = new PlaystateRequest { @@ -365,16 +363,14 @@ namespace MediaBrowser.Api.Session SeekPositionTicks = request.SeekPositionTicks }; - var task = _sessionManager.SendPlaystateCommand(GetSession().Id, request.Id, command, CancellationToken.None); - - Task.WaitAll(task); + return _sessionManager.SendPlaystateCommand(GetSession().Id, request.Id, command, CancellationToken.None); } /// /// Posts the specified request. /// /// The request. - public void Post(DisplayContent request) + public Task Post(DisplayContent request) { var command = new BrowseRequest { @@ -383,40 +379,39 @@ namespace MediaBrowser.Api.Session ItemType = request.ItemType }; - var task = _sessionManager.SendBrowseCommand(GetSession().Id, request.Id, command, CancellationToken.None); - - Task.WaitAll(task); + return _sessionManager.SendBrowseCommand(GetSession().Id, request.Id, command, CancellationToken.None); } /// /// Posts the specified request. /// /// The request. - public void Post(SendSystemCommand request) + public Task Post(SendSystemCommand request) { GeneralCommandType commandType; + var name = request.Command; - if (Enum.TryParse(request.Command, true, out commandType)) + if (Enum.TryParse(name, true, out commandType)) { - var currentSession = GetSession(); - - var command = new GeneralCommand - { - Name = commandType.ToString(), - ControllingUserId = currentSession.UserId.HasValue ? currentSession.UserId.Value.ToString("N") : null - }; - - var task = _sessionManager.SendGeneralCommand(currentSession.Id, request.Id, command, CancellationToken.None); - - Task.WaitAll(task); + name = commandType.ToString(); } + + var currentSession = GetSession(); + + var command = new GeneralCommand + { + Name = name, + ControllingUserId = currentSession.UserId.HasValue ? currentSession.UserId.Value.ToString("N") : null + }; + + return _sessionManager.SendGeneralCommand(currentSession.Id, request.Id, command, CancellationToken.None); } /// /// Posts the specified request. /// /// The request. - public void Post(SendMessageCommand request) + public Task Post(SendMessageCommand request) { var command = new MessageCommand { @@ -425,16 +420,14 @@ namespace MediaBrowser.Api.Session Text = request.Text }; - var task = _sessionManager.SendMessageCommand(GetSession().Id, request.Id, command, CancellationToken.None); - - Task.WaitAll(task); + return _sessionManager.SendMessageCommand(GetSession().Id, request.Id, command, CancellationToken.None); } /// /// Posts the specified request. /// /// The request. - public void Post(Play request) + public Task Post(Play request) { var command = new PlayRequest { @@ -444,12 +437,10 @@ namespace MediaBrowser.Api.Session StartPositionTicks = request.StartPositionTicks }; - var task = _sessionManager.SendPlayCommand(GetSession().Id, request.Id, command, CancellationToken.None); - - Task.WaitAll(task); + return _sessionManager.SendPlayCommand(GetSession().Id, request.Id, command, CancellationToken.None); } - public void Post(SendGeneralCommand request) + public Task Post(SendGeneralCommand request) { var currentSession = GetSession(); @@ -459,20 +450,16 @@ namespace MediaBrowser.Api.Session ControllingUserId = currentSession.UserId.HasValue ? currentSession.UserId.Value.ToString("N") : null }; - var task = _sessionManager.SendGeneralCommand(currentSession.Id, request.Id, command, CancellationToken.None); - - Task.WaitAll(task); + return _sessionManager.SendGeneralCommand(currentSession.Id, request.Id, command, CancellationToken.None); } - public void Post(SendFullGeneralCommand request) + public Task Post(SendFullGeneralCommand request) { var currentSession = GetSession(); request.ControllingUserId = currentSession.UserId.HasValue ? currentSession.UserId.Value.ToString("N") : null; - var task = _sessionManager.SendGeneralCommand(currentSession.Id, request.Id, request, CancellationToken.None); - - Task.WaitAll(task); + return _sessionManager.SendGeneralCommand(currentSession.Id, request.Id, request, CancellationToken.None); } public void Post(AddUserToSession request) diff --git a/MediaBrowser.Server.Implementations/HttpServer/NetListener/HttpListenerServer.cs b/MediaBrowser.Server.Implementations/HttpServer/NetListener/HttpListenerServer.cs index 12106c32e..bdc2750fb 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/NetListener/HttpListenerServer.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/NetListener/HttpListenerServer.cs @@ -244,9 +244,14 @@ namespace MediaBrowser.Server.Implementations.HttpServer.NetListener { var log = new StringBuilder(); - //var headers = string.Join(",", request.Headers.AllKeys.Where(i => !string.Equals(i, "cookie", StringComparison.OrdinalIgnoreCase) && !string.Equals(i, "Referer", StringComparison.OrdinalIgnoreCase)).Select(k => k + "=" + request.Headers[k])); + var logHeaders = true; - //log.AppendLine("Ip: " + request.RemoteEndPoint + ". Headers: " + headers); + if (logHeaders) + { + var headers = string.Join(",", request.Headers.AllKeys.Where(i => !string.Equals(i, "cookie", StringComparison.OrdinalIgnoreCase) && !string.Equals(i, "Referer", StringComparison.OrdinalIgnoreCase)).Select(k => k + "=" + request.Headers[k])); + + log.AppendLine("Ip: " + request.RemoteEndPoint + ". Headers: " + headers); + } var type = request.IsWebSocketRequest ? "Web Socket" : "HTTP " + request.HttpMethod;