[Fixes #6547] Re-introduce HttpMethodActionConstraint dictionary perf improvement
This commit is contained in:
parent
82e32240a4
commit
57c8b71b4d
|
|
@ -35,8 +35,9 @@ namespace Microsoft.AspNetCore.Mvc.Cors.Internal
|
|||
}
|
||||
|
||||
var request = context.RouteContext.HttpContext.Request;
|
||||
if (request.Headers.ContainsKey(OriginHeader) &&
|
||||
string.Equals(request.Method, PreflightHttpMethod, StringComparison.OrdinalIgnoreCase) &&
|
||||
// Perf: Check http method before accessing the Headers collection.
|
||||
if (string.Equals(request.Method, PreflightHttpMethod, StringComparison.OrdinalIgnoreCase) &&
|
||||
request.Headers.ContainsKey(OriginHeader) &&
|
||||
request.Headers.TryGetValue(AccessControlRequestMethod, out var accessControlRequestMethod) &&
|
||||
!StringValues.IsNullOrEmpty(accessControlRequestMethod))
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue