More optimal RequestMethod condition lookup
See gh-22644
This commit is contained in:
@@ -142,17 +142,19 @@ public final class RequestMethodsRequestCondition extends AbstractRequestConditi
|
||||
|
||||
@Nullable
|
||||
private RequestMethodsRequestCondition matchRequestMethod(String httpMethodValue) {
|
||||
HttpMethod httpMethod = HttpMethod.resolve(httpMethodValue);
|
||||
if (httpMethod != null) {
|
||||
for (RequestMethod method : getMethods()) {
|
||||
if (httpMethod.matches(method.name())) {
|
||||
return requestMethodConditionCache.get(method.name());
|
||||
}
|
||||
RequestMethod requestMethod;
|
||||
try {
|
||||
requestMethod = RequestMethod.valueOf(httpMethodValue);
|
||||
if (getMethods().contains(requestMethod)) {
|
||||
return requestMethodConditionCache.get(httpMethodValue);
|
||||
}
|
||||
if (httpMethod == HttpMethod.HEAD && getMethods().contains(RequestMethod.GET)) {
|
||||
if (requestMethod.equals(RequestMethod.HEAD) && getMethods().contains(RequestMethod.GET)) {
|
||||
return requestMethodConditionCache.get(HttpMethod.GET.name());
|
||||
}
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
// Custom request method
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user