Merge branch 'release/3.0' => 'master' (#12855)
This commit is contained in:
commit
b6f1a50583
|
|
@ -226,7 +226,7 @@
|
||||||
<CastleCorePackageVersion>4.2.1</CastleCorePackageVersion>
|
<CastleCorePackageVersion>4.2.1</CastleCorePackageVersion>
|
||||||
<FSharpCorePackageVersion>4.2.1</FSharpCorePackageVersion>
|
<FSharpCorePackageVersion>4.2.1</FSharpCorePackageVersion>
|
||||||
<GoogleProtobufPackageVersion>3.8.0</GoogleProtobufPackageVersion>
|
<GoogleProtobufPackageVersion>3.8.0</GoogleProtobufPackageVersion>
|
||||||
<GrpcAspNetCorePackageVersion>0.1.22-pre2</GrpcAspNetCorePackageVersion>
|
<GrpcAspNetCorePackageVersion>0.1.22-pre3</GrpcAspNetCorePackageVersion>
|
||||||
<IdentityServer4AspNetIdentityPackageVersion>3.0.0-preview3.4</IdentityServer4AspNetIdentityPackageVersion>
|
<IdentityServer4AspNetIdentityPackageVersion>3.0.0-preview3.4</IdentityServer4AspNetIdentityPackageVersion>
|
||||||
<IdentityServer4EntityFrameworkPackageVersion>3.0.0-preview3.4</IdentityServer4EntityFrameworkPackageVersion>
|
<IdentityServer4EntityFrameworkPackageVersion>3.0.0-preview3.4</IdentityServer4EntityFrameworkPackageVersion>
|
||||||
<IdentityServer4PackageVersion>3.0.0-preview3.4</IdentityServer4PackageVersion>
|
<IdentityServer4PackageVersion>3.0.0-preview3.4</IdentityServer4PackageVersion>
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,8 @@ namespace GrpcService_CSharp
|
||||||
CreateHostBuilder(args).Build().Run();
|
CreateHostBuilder(args).Build().Run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Additional configuration is required to successfully run gRPC on macOS.
|
||||||
|
// For instructions on how to configure Kestrel and gRPC clients on macOS, visit https://go.microsoft.com/fwlink/?linkid=2099682
|
||||||
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
||||||
Host.CreateDefaultBuilder(args)
|
Host.CreateDefaultBuilder(args)
|
||||||
.ConfigureWebHostDefaults(webBuilder =>
|
.ConfigureWebHostDefaults(webBuilder =>
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
"SPA"
|
"SPA"
|
||||||
],
|
],
|
||||||
"groupIdentity": "Microsoft.DotNet.Web.Spa.ProjectTemplates.Angular",
|
"groupIdentity": "Microsoft.DotNet.Web.Spa.ProjectTemplates.Angular",
|
||||||
|
"precedence": "5000",
|
||||||
"identity": "Microsoft.DotNet.Web.Spa.ProjectTemplates.Angular.CSharp.3.0",
|
"identity": "Microsoft.DotNet.Web.Spa.ProjectTemplates.Angular.CSharp.3.0",
|
||||||
"name": "ASP.NET Core with Angular",
|
"name": "ASP.NET Core with Angular",
|
||||||
"preferNameDirectory": true,
|
"preferNameDirectory": true,
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
"SPA"
|
"SPA"
|
||||||
],
|
],
|
||||||
"groupIdentity": "Microsoft.DotNet.Web.Spa.ProjectTemplates.React",
|
"groupIdentity": "Microsoft.DotNet.Web.Spa.ProjectTemplates.React",
|
||||||
|
"precedence": "5000",
|
||||||
"identity": "Microsoft.DotNet.Web.Spa.ProjectTemplates.React.CSharp.3.0",
|
"identity": "Microsoft.DotNet.Web.Spa.ProjectTemplates.React.CSharp.3.0",
|
||||||
"name": "ASP.NET Core with React.js",
|
"name": "ASP.NET Core with React.js",
|
||||||
"preferNameDirectory": true,
|
"preferNameDirectory": true,
|
||||||
|
|
@ -189,7 +190,6 @@
|
||||||
"binding": "HostIdentifier"
|
"binding": "HostIdentifier"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
"tags": {
|
"tags": {
|
||||||
"language": "C#",
|
"language": "C#",
|
||||||
"type": "project"
|
"type": "project"
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
"SPA"
|
"SPA"
|
||||||
],
|
],
|
||||||
"groupIdentity": "Microsoft.DotNet.Web.Spa.ProjectTemplates.ReactRedux",
|
"groupIdentity": "Microsoft.DotNet.Web.Spa.ProjectTemplates.ReactRedux",
|
||||||
|
"precedence": "5000",
|
||||||
"identity": "Microsoft.DotNet.Web.Spa.ProjectTemplates.ReactRedux.CSharp.3.0",
|
"identity": "Microsoft.DotNet.Web.Spa.ProjectTemplates.ReactRedux.CSharp.3.0",
|
||||||
"name": "ASP.NET Core with React.js and Redux",
|
"name": "ASP.NET Core with React.js and Redux",
|
||||||
"preferNameDirectory": true,
|
"preferNameDirectory": true,
|
||||||
|
|
|
||||||
|
|
@ -144,6 +144,7 @@ namespace Microsoft.AspNetCore.SignalR
|
||||||
public HubConnectionContextOptions() { }
|
public HubConnectionContextOptions() { }
|
||||||
public System.TimeSpan ClientTimeoutInterval { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
|
public System.TimeSpan ClientTimeoutInterval { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
|
||||||
public System.TimeSpan KeepAliveInterval { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
|
public System.TimeSpan KeepAliveInterval { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
|
||||||
|
public long? MaximumReceiveMessageSize { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
|
||||||
public int StreamBufferCapacity { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
|
public int StreamBufferCapacity { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
|
||||||
}
|
}
|
||||||
public partial class HubConnectionHandler<THub> : Microsoft.AspNetCore.Connections.ConnectionHandler where THub : Microsoft.AspNetCore.SignalR.Hub
|
public partial class HubConnectionHandler<THub> : Microsoft.AspNetCore.Connections.ConnectionHandler where THub : Microsoft.AspNetCore.SignalR.Hub
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ namespace Microsoft.AspNetCore.SignalR
|
||||||
private bool _clientTimeoutActive;
|
private bool _clientTimeoutActive;
|
||||||
private bool _connectionAborted;
|
private bool _connectionAborted;
|
||||||
private int _streamBufferCapacity;
|
private int _streamBufferCapacity;
|
||||||
|
private long? _maxMessageSize;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="HubConnectionContext"/> class.
|
/// Initializes a new instance of the <see cref="HubConnectionContext"/> class.
|
||||||
|
|
@ -55,6 +56,7 @@ namespace Microsoft.AspNetCore.SignalR
|
||||||
_keepAliveInterval = contextOptions.KeepAliveInterval.Ticks;
|
_keepAliveInterval = contextOptions.KeepAliveInterval.Ticks;
|
||||||
_clientTimeoutInterval = contextOptions.ClientTimeoutInterval.Ticks;
|
_clientTimeoutInterval = contextOptions.ClientTimeoutInterval.Ticks;
|
||||||
_streamBufferCapacity = contextOptions.StreamBufferCapacity;
|
_streamBufferCapacity = contextOptions.StreamBufferCapacity;
|
||||||
|
_maxMessageSize = contextOptions.MaximumReceiveMessageSize;
|
||||||
|
|
||||||
_connectionContext = connectionContext;
|
_connectionContext = connectionContext;
|
||||||
_logger = loggerFactory.CreateLogger<HubConnectionContext>();
|
_logger = loggerFactory.CreateLogger<HubConnectionContext>();
|
||||||
|
|
@ -406,10 +408,20 @@ namespace Microsoft.AspNetCore.SignalR
|
||||||
|
|
||||||
if (!buffer.IsEmpty)
|
if (!buffer.IsEmpty)
|
||||||
{
|
{
|
||||||
if (HandshakeProtocol.TryParseRequestMessage(ref buffer, out var handshakeRequestMessage))
|
var segment = buffer;
|
||||||
|
var overLength = false;
|
||||||
|
|
||||||
|
if (_maxMessageSize != null && buffer.Length > _maxMessageSize.Value)
|
||||||
|
{
|
||||||
|
// We give the parser a sliding window of the default message size
|
||||||
|
segment = segment.Slice(segment.Start, _maxMessageSize.Value);
|
||||||
|
overLength = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (HandshakeProtocol.TryParseRequestMessage(ref segment, out var handshakeRequestMessage))
|
||||||
{
|
{
|
||||||
// We parsed the handshake
|
// We parsed the handshake
|
||||||
consumed = buffer.Start;
|
consumed = segment.Start;
|
||||||
examined = consumed;
|
examined = consumed;
|
||||||
|
|
||||||
Protocol = protocolResolver.GetProtocol(handshakeRequestMessage.Protocol, supportedProtocols);
|
Protocol = protocolResolver.GetProtocol(handshakeRequestMessage.Protocol, supportedProtocols);
|
||||||
|
|
@ -461,6 +473,12 @@ namespace Microsoft.AspNetCore.SignalR
|
||||||
await WriteHandshakeResponseAsync(HandshakeResponseMessage.Empty);
|
await WriteHandshakeResponseAsync(HandshakeResponseMessage.Empty);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else if (overLength)
|
||||||
|
{
|
||||||
|
Log.HandshakeSizeLimitExceeded(_logger, _maxMessageSize.Value);
|
||||||
|
await WriteHandshakeResponseAsync(new HandshakeResponseMessage("Handshake was canceled."));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result.IsCompleted)
|
if (result.IsCompleted)
|
||||||
|
|
@ -619,6 +637,9 @@ namespace Microsoft.AspNetCore.SignalR
|
||||||
private static readonly Action<ILogger, int, Exception> _clientTimeout =
|
private static readonly Action<ILogger, int, Exception> _clientTimeout =
|
||||||
LoggerMessage.Define<int>(LogLevel.Debug, new EventId(9, "ClientTimeout"), "Client timeout ({ClientTimeout}ms) elapsed without receiving a message from the client. Closing connection.");
|
LoggerMessage.Define<int>(LogLevel.Debug, new EventId(9, "ClientTimeout"), "Client timeout ({ClientTimeout}ms) elapsed without receiving a message from the client. Closing connection.");
|
||||||
|
|
||||||
|
private static readonly Action<ILogger, long, Exception> _handshakeSizeLimitExceeded =
|
||||||
|
LoggerMessage.Define<long>(LogLevel.Debug, new EventId(10, "HandshakeSizeLimitExceeded"), "The maximum message size of {MaxMessageSize}B was exceeded while parsing the Handshake. The message size can be configured in AddHubOptions.");
|
||||||
|
|
||||||
public static void HandshakeComplete(ILogger logger, string hubProtocol)
|
public static void HandshakeComplete(ILogger logger, string hubProtocol)
|
||||||
{
|
{
|
||||||
_handshakeComplete(logger, hubProtocol, null);
|
_handshakeComplete(logger, hubProtocol, null);
|
||||||
|
|
@ -663,6 +684,11 @@ namespace Microsoft.AspNetCore.SignalR
|
||||||
{
|
{
|
||||||
_clientTimeout(logger, (int)timeout.TotalMilliseconds, null);
|
_clientTimeout(logger, (int)timeout.TotalMilliseconds, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void HandshakeSizeLimitExceeded(ILogger logger, long maxMessageSize)
|
||||||
|
{
|
||||||
|
_handshakeSizeLimitExceeded(logger, maxMessageSize, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,5 +24,10 @@ namespace Microsoft.AspNetCore.SignalR
|
||||||
/// Gets or sets the max buffer size for client upload streams.
|
/// Gets or sets the max buffer size for client upload streams.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int StreamBufferCapacity { get; set; }
|
public int StreamBufferCapacity { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the maximum message size the client can send.
|
||||||
|
/// </summary>
|
||||||
|
public long? MaximumReceiveMessageSize { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -89,6 +89,7 @@ namespace Microsoft.AspNetCore.SignalR
|
||||||
KeepAliveInterval = _hubOptions.KeepAliveInterval ?? _globalHubOptions.KeepAliveInterval ?? HubOptionsSetup.DefaultKeepAliveInterval,
|
KeepAliveInterval = _hubOptions.KeepAliveInterval ?? _globalHubOptions.KeepAliveInterval ?? HubOptionsSetup.DefaultKeepAliveInterval,
|
||||||
ClientTimeoutInterval = _hubOptions.ClientTimeoutInterval ?? _globalHubOptions.ClientTimeoutInterval ?? HubOptionsSetup.DefaultClientTimeoutInterval,
|
ClientTimeoutInterval = _hubOptions.ClientTimeoutInterval ?? _globalHubOptions.ClientTimeoutInterval ?? HubOptionsSetup.DefaultClientTimeoutInterval,
|
||||||
StreamBufferCapacity = _hubOptions.StreamBufferCapacity ?? _globalHubOptions.StreamBufferCapacity ?? HubOptionsSetup.DefaultStreamBufferCapacity,
|
StreamBufferCapacity = _hubOptions.StreamBufferCapacity ?? _globalHubOptions.StreamBufferCapacity ?? HubOptionsSetup.DefaultStreamBufferCapacity,
|
||||||
|
MaximumReceiveMessageSize = _maximumMessageSize,
|
||||||
};
|
};
|
||||||
|
|
||||||
Log.ConnectedStarting(_logger);
|
Log.ConnectedStarting(_logger);
|
||||||
|
|
|
||||||
|
|
@ -292,6 +292,40 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task ConnectionClosedWhenHandshakeLargerThanMaxMessageSize()
|
||||||
|
{
|
||||||
|
using (StartVerifiableLog())
|
||||||
|
{
|
||||||
|
var connectionHandler = HubConnectionHandlerTestUtils.GetHubConnectionHandler(typeof(HubT), loggerFactory: LoggerFactory,
|
||||||
|
builder =>
|
||||||
|
{
|
||||||
|
builder.AddSignalR(o =>
|
||||||
|
{
|
||||||
|
o.MaximumReceiveMessageSize = 1;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
using (var client = new TestClient())
|
||||||
|
{
|
||||||
|
client.SupportedFormats = TransferFormat.Text;
|
||||||
|
|
||||||
|
var connectionHandlerTask = await client.ConnectAsync(connectionHandler,
|
||||||
|
sendHandshakeRequestMessage: true,
|
||||||
|
expectedHandshakeResponseMessage: false);
|
||||||
|
|
||||||
|
var message = await client.ReadAsync(isHandshake: true).OrTimeout();
|
||||||
|
|
||||||
|
Assert.Equal("Handshake was canceled.", ((HandshakeResponseMessage)message).Error);
|
||||||
|
|
||||||
|
// Connection closes
|
||||||
|
await connectionHandlerTask.OrTimeout();
|
||||||
|
|
||||||
|
client.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task SendingHandshakeRequestInChunksWorks()
|
public async Task SendingHandshakeRequestInChunksWorks()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue