log request headers

pull/702/head
Luke Pulverenti 10 years ago
parent de03365201
commit a55449628b

@ -466,24 +466,10 @@ namespace MediaBrowser.Api.Library
/// Deletes the specified request. /// Deletes the specified request.
/// </summary> /// </summary>
/// <param name="request">The request.</param> /// <param name="request">The request.</param>
public void Delete(DeleteItem request) public Task Delete(DeleteItem request)
{
var task = DeleteItem(request);
Task.WaitAll(task);
}
private Task DeleteItem(DeleteItem request)
{ {
var item = _libraryManager.GetItemById(request.Id); 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); return _libraryManager.DeleteItem(item);
} }

@ -297,9 +297,9 @@ namespace MediaBrowser.Api.Session
Task.WaitAll(task); 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, AppName = request.App,
IsActive = true, IsActive = true,
@ -307,8 +307,6 @@ namespace MediaBrowser.Api.Session
DateCreated = DateTime.UtcNow DateCreated = DateTime.UtcNow
}, CancellationToken.None); }, CancellationToken.None);
Task.WaitAll(task);
} }
public void Post(ReportSessionEnded request) public void Post(ReportSessionEnded request)
@ -357,7 +355,7 @@ namespace MediaBrowser.Api.Session
return ToOptimizedResult(result.Select(_sessionManager.GetSessionInfoDto).ToList()); return ToOptimizedResult(result.Select(_sessionManager.GetSessionInfoDto).ToList());
} }
public void Post(SendPlaystateCommand request) public Task Post(SendPlaystateCommand request)
{ {
var command = new PlaystateRequest var command = new PlaystateRequest
{ {
@ -365,16 +363,14 @@ namespace MediaBrowser.Api.Session
SeekPositionTicks = request.SeekPositionTicks SeekPositionTicks = request.SeekPositionTicks
}; };
var task = _sessionManager.SendPlaystateCommand(GetSession().Id, request.Id, command, CancellationToken.None); return _sessionManager.SendPlaystateCommand(GetSession().Id, request.Id, command, CancellationToken.None);
Task.WaitAll(task);
} }
/// <summary> /// <summary>
/// Posts the specified request. /// Posts the specified request.
/// </summary> /// </summary>
/// <param name="request">The request.</param> /// <param name="request">The request.</param>
public void Post(DisplayContent request) public Task Post(DisplayContent request)
{ {
var command = new BrowseRequest var command = new BrowseRequest
{ {
@ -383,40 +379,39 @@ namespace MediaBrowser.Api.Session
ItemType = request.ItemType ItemType = request.ItemType
}; };
var task = _sessionManager.SendBrowseCommand(GetSession().Id, request.Id, command, CancellationToken.None); return _sessionManager.SendBrowseCommand(GetSession().Id, request.Id, command, CancellationToken.None);
Task.WaitAll(task);
} }
/// <summary> /// <summary>
/// Posts the specified request. /// Posts the specified request.
/// </summary> /// </summary>
/// <param name="request">The request.</param> /// <param name="request">The request.</param>
public void Post(SendSystemCommand request) public Task Post(SendSystemCommand request)
{ {
GeneralCommandType commandType; GeneralCommandType commandType;
var name = request.Command;
if (Enum.TryParse(request.Command, true, out commandType)) if (Enum.TryParse(name, true, out commandType))
{ {
name = commandType.ToString();
}
var currentSession = GetSession(); var currentSession = GetSession();
var command = new GeneralCommand var command = new GeneralCommand
{ {
Name = commandType.ToString(), Name = name,
ControllingUserId = currentSession.UserId.HasValue ? currentSession.UserId.Value.ToString("N") : null ControllingUserId = currentSession.UserId.HasValue ? currentSession.UserId.Value.ToString("N") : null
}; };
var task = _sessionManager.SendGeneralCommand(currentSession.Id, request.Id, command, CancellationToken.None); return _sessionManager.SendGeneralCommand(currentSession.Id, request.Id, command, CancellationToken.None);
Task.WaitAll(task);
}
} }
/// <summary> /// <summary>
/// Posts the specified request. /// Posts the specified request.
/// </summary> /// </summary>
/// <param name="request">The request.</param> /// <param name="request">The request.</param>
public void Post(SendMessageCommand request) public Task Post(SendMessageCommand request)
{ {
var command = new MessageCommand var command = new MessageCommand
{ {
@ -425,16 +420,14 @@ namespace MediaBrowser.Api.Session
Text = request.Text Text = request.Text
}; };
var task = _sessionManager.SendMessageCommand(GetSession().Id, request.Id, command, CancellationToken.None); return _sessionManager.SendMessageCommand(GetSession().Id, request.Id, command, CancellationToken.None);
Task.WaitAll(task);
} }
/// <summary> /// <summary>
/// Posts the specified request. /// Posts the specified request.
/// </summary> /// </summary>
/// <param name="request">The request.</param> /// <param name="request">The request.</param>
public void Post(Play request) public Task Post(Play request)
{ {
var command = new PlayRequest var command = new PlayRequest
{ {
@ -444,12 +437,10 @@ namespace MediaBrowser.Api.Session
StartPositionTicks = request.StartPositionTicks StartPositionTicks = request.StartPositionTicks
}; };
var task = _sessionManager.SendPlayCommand(GetSession().Id, request.Id, command, CancellationToken.None); return _sessionManager.SendPlayCommand(GetSession().Id, request.Id, command, CancellationToken.None);
Task.WaitAll(task);
} }
public void Post(SendGeneralCommand request) public Task Post(SendGeneralCommand request)
{ {
var currentSession = GetSession(); var currentSession = GetSession();
@ -459,20 +450,16 @@ namespace MediaBrowser.Api.Session
ControllingUserId = currentSession.UserId.HasValue ? currentSession.UserId.Value.ToString("N") : null ControllingUserId = currentSession.UserId.HasValue ? currentSession.UserId.Value.ToString("N") : null
}; };
var task = _sessionManager.SendGeneralCommand(currentSession.Id, request.Id, command, CancellationToken.None); return _sessionManager.SendGeneralCommand(currentSession.Id, request.Id, command, CancellationToken.None);
Task.WaitAll(task);
} }
public void Post(SendFullGeneralCommand request) public Task Post(SendFullGeneralCommand request)
{ {
var currentSession = GetSession(); var currentSession = GetSession();
request.ControllingUserId = currentSession.UserId.HasValue ? currentSession.UserId.Value.ToString("N") : null; request.ControllingUserId = currentSession.UserId.HasValue ? currentSession.UserId.Value.ToString("N") : null;
var task = _sessionManager.SendGeneralCommand(currentSession.Id, request.Id, request, CancellationToken.None); return _sessionManager.SendGeneralCommand(currentSession.Id, request.Id, request, CancellationToken.None);
Task.WaitAll(task);
} }
public void Post(AddUserToSession request) public void Post(AddUserToSession request)

@ -244,9 +244,14 @@ namespace MediaBrowser.Server.Implementations.HttpServer.NetListener
{ {
var log = new StringBuilder(); 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; var type = request.IsWebSocketRequest ? "Web Socket" : "HTTP " + request.HttpMethod;

Loading…
Cancel
Save