mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2026-04-22 22:34:53 -04:00
Upgraded SignalR to 1.2.2
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Security.Principal;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.SignalR.Hosting;
|
||||
using Microsoft.AspNet.SignalR.Owin.Infrastructure;
|
||||
@@ -65,9 +66,19 @@ namespace Microsoft.AspNet.SignalR.Owin
|
||||
|
||||
if (!_connection.Authorize(serverRequest))
|
||||
{
|
||||
// If we failed to authorize the request then return a 403 since the request
|
||||
// can't do anything
|
||||
return EndResponse(environment, 403, "Forbidden");
|
||||
IPrincipal user = hostContext.Request.User;
|
||||
if (user != null && user.Identity.IsAuthenticated)
|
||||
{
|
||||
// If we failed to authorize the request then return a 403 since the request
|
||||
// can't do anything
|
||||
return EndResponse(environment, 403, "Forbidden");
|
||||
}
|
||||
else
|
||||
{
|
||||
// If we failed to authorize the request and the user is not authenticated
|
||||
// then return a 401
|
||||
return EndResponse(environment, 401, "Unauthorized");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -7,6 +7,7 @@ using System.Security.Principal;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.SignalR.Owin.Infrastructure;
|
||||
using Microsoft.AspNet.SignalR.Hosting;
|
||||
|
||||
namespace Microsoft.AspNet.SignalR.Owin
|
||||
{
|
||||
@@ -138,15 +139,17 @@ namespace Microsoft.AspNet.SignalR.Owin
|
||||
}
|
||||
|
||||
#if NET45
|
||||
public Task AcceptWebSocketRequest(Func<IWebSocket, Task> callback)
|
||||
public Task AcceptWebSocketRequest(Func<IWebSocket, Task> callback, Task initTask)
|
||||
{
|
||||
var accept = _environment.Get<Action<IDictionary<string, object>, WebSocketFunc>>(OwinConstants.WebSocketAccept);
|
||||
if (accept == null)
|
||||
{
|
||||
throw new InvalidOperationException(Resources.Error_NotWebSocketRequest);
|
||||
var response = new ServerResponse(_environment);
|
||||
response.StatusCode = 400;
|
||||
return response.End(Resources.Error_NotWebSocketRequest);
|
||||
}
|
||||
|
||||
var handler = new OwinWebSocketHandler(callback);
|
||||
var handler = new OwinWebSocketHandler(callback, initTask);
|
||||
accept(null, handler.ProcessRequestAsync);
|
||||
return TaskAsyncHelper.Empty;
|
||||
}
|
||||
|
||||
@@ -27,6 +27,18 @@ namespace Microsoft.AspNet.SignalR.Owin
|
||||
get { return _callCancelled; }
|
||||
}
|
||||
|
||||
public int StatusCode
|
||||
{
|
||||
get
|
||||
{
|
||||
return _environment.Get<int>(OwinConstants.ResponseStatusCode);
|
||||
}
|
||||
set
|
||||
{
|
||||
_environment[OwinConstants.ResponseStatusCode] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string ContentType
|
||||
{
|
||||
get { return ResponseHeaders.GetHeader("Content-Type"); }
|
||||
|
||||
Reference in New Issue
Block a user