Avoid boxing context.Method (#5687)
This commit is contained in:
parent
cb1917aa59
commit
8be8e0008d
|
|
@ -280,16 +280,12 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
|
||||||
return new ForContentLength(keepAlive, contentLength, context);
|
return new ForContentLength(keepAlive, contentLength, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Avoid slowing down most common case
|
// If we got here, request contains no Content-Length or Transfer-Encoding header.
|
||||||
if (!object.ReferenceEquals(context.Method, HttpMethods.Get))
|
// Reject with 411 Length Required.
|
||||||
|
if (context.Method == HttpMethod.Post || context.Method == HttpMethod.Put)
|
||||||
{
|
{
|
||||||
// If we got here, request contains no Content-Length or Transfer-Encoding header.
|
var requestRejectionReason = httpVersion == HttpVersion.Http11 ? RequestRejectionReason.LengthRequired : RequestRejectionReason.LengthRequiredHttp10;
|
||||||
// Reject with 411 Length Required.
|
BadHttpRequestException.Throw(requestRejectionReason, context.Method);
|
||||||
if (context.Method == HttpMethod.Post || context.Method == HttpMethod.Put)
|
|
||||||
{
|
|
||||||
var requestRejectionReason = httpVersion == HttpVersion.Http11 ? RequestRejectionReason.LengthRequired : RequestRejectionReason.LengthRequiredHttp10;
|
|
||||||
BadHttpRequestException.Throw(requestRejectionReason, context.Method);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return keepAlive ? MessageBody.ZeroContentLengthKeepAlive : MessageBody.ZeroContentLengthClose;
|
return keepAlive ? MessageBody.ZeroContentLengthKeepAlive : MessageBody.ZeroContentLengthClose;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue