Skip to content

Merge 2.1 into 3.1 #18369

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jan 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public Startup(IConfiguration config, IWebHostEnvironment env)

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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -440,4 +440,4 @@ protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage reques
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -21,4 +23,4 @@ public static async Task NoThrow(this Task task)
public void OnCompleted(Action continuation) => _task.GetAwaiter().OnCompleted(continuation);
public void UnsafeOnCompleted(Action continuation) => OnCompleted(continuation);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,24 @@ public async Task ProcessRequestAsync(HttpContext context, CancellationToken tok
var result = await _application.ReadAsync(token);
var buffer = result.Buffer;

if (buffer.IsEmpty && (result.IsCompleted || result.IsCanceled))
try
{
Log.LongPolling204(_logger);
context.Response.ContentType = "text/plain";
context.Response.StatusCode = StatusCodes.Status204NoContent;
return;
}
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.
// 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);
Log.LongPollingWritingMessage(_logger, buffer.Length);

context.Response.ContentLength = buffer.Length;
context.Response.ContentType = "application/octet-stream";
context.Response.ContentLength = buffer.Length;
context.Response.ContentType = "application/octet-stream";

try
{
_connection?.StartSendCancellation();
await context.Response.Body.WriteAsync(buffer, _connection?.SendingToken ?? default);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1098,7 +1098,6 @@ public override async Task WriteAsync(byte[] buffer, int offset, int count, Canc
await _sync.WaitToContinue();
cancellationToken.ThrowIfCancellationRequested();
}
#if NETCOREAPP2_1
public override async ValueTask WriteAsync(ReadOnlyMemory<byte> buffer, CancellationToken cancellationToken = default)
{
if (_isSSE)
Expand All @@ -1110,7 +1109,6 @@ public override async ValueTask WriteAsync(ReadOnlyMemory<byte> buffer, Cancella
await _sync.WaitToContinue();
cancellationToken.ThrowIfCancellationRequested();
}
#endif
}

[Fact]
Expand Down
1 change: 0 additions & 1 deletion src/SignalR/common/Shared/PipeWriterStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ private ValueTask WriteCoreAsync(ReadOnlyMemory<byte> source, CancellationToken

_length += source.Length;
var task = _pipeWriter.WriteAsync(source);

if (task.IsCompletedSuccessfully)
{
// Cancellation can be triggered by PipeWriter.CancelPendingFlush
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -62,4 +62,4 @@ public void Dispose()
}
}
}
}
}
1 change: 1 addition & 0 deletions src/SignalR/server/Core/src/HubConnectionContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ private ValueTask TryWritePingAsync()
return default;
}

// TODO: cancel?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BrennanConroy anything to be concerned about here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha, not really

return new ValueTask(TryWritePingSlowAsync());
}

Expand Down