diff --git a/spring-web/src/main/java/org/springframework/http/ReadOnlyHttpHeaders.java b/spring-web/src/main/java/org/springframework/http/ReadOnlyHttpHeaders.java index 341938f1ba2..c3dedaa241b 100644 --- a/spring-web/src/main/java/org/springframework/http/ReadOnlyHttpHeaders.java +++ b/spring-web/src/main/java/org/springframework/http/ReadOnlyHttpHeaders.java @@ -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. @@ -40,10 +40,15 @@ class ReadOnlyHttpHeaders extends HttpHeaders { @Nullable private MediaType cachedContentType; + @Nullable + private List cachedAccept; + + ReadOnlyHttpHeaders(HttpHeaders headers) { super(headers.headers); } + @Override public MediaType getContentType() { if (this.cachedContentType != null) { @@ -56,6 +61,18 @@ class ReadOnlyHttpHeaders extends HttpHeaders { } } + @Override + public List getAccept() { + if (this.cachedAccept != null) { + return this.cachedAccept; + } + else { + List accept = super.getAccept(); + this.cachedAccept = accept; + return accept; + } + } + @Override public List get(Object key) { List values = this.headers.get(key); diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/condition/ConsumesRequestCondition.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/condition/ConsumesRequestCondition.java index f41bad10245..815b2b844bd 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/condition/ConsumesRequestCondition.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/condition/ConsumesRequestCondition.java @@ -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 { - private static final ConsumesRequestCondition PRE_FLIGHT_MATCH = new ConsumesRequestCondition(); + private static final ConsumesRequestCondition EMPTY_CONDITION = new ConsumesRequestCondition(); private final List expressions; @@ -161,7 +161,7 @@ public final class ConsumesRequestCondition extends AbstractRequestCondition { - 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 result = new LinkedHashSet<>(this.expressions); result.removeIf(expression -> !expression.match(exchange)); diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/RequestMappingInfo.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/RequestMappingInfo.java index 795dc53185d..ae9dfc3d5d2 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/RequestMappingInfo.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/RequestMappingInfo.java @@ -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. @@ -216,25 +216,34 @@ public final class RequestMappingInfo implements RequestCondition { - private static final ConsumesRequestCondition PRE_FLIGHT_MATCH = new ConsumesRequestCondition(); + private static final ConsumesRequestCondition EMPTY_CONDITION = new ConsumesRequestCondition(); private final List expressions; @@ -163,7 +163,7 @@ public final class ConsumesRequestCondition extends AbstractRequestCondition { - private static final ProducesRequestCondition PRE_FLIGHT_MATCH = new ProducesRequestCondition(); - private static final ProducesRequestCondition EMPTY_CONDITION = new ProducesRequestCondition(); private static final List MEDIA_TYPE_ALL_LIST = @@ -187,11 +185,8 @@ public final class ProducesRequestCondition extends AbstractRequestCondition acceptedMediaTypes; diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/RequestMappingInfo.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/RequestMappingInfo.java index 29a1d638255..70eb0e57b7c 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/RequestMappingInfo.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/RequestMappingInfo.java @@ -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. @@ -217,20 +217,29 @@ public final class RequestMappingInfo implements RequestCondition