diff --git a/src/Security/Authentication/OpenIdConnect/samples/OpenIdConnectSample/Startup.cs b/src/Security/Authentication/OpenIdConnect/samples/OpenIdConnectSample/Startup.cs index 6d01fae4e9..5d4a94ec56 100644 --- a/src/Security/Authentication/OpenIdConnect/samples/OpenIdConnectSample/Startup.cs +++ b/src/Security/Authentication/OpenIdConnect/samples/OpenIdConnectSample/Startup.cs @@ -35,7 +35,7 @@ namespace OpenIdConnectSample private void CheckSameSite(HttpContext httpContext, CookieOptions options) { - if (options.SameSite > SameSiteMode.Unspecified) + if (options.SameSite == SameSiteMode.None) { var userAgent = httpContext.Request.Headers["User-Agent"]; // TODO: Use your User Agent library of choice here. diff --git a/src/Security/Authentication/test/WsFederation/WsFederationTest.cs b/src/Security/Authentication/test/WsFederation/WsFederationTest.cs index 6cc25f6dd5..1c4fc9e94d 100644 --- a/src/Security/Authentication/test/WsFederation/WsFederationTest.cs +++ b/src/Security/Authentication/test/WsFederation/WsFederationTest.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; @@ -440,4 +440,4 @@ namespace Microsoft.AspNetCore.Authentication.WsFederation } } } -} \ No newline at end of file +} diff --git a/src/SignalR/common/Http.Connections/src/Internal/TaskExtensions.cs b/src/SignalR/common/Http.Connections/src/Internal/TaskExtensions.cs index 9608a67272..efbbb4a239 100644 --- a/src/SignalR/common/Http.Connections/src/Internal/TaskExtensions.cs +++ b/src/SignalR/common/Http.Connections/src/Internal/TaskExtensions.cs @@ -1,6 +1,8 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + using System.Runtime.CompilerServices; + namespace System.Threading.Tasks { internal static class TaskExtensions @@ -21,4 +23,4 @@ namespace System.Threading.Tasks public void OnCompleted(Action continuation) => _task.GetAwaiter().OnCompleted(continuation); public void UnsafeOnCompleted(Action continuation) => OnCompleted(continuation); } -} \ No newline at end of file +} diff --git a/src/SignalR/common/Http.Connections/src/Internal/Transports/LongPollingServerTransport.cs b/src/SignalR/common/Http.Connections/src/Internal/Transports/LongPollingServerTransport.cs index 3432e37039..8ecf395276 100644 --- a/src/SignalR/common/Http.Connections/src/Internal/Transports/LongPollingServerTransport.cs +++ b/src/SignalR/common/Http.Connections/src/Internal/Transports/LongPollingServerTransport.cs @@ -40,24 +40,24 @@ namespace Microsoft.AspNetCore.Http.Connections.Internal.Transports var result = await _application.ReadAsync(token); var buffer = result.Buffer; - if (buffer.IsEmpty && (result.IsCompleted || result.IsCanceled)) - { - Log.LongPolling204(_logger); - context.Response.ContentType = "text/plain"; - context.Response.StatusCode = StatusCodes.Status204NoContent; - return; - } - - // We're intentionally not checking cancellation here because we need to drain messages we've got so far, - // but it's too late to emit the 204 required by being canceled. - - Log.LongPollingWritingMessage(_logger, buffer.Length); - - context.Response.ContentLength = buffer.Length; - context.Response.ContentType = "application/octet-stream"; - try { + if (buffer.IsEmpty && (result.IsCompleted || result.IsCanceled)) + { + Log.LongPolling204(_logger); + context.Response.ContentType = "text/plain"; + context.Response.StatusCode = StatusCodes.Status204NoContent; + return; + } + + // We're intentionally not checking cancellation here because we need to drain messages we've got so far, + // but it's too late to emit the 204 required by being canceled. + + Log.LongPollingWritingMessage(_logger, buffer.Length); + + context.Response.ContentLength = buffer.Length; + context.Response.ContentType = "application/octet-stream"; + _connection?.StartSendCancellation(); await context.Response.Body.WriteAsync(buffer, _connection?.SendingToken ?? default); } diff --git a/src/SignalR/common/Http.Connections/test/HttpConnectionDispatcherTests.cs b/src/SignalR/common/Http.Connections/test/HttpConnectionDispatcherTests.cs index 2dabe1adbc..33d72eddc2 100644 --- a/src/SignalR/common/Http.Connections/test/HttpConnectionDispatcherTests.cs +++ b/src/SignalR/common/Http.Connections/test/HttpConnectionDispatcherTests.cs @@ -1098,7 +1098,6 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests await _sync.WaitToContinue(); cancellationToken.ThrowIfCancellationRequested(); } -#if NETCOREAPP2_1 public override async ValueTask WriteAsync(ReadOnlyMemory buffer, CancellationToken cancellationToken = default) { if (_isSSE) @@ -1110,7 +1109,6 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests await _sync.WaitToContinue(); cancellationToken.ThrowIfCancellationRequested(); } -#endif } [Fact] diff --git a/src/SignalR/common/Shared/PipeWriterStream.cs b/src/SignalR/common/Shared/PipeWriterStream.cs index 2afdc723d2..43474433f4 100644 --- a/src/SignalR/common/Shared/PipeWriterStream.cs +++ b/src/SignalR/common/Shared/PipeWriterStream.cs @@ -74,7 +74,6 @@ namespace System.IO.Pipelines _length += source.Length; var task = _pipeWriter.WriteAsync(source); - if (task.IsCompletedSuccessfully) { // Cancellation can be triggered by PipeWriter.CancelPendingFlush diff --git a/src/SignalR/common/testassets/Tests.Utils/VerifyNoErrorsScope.cs b/src/SignalR/common/testassets/Tests.Utils/VerifyNoErrorsScope.cs index f23712c8d5..7aa1c4544f 100644 --- a/src/SignalR/common/testassets/Tests.Utils/VerifyNoErrorsScope.cs +++ b/src/SignalR/common/testassets/Tests.Utils/VerifyNoErrorsScope.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; @@ -62,4 +62,4 @@ namespace Microsoft.AspNetCore.SignalR.Tests } } } -} \ No newline at end of file +} diff --git a/src/SignalR/server/Core/src/HubConnectionContext.cs b/src/SignalR/server/Core/src/HubConnectionContext.cs index 11e05c177c..1dc7ad89c4 100644 --- a/src/SignalR/server/Core/src/HubConnectionContext.cs +++ b/src/SignalR/server/Core/src/HubConnectionContext.cs @@ -318,6 +318,7 @@ namespace Microsoft.AspNetCore.SignalR return default; } + // TODO: cancel? return new ValueTask(TryWritePingSlowAsync()); }