parent
c6df7eb644
commit
3f771ef0bc
|
|
@ -12,15 +12,14 @@ using System.Text;
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Http.Features;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Internal.System;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Internal.System.IO.Pipelines;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Internal.System.Text.Encodings.Web.Utf8;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions;
|
||||
using Microsoft.Extensions.Internal;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Primitives;
|
||||
using Microsoft.AspNetCore.Http.Features;
|
||||
|
||||
// ReSharper disable AccessToModifiedClosure
|
||||
|
||||
|
|
@ -526,7 +525,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
|
|||
{
|
||||
if (data.Count == 0)
|
||||
{
|
||||
return TaskCache.CompletedTask;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
return WriteChunkedAsync(data, cancellationToken);
|
||||
}
|
||||
|
|
@ -539,7 +538,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
|
|||
else
|
||||
{
|
||||
HandleNonBodyResponseWrite();
|
||||
return TaskCache.CompletedTask;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -665,7 +664,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
|
|||
{
|
||||
if (HasResponseStarted)
|
||||
{
|
||||
return TaskCache.CompletedTask;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
if (_onStarting != null)
|
||||
|
|
@ -681,7 +680,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
|
|||
VerifyAndUpdateWrite(firstWriteByteCount);
|
||||
ProduceStart(appCompleted: false);
|
||||
|
||||
return TaskCache.CompletedTask;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private async Task InitializeResponseAwaited(int firstWriteByteCount)
|
||||
|
|
@ -716,7 +715,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
|
|||
return ProduceEnd();
|
||||
}
|
||||
|
||||
return TaskCache.CompletedTask;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
protected Task ProduceEnd()
|
||||
|
|
@ -727,7 +726,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
|
|||
{
|
||||
// We can no longer change the response, so we simply close the connection.
|
||||
_requestProcessingStopping = true;
|
||||
return TaskCache.CompletedTask;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
// If the request was rejected, the error state has already been set by SetBadRequestState and
|
||||
|
|
@ -780,7 +779,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
|
|||
Log.ConnectionHeadResponseBodyWrite(ConnectionId, _responseBytesWritten);
|
||||
}
|
||||
|
||||
return TaskCache.CompletedTask;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private async Task WriteAutoChunkSuffixAwaited()
|
||||
|
|
|
|||
|
|
@ -3,12 +3,10 @@
|
|||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.ExceptionServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions;
|
||||
using Microsoft.Extensions.Internal;
|
||||
|
||||
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
|
||||
{
|
||||
|
|
@ -42,7 +40,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
|
|||
public override Task FlushAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
// No-op.
|
||||
return TaskCache.CompletedTask;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public override long Seek(long offset, SeekOrigin origin)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ using System.Threading;
|
|||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Internal.System.IO.Pipelines;
|
||||
using Microsoft.Extensions.Internal;
|
||||
|
||||
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
|
||||
{
|
||||
|
|
@ -110,7 +109,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
|
|||
{
|
||||
if (_completed)
|
||||
{
|
||||
return TaskCache.CompletedTask;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
writableBuffer = _pipe.Writer.Alloc(1);
|
||||
|
|
@ -143,7 +142,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
|
|||
if (awaitable.IsCompleted)
|
||||
{
|
||||
// The flush task can't fail today
|
||||
return TaskCache.CompletedTask;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
return FlushAsyncAwaited(awaitable, cancellationToken);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@
|
|||
<PackageReference Include="Microsoft.Net.Http.Headers" Version="$(AspNetCoreVersion)" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="$(AspNetCoreVersion)" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options" Version="$(AspNetCoreVersion)" />
|
||||
<PackageReference Include="Microsoft.Extensions.TaskCache.Sources" Version="$(AspNetCoreVersion)" PrivateAssets="All" />
|
||||
<PackageReference Include="System.Threading.Tasks.Extensions" Version="$(CoreFxVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
|||
|
|
@ -5,12 +5,13 @@ using System;
|
|||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Internal;
|
||||
|
||||
namespace Microsoft.AspNetCore.Server.Kestrel.Https.Internal
|
||||
{
|
||||
internal class ClosedStream : Stream
|
||||
{
|
||||
private static readonly Task<int> ZeroResultTask = Task.FromResult(result: 0);
|
||||
|
||||
public override bool CanRead => true;
|
||||
public override bool CanSeek => false;
|
||||
public override bool CanWrite => false;
|
||||
|
|
@ -56,7 +57,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Https.Internal
|
|||
|
||||
public override Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
|
||||
{
|
||||
return TaskCache<int>.DefaultCompletedTask;
|
||||
return ZeroResultTask;
|
||||
}
|
||||
|
||||
public override void Write(byte[] buffer, int offset, int count)
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="$(AspNetCoreVersion)" />
|
||||
<PackageReference Include="Microsoft.Extensions.TaskCache.Sources" Version="$(AspNetCoreVersion)" PrivateAssets="All" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="$(AspNetCoreVersion)" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="$(AspNetCoreVersion)" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options" Version="$(AspNetCoreVersion)" />
|
||||
<PackageReference Include="Microsoft.Extensions.TaskCache.Sources" Version="$(AspNetCoreVersion)" PrivateAssets="All" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http;
|
|||
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Internal.System.IO.Pipelines;
|
||||
using Microsoft.AspNetCore.Testing;
|
||||
using Microsoft.Extensions.Internal;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Primitives;
|
||||
using Moq;
|
||||
|
|
@ -240,7 +239,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
|
||||
// Act/Assert
|
||||
Assert.True(_frame.HasResponseStarted);
|
||||
Assert.Throws<InvalidOperationException>(() => ((IHttpResponseFeature)_frame).OnStarting(_ => TaskCache.CompletedTask, null));
|
||||
Assert.Throws<InvalidOperationException>(() => ((IHttpResponseFeature)_frame).OnStarting(_ => Task.CompletedTask, null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -5,12 +5,12 @@ using System;
|
|||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting.Server;
|
||||
using Microsoft.AspNetCore.Hosting.Server.Features;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions;
|
||||
using Microsoft.AspNetCore.Testing;
|
||||
using Microsoft.Extensions.Internal;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Moq;
|
||||
|
|
@ -161,7 +161,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
|
||||
private static void StartDummyApplication(IServer server)
|
||||
{
|
||||
server.StartAsync(new DummyApplication(context => TaskCache.CompletedTask), CancellationToken.None).GetAwaiter().GetResult();
|
||||
server.StartAsync(new DummyApplication(context => Task.CompletedTask), CancellationToken.None).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
private class MockTransportFactory : ITransportFactory
|
||||
|
|
|
|||
|
|
@ -9,14 +9,10 @@ using System.Text;
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http;
|
||||
using Microsoft.AspNetCore.Testing;
|
||||
using Microsoft.Extensions.Internal;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Moq;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
using Xunit.Sdk;
|
||||
|
||||
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
||||
|
|
@ -398,7 +394,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
writeTcs.SetResult(buffer);
|
||||
writeCount++;
|
||||
})
|
||||
.Returns(TaskCache.CompletedTask);
|
||||
.Returns(Task.CompletedTask);
|
||||
|
||||
using (var input = new TestInput())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ using System;
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http;
|
||||
using Microsoft.Extensions.Internal;
|
||||
|
||||
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests.TestHelpers
|
||||
{
|
||||
|
|
@ -13,7 +12,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests.TestHelpers
|
|||
{
|
||||
public Task FlushAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
return TaskCache.CompletedTask;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public void ProduceContinue()
|
||||
|
|
@ -22,7 +21,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests.TestHelpers
|
|||
|
||||
public Task WriteAsync(ArraySegment<byte> data, CancellationToken cancellationToken)
|
||||
{
|
||||
return TaskCache.CompletedTask;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,17 +2,12 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Internal.System.IO.Pipelines;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions;
|
||||
using Microsoft.AspNetCore.Testing;
|
||||
using Microsoft.Extensions.Internal;
|
||||
using Moq;
|
||||
|
||||
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
||||
{
|
||||
|
|
@ -82,12 +77,12 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
|
||||
Task IFrameControl.WriteAsync(ArraySegment<byte> data, CancellationToken cancellationToken)
|
||||
{
|
||||
return TaskCache.CompletedTask;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
Task IFrameControl.FlushAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
return TaskCache.CompletedTask;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ using Microsoft.AspNetCore.Server.Kestrel.Core;
|
|||
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
|
||||
using Microsoft.AspNetCore.Testing;
|
||||
using Microsoft.Extensions.Internal;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Moq;
|
||||
using Xunit;
|
||||
|
|
@ -181,7 +180,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
.Setup(trace => trace.ConnectionBadRequest(It.IsAny<string>(), It.IsAny<BadHttpRequestException>()))
|
||||
.Callback<string, BadHttpRequestException>((connectionId, exception) => loggedException = exception);
|
||||
|
||||
using (var server = new TestServer(context => TaskCache.CompletedTask, new TestServiceContext { Log = mockKestrelTrace.Object }))
|
||||
using (var server = new TestServer(context => Task.CompletedTask, new TestServiceContext { Log = mockKestrelTrace.Object }))
|
||||
{
|
||||
using (var connection = server.CreateConnection())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ using System.Threading.Tasks;
|
|||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Core;
|
||||
using Microsoft.AspNetCore.Testing;
|
||||
using Microsoft.Extensions.Internal;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
||||
|
|
@ -538,7 +537,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
var testContext = new TestServiceContext();
|
||||
using (var server = new TestServer(httpContext =>
|
||||
{
|
||||
return TaskCache.CompletedTask;
|
||||
return Task.CompletedTask;
|
||||
}, testContext, listenOptions))
|
||||
{
|
||||
using (var connection = server.CreateConnection())
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Testing;
|
||||
using Microsoft.Extensions.Internal;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
||||
|
|
@ -18,7 +17,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
ServerOptions = { AddServerHeader = true }
|
||||
};
|
||||
|
||||
using (var server = new TestServer(ctx => TaskCache.CompletedTask, testContext))
|
||||
using (var server = new TestServer(ctx => Task.CompletedTask, testContext))
|
||||
{
|
||||
using (var connection = server.CreateConnection())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ using Microsoft.AspNetCore.Http.Features;
|
|||
using Microsoft.AspNetCore.Server.Kestrel.Core;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Https;
|
||||
using Microsoft.AspNetCore.Testing;
|
||||
using Microsoft.Extensions.Internal;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
||||
|
|
@ -126,7 +125,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
}
|
||||
};
|
||||
|
||||
using (var server = new TestServer(context => TaskCache.CompletedTask, serviceContext, listenOptions))
|
||||
using (var server = new TestServer(context => Task.CompletedTask, serviceContext, listenOptions))
|
||||
{
|
||||
using (var client = new TcpClient())
|
||||
{
|
||||
|
|
@ -256,7 +255,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
}
|
||||
};
|
||||
|
||||
using (var server = new TestServer(context => TaskCache.CompletedTask, serviceContext, listenOptions))
|
||||
using (var server = new TestServer(context => Task.CompletedTask, serviceContext, listenOptions))
|
||||
{
|
||||
using (var client = new TcpClient())
|
||||
{
|
||||
|
|
@ -287,7 +286,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
}
|
||||
};
|
||||
|
||||
using (var server = new TestServer(context => TaskCache.CompletedTask, serviceContext, listenOptions))
|
||||
using (var server = new TestServer(context => Task.CompletedTask, serviceContext, listenOptions))
|
||||
{
|
||||
using (var client = new TcpClient())
|
||||
{
|
||||
|
|
@ -316,7 +315,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
}
|
||||
};
|
||||
|
||||
using (var server = new TestServer(context => TaskCache.CompletedTask, serviceContext, listenOptions))
|
||||
using (var server = new TestServer(context => Task.CompletedTask, serviceContext, listenOptions))
|
||||
{
|
||||
using (var client = new TcpClient())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http;
|
|||
using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions;
|
||||
using Microsoft.AspNetCore.Testing;
|
||||
using Microsoft.AspNetCore.Testing.xunit;
|
||||
using Microsoft.Extensions.Internal;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Moq;
|
||||
using Newtonsoft.Json;
|
||||
|
|
@ -291,7 +290,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
.Setup(factory => factory.CreateLogger(It.IsIn("Microsoft.AspNetCore.Server.Kestrel", "Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv")))
|
||||
.Returns(mockLogger.Object);
|
||||
|
||||
using (var server = new TestServer(context => TaskCache.CompletedTask, new TestServiceContext(mockLoggerFactory.Object)))
|
||||
using (var server = new TestServer(context => Task.CompletedTask, new TestServiceContext(mockLoggerFactory.Object)))
|
||||
{
|
||||
using (var connection = server.CreateConnection())
|
||||
{
|
||||
|
|
@ -345,7 +344,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
.Setup(factory => factory.CreateLogger(It.IsIn("Microsoft.AspNetCore.Server.Kestrel", "Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv")))
|
||||
.Returns(mockLogger.Object);
|
||||
|
||||
using (var server = new TestServer(context => TaskCache.CompletedTask, new TestServiceContext(mockLoggerFactory.Object)))
|
||||
using (var server = new TestServer(context => Task.CompletedTask, new TestServiceContext(mockLoggerFactory.Object)))
|
||||
{
|
||||
using (var connection = server.CreateConnection())
|
||||
{
|
||||
|
|
@ -1105,7 +1104,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
Assert.Same(originalRequestHeaders, requestFeature.Headers);
|
||||
}
|
||||
|
||||
return TaskCache.CompletedTask;
|
||||
return Task.CompletedTask;
|
||||
}, testContext, listenOptions))
|
||||
{
|
||||
using (var connection = server.CreateConnection())
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http;
|
|||
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
|
||||
using Microsoft.AspNetCore.Testing;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Internal;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Primitives;
|
||||
using Moq;
|
||||
|
|
@ -182,7 +181,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
{
|
||||
await context.Response.WriteAsync("hello, world");
|
||||
await context.Response.Body.FlushAsync();
|
||||
ex = Assert.Throws<InvalidOperationException>(() => context.Response.OnStarting(_ => TaskCache.CompletedTask, null));
|
||||
ex = Assert.Throws<InvalidOperationException>(() => context.Response.OnStarting(_ => Task.CompletedTask, null));
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -220,7 +219,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
context =>
|
||||
{
|
||||
context.Abort();
|
||||
return TaskCache.CompletedTask;
|
||||
return Task.CompletedTask;
|
||||
},
|
||||
expectedClientStatusCode: null,
|
||||
expectedServerStatusCode: 0);
|
||||
|
|
@ -245,7 +244,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
return ResponseStatusCodeSetBeforeHttpContextDispose(
|
||||
context =>
|
||||
{
|
||||
return TaskCache.CompletedTask;
|
||||
return Task.CompletedTask;
|
||||
},
|
||||
expectedClientStatusCode: null,
|
||||
expectedServerStatusCode: HttpStatusCode.BadRequest,
|
||||
|
|
@ -421,7 +420,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
using (var server = new TestServer(httpContext =>
|
||||
{
|
||||
httpContext.Response.StatusCode = statusCode;
|
||||
return TaskCache.CompletedTask;
|
||||
return Task.CompletedTask;
|
||||
}))
|
||||
{
|
||||
using (var connection = server.CreateConnection())
|
||||
|
|
@ -445,7 +444,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
{
|
||||
using (var server = new TestServer(httpContext =>
|
||||
{
|
||||
return TaskCache.CompletedTask;
|
||||
return Task.CompletedTask;
|
||||
}))
|
||||
{
|
||||
using (var connection = server.CreateConnection())
|
||||
|
|
@ -516,7 +515,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
httpContext.Response.ContentLength = 11;
|
||||
httpContext.Response.Body.Write(Encoding.ASCII.GetBytes("hello,"), 0, 6);
|
||||
httpContext.Response.Body.Write(Encoding.ASCII.GetBytes(" world"), 0, 6);
|
||||
return TaskCache.CompletedTask;
|
||||
return Task.CompletedTask;
|
||||
}, serviceContext))
|
||||
{
|
||||
using (var connection = server.CreateConnection())
|
||||
|
|
@ -592,7 +591,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
var response = Encoding.ASCII.GetBytes("hello, world");
|
||||
httpContext.Response.ContentLength = 5;
|
||||
httpContext.Response.Body.Write(response, 0, response.Length);
|
||||
return TaskCache.CompletedTask;
|
||||
return Task.CompletedTask;
|
||||
}, serviceContext))
|
||||
{
|
||||
using (var connection = server.CreateConnection())
|
||||
|
|
@ -764,7 +763,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
using (var server = new TestServer(httpContext =>
|
||||
{
|
||||
httpContext.Response.ContentLength = 5;
|
||||
return TaskCache.CompletedTask;
|
||||
return Task.CompletedTask;
|
||||
}, serviceContext))
|
||||
{
|
||||
using (var connection = server.CreateConnection())
|
||||
|
|
@ -912,7 +911,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
using (var server = new TestServer(httpContext =>
|
||||
{
|
||||
httpContext.Response.ContentLength = 42;
|
||||
return TaskCache.CompletedTask;
|
||||
return Task.CompletedTask;
|
||||
}))
|
||||
{
|
||||
using (var connection = server.CreateConnection())
|
||||
|
|
@ -973,7 +972,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
httpContext.Response.ContentLength = 12;
|
||||
httpContext.Response.Body.Write(Encoding.ASCII.GetBytes("hello, world"), 0, 12);
|
||||
flushed.Wait();
|
||||
return TaskCache.CompletedTask;
|
||||
return Task.CompletedTask;
|
||||
}))
|
||||
{
|
||||
using (var connection = server.CreateConnection())
|
||||
|
|
@ -1255,7 +1254,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
{
|
||||
// Change response to chunked
|
||||
httpContext.Response.ContentLength = null;
|
||||
return TaskCache.CompletedTask;
|
||||
return Task.CompletedTask;
|
||||
});
|
||||
|
||||
var response = Encoding.ASCII.GetBytes("hello, world");
|
||||
|
|
@ -1263,7 +1262,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
|
||||
// If OnStarting is not run before verifying writes, an error response will be sent.
|
||||
httpContext.Response.Body.Write(response, 0, response.Length);
|
||||
return TaskCache.CompletedTask;
|
||||
return Task.CompletedTask;
|
||||
}))
|
||||
{
|
||||
using (var connection = server.CreateConnection())
|
||||
|
|
@ -1296,7 +1295,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
{
|
||||
// Change response to chunked
|
||||
httpContext.Response.ContentLength = null;
|
||||
return TaskCache.CompletedTask;
|
||||
return Task.CompletedTask;
|
||||
});
|
||||
|
||||
var response = Encoding.ASCII.GetBytes("hello, world");
|
||||
|
|
@ -1305,7 +1304,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
// If OnStarting is not run before verifying writes, an error response will be sent.
|
||||
httpContext.Response.Body.Write(response, 0, response.Length / 2);
|
||||
httpContext.Response.Body.Write(response, response.Length / 2, response.Length - response.Length / 2);
|
||||
return TaskCache.CompletedTask;
|
||||
return Task.CompletedTask;
|
||||
}))
|
||||
{
|
||||
using (var connection = server.CreateConnection())
|
||||
|
|
@ -1340,7 +1339,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
{
|
||||
// Change response to chunked
|
||||
httpContext.Response.ContentLength = null;
|
||||
return TaskCache.CompletedTask;
|
||||
return Task.CompletedTask;
|
||||
});
|
||||
|
||||
var response = Encoding.ASCII.GetBytes("hello, world");
|
||||
|
|
@ -1380,7 +1379,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
{
|
||||
// Change response to chunked
|
||||
httpContext.Response.ContentLength = null;
|
||||
return TaskCache.CompletedTask;
|
||||
return Task.CompletedTask;
|
||||
});
|
||||
|
||||
var response = Encoding.ASCII.GetBytes("hello, world");
|
||||
|
|
@ -1454,7 +1453,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
[Fact]
|
||||
public async Task WhenResponseNotStartedResponseEndedAfterConsumingRequestBody()
|
||||
{
|
||||
using (var server = new TestServer(httpContext => TaskCache.CompletedTask))
|
||||
using (var server = new TestServer(httpContext => Task.CompletedTask))
|
||||
{
|
||||
using (var connection = server.CreateConnection())
|
||||
{
|
||||
|
|
@ -1822,7 +1821,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
response.OnStarting(_ =>
|
||||
{
|
||||
onStartingCalled = true;
|
||||
return TaskCache.CompletedTask;
|
||||
return Task.CompletedTask;
|
||||
}, null);
|
||||
|
||||
// Anything added to the ResponseHeaders dictionary is ignored
|
||||
|
|
@ -2166,7 +2165,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
using (var server = new TestServer(httpContext =>
|
||||
{
|
||||
httpContext.Abort();
|
||||
return TaskCache.CompletedTask;
|
||||
return Task.CompletedTask;
|
||||
}, testContext, listenOptions))
|
||||
{
|
||||
using (var connection = server.CreateConnection())
|
||||
|
|
@ -2205,7 +2204,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
Assert.Same(originalResponseHeaders, responseFeature.Headers);
|
||||
}
|
||||
|
||||
return TaskCache.CompletedTask;
|
||||
return Task.CompletedTask;
|
||||
}, testContext, listenOptions))
|
||||
{
|
||||
using (var connection = server.CreateConnection())
|
||||
|
|
@ -2249,12 +2248,12 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
{
|
||||
callOrder.Push(1);
|
||||
onStartingTcs.SetResult(null);
|
||||
return TaskCache.CompletedTask;
|
||||
return Task.CompletedTask;
|
||||
}, null);
|
||||
context.Response.OnStarting(_ =>
|
||||
{
|
||||
callOrder.Push(2);
|
||||
return TaskCache.CompletedTask;
|
||||
return Task.CompletedTask;
|
||||
}, null);
|
||||
|
||||
context.Response.ContentLength = response.Length;
|
||||
|
|
@ -2301,12 +2300,12 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
{
|
||||
callOrder.Push(1);
|
||||
onCompletedTcs.SetResult(null);
|
||||
return TaskCache.CompletedTask;
|
||||
return Task.CompletedTask;
|
||||
}, null);
|
||||
context.Response.OnCompleted(_ =>
|
||||
{
|
||||
callOrder.Push(2);
|
||||
return TaskCache.CompletedTask;
|
||||
return Task.CompletedTask;
|
||||
}, null);
|
||||
|
||||
context.Response.ContentLength = response.Length;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ using Microsoft.AspNetCore.Server.Kestrel.Core;
|
|||
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Tests;
|
||||
using Microsoft.AspNetCore.Testing;
|
||||
using Microsoft.Extensions.Internal;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
|
|
@ -154,7 +153,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
[Fact]
|
||||
public async Task RejectsRequestWithContentLengthAndUpgrade()
|
||||
{
|
||||
using (var server = new TestServer(context => TaskCache.CompletedTask))
|
||||
using (var server = new TestServer(context => Task.CompletedTask))
|
||||
using (var connection = server.CreateConnection())
|
||||
{
|
||||
await connection.Send("POST / HTTP/1.1",
|
||||
|
|
@ -177,7 +176,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
[Fact]
|
||||
public async Task AcceptsRequestWithNoContentLengthAndUpgrade()
|
||||
{
|
||||
using (var server = new TestServer(context => TaskCache.CompletedTask))
|
||||
using (var server = new TestServer(context => Task.CompletedTask))
|
||||
{
|
||||
using (var connection = server.CreateConnection())
|
||||
{
|
||||
|
|
@ -201,7 +200,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
[Fact]
|
||||
public async Task RejectsRequestWithChunkedEncodingAndUpgrade()
|
||||
{
|
||||
using (var server = new TestServer(context => TaskCache.CompletedTask))
|
||||
using (var server = new TestServer(context => Task.CompletedTask))
|
||||
using (var connection = server.CreateConnection())
|
||||
{
|
||||
await connection.Send("POST / HTTP/1.1",
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.Internal;
|
||||
|
||||
namespace Microsoft.AspNetCore.Testing
|
||||
{
|
||||
|
|
@ -43,7 +42,7 @@ namespace Microsoft.AspNetCore.Testing
|
|||
|
||||
public static Task EmptyApp(HttpContext httpContext)
|
||||
{
|
||||
return TaskCache.CompletedTask;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue