-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
Labels
api-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implementedarea-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractionsIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions
Milestone
Description
Background and Motivation
According to pull request #54247, CorsConstants only contain AnyOrigin value
This is while it also needs AnyHeaders and AnyMethods because, unlike AnyOrigin, the value "*" is used directly in other places.
Proposed API
My changes are like this:
namespace Microsoft.AspNetCore.Cors.Infrastructure;
public static class CorsConstants
{
+ public static readonly string AnyHeader = "*";
+ public static readonly string AnyMethod = "*";
}Usage Examples
public bool AllowAnyHeader
{
get
{
if (Headers == null || Headers.Count != 1 || Headers[0] != CorsConstants.AnyHeader)
{
return false;
}
return true;
}
}
public bool AllowAnyMethod
{
get
{
if (Methods == null || Methods.Count != 1 || Methods[0] != CorsConstants.AnyMethod)
{
return false;
}
return true;
}
}Instead of using this form:
public bool AllowAnyHeader
{
get
{
if (Headers == null || Headers.Count != 1 || Headers[0] != "*")
{
return false;
}
return true;
}
}
public bool AllowAnyMethod
{
get
{
if (Methods == null || Methods.Count != 1 || Methods[0] != "*")
{
return false;
}
return true;
}
}Metadata
Metadata
Assignees
Labels
api-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implementedarea-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractionsIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions