Stop writing responses after the unexpected end of request content (#2734)
This commit is contained in:
parent
b934e46161
commit
603cd03bfa
|
|
@ -91,8 +91,15 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
|
||||||
// Read() will have already have greedily consumed the entire request body if able.
|
// Read() will have already have greedily consumed the entire request body if able.
|
||||||
if (result.IsCompleted)
|
if (result.IsCompleted)
|
||||||
{
|
{
|
||||||
|
// OnInputOrOutputCompleted() is an idempotent method that closes the connection. Sometimes
|
||||||
|
// input completion is observed here before the Input.OnWriterCompleted() callback is fired,
|
||||||
|
// so we call OnInputOrOutputCompleted() now to prevent a race in our tests where a 400
|
||||||
|
// response is written after observing the unexpected end of request content instead of just
|
||||||
|
// closing the connection without a response as expected.
|
||||||
|
_context.OnInputOrOutputCompleted();
|
||||||
|
|
||||||
// Treat any FIN from an upgraded request as expected.
|
// Treat any FIN from an upgraded request as expected.
|
||||||
// It's up to higher-level consumer (i.e. WebSocket middleware) to determine
|
// It's up to higher-level consumer (i.e. WebSocket middleware) to determine
|
||||||
// if the end is actually expected based on higher-level framing.
|
// if the end is actually expected based on higher-level framing.
|
||||||
if (RequestUpgrade)
|
if (RequestUpgrade)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1302,11 +1302,6 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
|
||||||
? target.GetAsciiStringEscaped(Constants.MaxExceptionDetailSize)
|
? target.GetAsciiStringEscaped(Constants.MaxExceptionDetailSize)
|
||||||
: string.Empty);
|
: string.Empty);
|
||||||
|
|
||||||
public void SetBadRequestState(RequestRejectionReason reason)
|
|
||||||
{
|
|
||||||
SetBadRequestState(BadHttpRequestException.GetException(reason));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetBadRequestState(BadHttpRequestException ex)
|
public void SetBadRequestState(BadHttpRequestException ex)
|
||||||
{
|
{
|
||||||
Log.ConnectionBadRequest(ConnectionId, ex);
|
Log.ConnectionBadRequest(ConnectionId, ex);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue