Polish
See gh-22598
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -41,12 +41,14 @@ class ReadOnlyHttpHeaders extends HttpHeaders {
|
||||
private MediaType cachedContentType;
|
||||
|
||||
@Nullable
|
||||
private MediaType cachedAccept;
|
||||
private List<MediaType> cachedAccept;
|
||||
|
||||
|
||||
ReadOnlyHttpHeaders(HttpHeaders headers) {
|
||||
super(headers.headers);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public MediaType getContentType() {
|
||||
if (this.cachedContentType != null) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -43,7 +43,7 @@ import org.springframework.web.server.UnsupportedMediaTypeStatusException;
|
||||
*/
|
||||
public final class ConsumesRequestCondition extends AbstractRequestCondition<ConsumesRequestCondition> {
|
||||
|
||||
private static final ConsumesRequestCondition PRE_FLIGHT_MATCH = new ConsumesRequestCondition();
|
||||
private static final ConsumesRequestCondition EMPTY_CONDITION = new ConsumesRequestCondition();
|
||||
|
||||
|
||||
private final List<ConsumeMediaTypeExpression> expressions;
|
||||
@@ -161,7 +161,7 @@ public final class ConsumesRequestCondition extends AbstractRequestCondition<Con
|
||||
@Override
|
||||
public ConsumesRequestCondition getMatchingCondition(ServerWebExchange exchange) {
|
||||
if (CorsUtils.isPreFlightRequest(exchange.getRequest())) {
|
||||
return PRE_FLIGHT_MATCH;
|
||||
return EMPTY_CONDITION;
|
||||
}
|
||||
if (isEmpty()) {
|
||||
return this;
|
||||
|
||||
@@ -47,8 +47,6 @@ import org.springframework.web.server.UnsupportedMediaTypeStatusException;
|
||||
*/
|
||||
public final class ProducesRequestCondition extends AbstractRequestCondition<ProducesRequestCondition> {
|
||||
|
||||
private static final ProducesRequestCondition PRE_FLIGHT_MATCH = new ProducesRequestCondition();
|
||||
|
||||
private static final ProducesRequestCondition EMPTY_CONDITION = new ProducesRequestCondition();
|
||||
|
||||
|
||||
@@ -187,11 +185,8 @@ public final class ProducesRequestCondition extends AbstractRequestCondition<Pro
|
||||
@Override
|
||||
@Nullable
|
||||
public ProducesRequestCondition getMatchingCondition(ServerWebExchange exchange) {
|
||||
if (CorsUtils.isPreFlightRequest(exchange.getRequest())) {
|
||||
return PRE_FLIGHT_MATCH;
|
||||
}
|
||||
if (isEmpty()) {
|
||||
return this;
|
||||
if (isEmpty() || CorsUtils.isPreFlightRequest(exchange.getRequest())) {
|
||||
return EMPTY_CONDITION;
|
||||
}
|
||||
Set<ProduceMediaTypeExpression> result = new LinkedHashSet<>(this.expressions);
|
||||
result.removeIf(expression -> !expression.match(exchange));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -227,10 +227,7 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping
|
||||
if (headers == null) {
|
||||
return null;
|
||||
}
|
||||
PatternsRequestCondition patterns = this.patternsCondition.getMatchingCondition(exchange);
|
||||
if (patterns == null) {
|
||||
return null;
|
||||
}
|
||||
// Match "Content-Type" and "Accept" (parsed ones and cached) before patterns
|
||||
ConsumesRequestCondition consumes = this.consumesCondition.getMatchingCondition(exchange);
|
||||
if (consumes == null) {
|
||||
return null;
|
||||
@@ -239,11 +236,14 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping
|
||||
if (produces == null) {
|
||||
return null;
|
||||
}
|
||||
PatternsRequestCondition patterns = this.patternsCondition.getMatchingCondition(exchange);
|
||||
if (patterns == null) {
|
||||
return null;
|
||||
}
|
||||
RequestConditionHolder custom = this.customConditionHolder.getMatchingCondition(exchange);
|
||||
if (custom == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new RequestMappingInfo(this.name, patterns,
|
||||
methods, params, headers, consumes, produces, custom.getCondition());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -46,7 +46,7 @@ import org.springframework.web.servlet.mvc.condition.HeadersRequestCondition.Hea
|
||||
*/
|
||||
public final class ConsumesRequestCondition extends AbstractRequestCondition<ConsumesRequestCondition> {
|
||||
|
||||
private static final ConsumesRequestCondition PRE_FLIGHT_MATCH = new ConsumesRequestCondition();
|
||||
private static final ConsumesRequestCondition EMPTY_CONDITION = new ConsumesRequestCondition();
|
||||
|
||||
private final List<ConsumeMediaTypeExpression> expressions;
|
||||
|
||||
@@ -163,7 +163,7 @@ public final class ConsumesRequestCondition extends AbstractRequestCondition<Con
|
||||
@Nullable
|
||||
public ConsumesRequestCondition getMatchingCondition(HttpServletRequest request) {
|
||||
if (CorsUtils.isPreFlightRequest(request)) {
|
||||
return PRE_FLIGHT_MATCH;
|
||||
return EMPTY_CONDITION;
|
||||
}
|
||||
if (isEmpty()) {
|
||||
return this;
|
||||
|
||||
@@ -47,8 +47,6 @@ import org.springframework.web.servlet.mvc.condition.HeadersRequestCondition.Hea
|
||||
*/
|
||||
public final class ProducesRequestCondition extends AbstractRequestCondition<ProducesRequestCondition> {
|
||||
|
||||
private static final ProducesRequestCondition PRE_FLIGHT_MATCH = new ProducesRequestCondition();
|
||||
|
||||
private static final ProducesRequestCondition EMPTY_CONDITION = new ProducesRequestCondition();
|
||||
|
||||
private static final List<ProduceMediaTypeExpression> MEDIA_TYPE_ALL_LIST =
|
||||
@@ -187,11 +185,8 @@ public final class ProducesRequestCondition extends AbstractRequestCondition<Pro
|
||||
@Override
|
||||
@Nullable
|
||||
public ProducesRequestCondition getMatchingCondition(HttpServletRequest request) {
|
||||
if (CorsUtils.isPreFlightRequest(request)) {
|
||||
return PRE_FLIGHT_MATCH;
|
||||
}
|
||||
if (isEmpty()) {
|
||||
return this;
|
||||
if (isEmpty() || CorsUtils.isPreFlightRequest(request)) {
|
||||
return EMPTY_CONDITION;
|
||||
}
|
||||
|
||||
List<MediaType> acceptedMediaTypes;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -228,10 +228,6 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping
|
||||
if (headers == null) {
|
||||
return null;
|
||||
}
|
||||
PatternsRequestCondition patterns = this.patternsCondition.getMatchingCondition(request);
|
||||
if (patterns == null) {
|
||||
return null;
|
||||
}
|
||||
ConsumesRequestCondition consumes = this.consumesCondition.getMatchingCondition(request);
|
||||
if (consumes == null) {
|
||||
return null;
|
||||
@@ -240,6 +236,10 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping
|
||||
if (produces == null) {
|
||||
return null;
|
||||
}
|
||||
PatternsRequestCondition patterns = this.patternsCondition.getMatchingCondition(request);
|
||||
if (patterns == null) {
|
||||
return null;
|
||||
}
|
||||
RequestConditionHolder custom = this.customConditionHolder.getMatchingCondition(request);
|
||||
if (custom == null) {
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user