Fix more test failures caused by connection resets
- Avoid sending data that won't be processed.
This commit is contained in:
parent
6cbbb73ca7
commit
8591900849
|
|
@ -340,15 +340,12 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task SingleErrorResponseSentWhenAppSwallowsBadRequestException()
|
public async Task SingleErrorResponseSentWhenAppSwallowsBadRequestException()
|
||||||
{
|
{
|
||||||
|
BadHttpRequestException readException = null;
|
||||||
|
|
||||||
using (var server = new TestServer(async httpContext =>
|
using (var server = new TestServer(async httpContext =>
|
||||||
{
|
{
|
||||||
try
|
readException = await Assert.ThrowsAsync<BadHttpRequestException>(
|
||||||
{
|
async () => await httpContext.Request.Body.ReadAsync(new byte[1], 0, 1));
|
||||||
await httpContext.Request.Body.ReadAsync(new byte[1], 0, 1);
|
|
||||||
}
|
|
||||||
catch (BadHttpRequestException)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}, new TestServiceContext()))
|
}, new TestServiceContext()))
|
||||||
{
|
{
|
||||||
using (var connection = server.CreateConnection())
|
using (var connection = server.CreateConnection())
|
||||||
|
|
@ -357,8 +354,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
||||||
"POST / HTTP/1.1",
|
"POST / HTTP/1.1",
|
||||||
"Transfer-Encoding: chunked",
|
"Transfer-Encoding: chunked",
|
||||||
"",
|
"",
|
||||||
"g",
|
"gg");
|
||||||
"");
|
|
||||||
await connection.ReceiveForcedEnd(
|
await connection.ReceiveForcedEnd(
|
||||||
"HTTP/1.1 400 Bad Request",
|
"HTTP/1.1 400 Bad Request",
|
||||||
"Connection: close",
|
"Connection: close",
|
||||||
|
|
@ -368,6 +364,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
||||||
"");
|
"");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Assert.NotNull(readException);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue