Merge branch 'rel/2.0.0' into dev
This commit is contained in:
commit
09c92d61d0
|
|
@ -75,17 +75,13 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Adapter.Internal
|
|||
|
||||
public override async Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken token)
|
||||
{
|
||||
ArraySegment<byte> segment;
|
||||
var output = _output.Alloc();
|
||||
|
||||
if (buffer != null)
|
||||
{
|
||||
segment = new ArraySegment<byte>(buffer, offset, count);
|
||||
output.Write(new ArraySegment<byte>(buffer, offset, count));
|
||||
}
|
||||
else
|
||||
{
|
||||
segment = default(ArraySegment<byte>);
|
||||
}
|
||||
var output = _output.Alloc();
|
||||
output.Write(segment);
|
||||
|
||||
await output.FlushAsync(token);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -81,10 +81,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal
|
|||
private static void ConnectCallback(UvConnectRequest connect, int status, UvException error, TaskCompletionSource<int> tcs)
|
||||
{
|
||||
var listener = (ListenerSecondary)tcs.Task.AsyncState;
|
||||
listener.ConnectedCallback(connect, status, error, tcs);
|
||||
_ = listener.ConnectedCallback(connect, status, error, tcs);
|
||||
}
|
||||
|
||||
private async void ConnectedCallback(UvConnectRequest connect, int status, UvException error, TaskCompletionSource<int> tcs)
|
||||
private async Task ConnectedCallback(UvConnectRequest connect, int status, UvException error, TaskCompletionSource<int> tcs)
|
||||
{
|
||||
connect.Dispose();
|
||||
if (error != null)
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets
|
|||
_remoteEndPoint = (IPEndPoint)_socket.RemoteEndPoint;
|
||||
}
|
||||
|
||||
public async void Start(IConnectionHandler connectionHandler)
|
||||
public async Task StartAsync(IConnectionHandler connectionHandler)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets
|
|||
acceptSocket.NoDelay = _endPointInformation.NoDelay;
|
||||
|
||||
var connection = new SocketConnection(acceptSocket, this);
|
||||
connection.Start(_handler);
|
||||
_ = connection.StartAsync(_handler);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ using System.Net;
|
|||
using System.Net.Sockets;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Core;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Core.Adapter.Internal;
|
||||
using Microsoft.AspNetCore.Testing;
|
||||
|
|
@ -172,6 +173,39 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task CanFlushAsyncWithConnectionAdapter()
|
||||
{
|
||||
var listenOptions = new ListenOptions(new IPEndPoint(IPAddress.Loopback, 0))
|
||||
{
|
||||
ConnectionAdapters = { new PassThroughConnectionAdapter() }
|
||||
};
|
||||
|
||||
var serviceContext = new TestServiceContext();
|
||||
|
||||
using (var server = new TestServer(async context =>
|
||||
{
|
||||
await context.Response.WriteAsync("Hello ");
|
||||
await context.Response.Body.FlushAsync();
|
||||
await context.Response.WriteAsync("World!");
|
||||
}, serviceContext, listenOptions))
|
||||
{
|
||||
using (var connection = server.CreateConnection())
|
||||
{
|
||||
await connection.Send(
|
||||
"GET / HTTP/1.0",
|
||||
"",
|
||||
"");
|
||||
await connection.ReceiveEnd(
|
||||
"HTTP/1.1 200 OK",
|
||||
"Connection: close",
|
||||
$"Date: {serviceContext.DateHeaderValue}",
|
||||
"",
|
||||
"Hello World!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class RewritingConnectionAdapter : IConnectionAdapter
|
||||
{
|
||||
private RewritingStream _rewritingStream;
|
||||
|
|
|
|||
Loading…
Reference in New Issue