From 8cb7e026e20b67461d084e15ccb9d5b267c9cafe Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 30 Nov 2016 11:12:06 +0100 Subject: [PATCH] HttpRequestPathHelper in new web.server.support package In general, web.util is supposed to remain lowest-level, not depending on any other web.* package. Since web.client also has a support package, a corresponding web.server.support package seemed appropriate for a helper class depending on ServerWebExchange in web.server itself. --- .../web/reactive/config/PathMatchConfigurer.java | 3 ++- .../web/reactive/handler/AbstractHandlerMapping.java | 3 ++- .../web/reactive/resource/ResourceUrlProvider.java | 2 +- .../result/condition/PatternsRequestCondition.java | 2 +- .../web/reactive/result/method/RequestMappingInfo.java | 4 ++-- .../reactive/result/view/ViewResolutionResultHandler.java | 2 +- .../method/RequestMappingInfoHandlerMappingTests.java | 2 +- .../cors/reactive/UrlBasedCorsConfigurationSource.java | 2 +- .../{util => server/support}/HttpRequestPathHelper.java | 8 +++++--- .../springframework/web/server/support/package-info.java | 5 +++++ 10 files changed, 21 insertions(+), 12 deletions(-) rename spring-web/src/main/java/org/springframework/web/{util => server/support}/HttpRequestPathHelper.java (96%) create mode 100644 spring-web/src/main/java/org/springframework/web/server/support/package-info.java diff --git a/spring-web-reactive/src/main/java/org/springframework/web/reactive/config/PathMatchConfigurer.java b/spring-web-reactive/src/main/java/org/springframework/web/reactive/config/PathMatchConfigurer.java index 535d7fe905..32e5b1ac2c 100644 --- a/spring-web-reactive/src/main/java/org/springframework/web/reactive/config/PathMatchConfigurer.java +++ b/spring-web-reactive/src/main/java/org/springframework/web/reactive/config/PathMatchConfigurer.java @@ -13,10 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.web.reactive.config; import org.springframework.util.PathMatcher; -import org.springframework.web.util.HttpRequestPathHelper; +import org.springframework.web.server.support.HttpRequestPathHelper; /** * Assist with configuring {@code HandlerMapping}'s with path matching options. diff --git a/spring-web-reactive/src/main/java/org/springframework/web/reactive/handler/AbstractHandlerMapping.java b/spring-web-reactive/src/main/java/org/springframework/web/reactive/handler/AbstractHandlerMapping.java index b7423f5136..7de183cc0b 100644 --- a/spring-web-reactive/src/main/java/org/springframework/web/reactive/handler/AbstractHandlerMapping.java +++ b/spring-web-reactive/src/main/java/org/springframework/web/reactive/handler/AbstractHandlerMapping.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.web.reactive.handler; import java.util.Map; @@ -33,7 +34,7 @@ import org.springframework.web.cors.reactive.UrlBasedCorsConfigurationSource; import org.springframework.web.reactive.HandlerMapping; import org.springframework.web.server.ServerWebExchange; import org.springframework.web.server.WebHandler; -import org.springframework.web.util.HttpRequestPathHelper; +import org.springframework.web.server.support.HttpRequestPathHelper; /** * Abstract base class for {@link org.springframework.web.reactive.HandlerMapping} diff --git a/spring-web-reactive/src/main/java/org/springframework/web/reactive/resource/ResourceUrlProvider.java b/spring-web-reactive/src/main/java/org/springframework/web/reactive/resource/ResourceUrlProvider.java index 21a340b524..950e870019 100644 --- a/spring-web-reactive/src/main/java/org/springframework/web/reactive/resource/ResourceUrlProvider.java +++ b/spring-web-reactive/src/main/java/org/springframework/web/reactive/resource/ResourceUrlProvider.java @@ -37,7 +37,7 @@ import org.springframework.util.AntPathMatcher; import org.springframework.util.PathMatcher; import org.springframework.web.reactive.handler.SimpleUrlHandlerMapping; import org.springframework.web.server.ServerWebExchange; -import org.springframework.web.util.HttpRequestPathHelper; +import org.springframework.web.server.support.HttpRequestPathHelper; /** * A central component to use to obtain the public URL path that clients should diff --git a/spring-web-reactive/src/main/java/org/springframework/web/reactive/result/condition/PatternsRequestCondition.java b/spring-web-reactive/src/main/java/org/springframework/web/reactive/result/condition/PatternsRequestCondition.java index 6865671a06..82797a3182 100644 --- a/spring-web-reactive/src/main/java/org/springframework/web/reactive/result/condition/PatternsRequestCondition.java +++ b/spring-web-reactive/src/main/java/org/springframework/web/reactive/result/condition/PatternsRequestCondition.java @@ -31,7 +31,7 @@ import org.springframework.util.AntPathMatcher; import org.springframework.util.PathMatcher; import org.springframework.util.StringUtils; import org.springframework.web.server.ServerWebExchange; -import org.springframework.web.util.HttpRequestPathHelper; +import org.springframework.web.server.support.HttpRequestPathHelper; /** * A logical disjunction (' || ') request condition that matches a request diff --git a/spring-web-reactive/src/main/java/org/springframework/web/reactive/result/method/RequestMappingInfo.java b/spring-web-reactive/src/main/java/org/springframework/web/reactive/result/method/RequestMappingInfo.java index a618e97f6b..6dfe57170a 100644 --- a/spring-web-reactive/src/main/java/org/springframework/web/reactive/result/method/RequestMappingInfo.java +++ b/spring-web-reactive/src/main/java/org/springframework/web/reactive/result/method/RequestMappingInfo.java @@ -21,8 +21,8 @@ import java.util.Set; import org.springframework.util.PathMatcher; import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.reactive.accept.RequestedContentTypeResolver; import org.springframework.web.reactive.accept.MappingContentTypeResolver; +import org.springframework.web.reactive.accept.RequestedContentTypeResolver; import org.springframework.web.reactive.result.condition.ConsumesRequestCondition; import org.springframework.web.reactive.result.condition.HeadersRequestCondition; import org.springframework.web.reactive.result.condition.ParamsRequestCondition; @@ -32,7 +32,7 @@ import org.springframework.web.reactive.result.condition.RequestCondition; import org.springframework.web.reactive.result.condition.RequestConditionHolder; import org.springframework.web.reactive.result.condition.RequestMethodsRequestCondition; import org.springframework.web.server.ServerWebExchange; -import org.springframework.web.util.HttpRequestPathHelper; +import org.springframework.web.server.support.HttpRequestPathHelper; /** * Encapsulates the following request mapping conditions: diff --git a/spring-web-reactive/src/main/java/org/springframework/web/reactive/result/view/ViewResolutionResultHandler.java b/spring-web-reactive/src/main/java/org/springframework/web/reactive/result/view/ViewResolutionResultHandler.java index 184d4c81de..8d52bb7a2b 100644 --- a/spring-web-reactive/src/main/java/org/springframework/web/reactive/result/view/ViewResolutionResultHandler.java +++ b/spring-web-reactive/src/main/java/org/springframework/web/reactive/result/view/ViewResolutionResultHandler.java @@ -50,7 +50,7 @@ import org.springframework.web.reactive.accept.RequestedContentTypeResolver; import org.springframework.web.reactive.result.AbstractHandlerResultHandler; import org.springframework.web.server.NotAcceptableStatusException; import org.springframework.web.server.ServerWebExchange; -import org.springframework.web.util.HttpRequestPathHelper; +import org.springframework.web.server.support.HttpRequestPathHelper; /** * {@code HandlerResultHandler} that encapsulates the view resolution algorithm diff --git a/spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/RequestMappingInfoHandlerMappingTests.java b/spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/RequestMappingInfoHandlerMappingTests.java index f13aa777c8..ccd034c924 100644 --- a/spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/RequestMappingInfoHandlerMappingTests.java +++ b/spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/RequestMappingInfoHandlerMappingTests.java @@ -60,7 +60,7 @@ import org.springframework.web.server.UnsupportedMediaTypeStatusException; import org.springframework.web.server.adapter.DefaultServerWebExchange; import org.springframework.web.server.session.MockWebSessionManager; import org.springframework.web.server.session.WebSessionManager; -import org.springframework.web.util.HttpRequestPathHelper; +import org.springframework.web.server.support.HttpRequestPathHelper; import static org.hamcrest.CoreMatchers.*; import static org.junit.Assert.*; diff --git a/spring-web/src/main/java/org/springframework/web/cors/reactive/UrlBasedCorsConfigurationSource.java b/spring-web/src/main/java/org/springframework/web/cors/reactive/UrlBasedCorsConfigurationSource.java index c6b78d77e8..32a04851e3 100644 --- a/spring-web/src/main/java/org/springframework/web/cors/reactive/UrlBasedCorsConfigurationSource.java +++ b/spring-web/src/main/java/org/springframework/web/cors/reactive/UrlBasedCorsConfigurationSource.java @@ -25,7 +25,7 @@ import org.springframework.util.Assert; import org.springframework.util.PathMatcher; import org.springframework.web.cors.CorsConfiguration; import org.springframework.web.server.ServerWebExchange; -import org.springframework.web.util.HttpRequestPathHelper; +import org.springframework.web.server.support.HttpRequestPathHelper; /** * Provide a per reactive request {@link CorsConfiguration} instance based on a diff --git a/spring-web/src/main/java/org/springframework/web/util/HttpRequestPathHelper.java b/spring-web/src/main/java/org/springframework/web/server/support/HttpRequestPathHelper.java similarity index 96% rename from spring-web/src/main/java/org/springframework/web/util/HttpRequestPathHelper.java rename to spring-web/src/main/java/org/springframework/web/server/support/HttpRequestPathHelper.java index 993ac726da..ac92db6a69 100644 --- a/spring-web/src/main/java/org/springframework/web/util/HttpRequestPathHelper.java +++ b/spring-web/src/main/java/org/springframework/web/server/support/HttpRequestPathHelper.java @@ -13,7 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.web.util; + +package org.springframework.web.server.support; import java.io.UnsupportedEncodingException; import java.util.LinkedHashMap; @@ -24,6 +25,7 @@ import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; import org.springframework.util.StringUtils; import org.springframework.web.server.ServerWebExchange; +import org.springframework.web.util.UriUtils; /** * A helper class to obtain the lookup path for path matching purposes. @@ -57,7 +59,7 @@ public class HttpRequestPathHelper { public String getLookupPathForRequest(ServerWebExchange exchange) { String path = getPathWithinApplication(exchange.getRequest()); - return (this.shouldUrlDecode() ? decode(exchange, path) : path); + return (shouldUrlDecode() ? decode(exchange, path) : path); } private String getPathWithinApplication(ServerHttpRequest request) { @@ -125,4 +127,4 @@ public class HttpRequestPathHelper { return decodedVars; } -} \ No newline at end of file +} diff --git a/spring-web/src/main/java/org/springframework/web/server/support/package-info.java b/spring-web/src/main/java/org/springframework/web/server/support/package-info.java new file mode 100644 index 0000000000..0220d7faa4 --- /dev/null +++ b/spring-web/src/main/java/org/springframework/web/server/support/package-info.java @@ -0,0 +1,5 @@ +/** + * Helper classes on top of {@code org.springframework.web.server}, + * as a convenience for working with {@code ServerWebExchange}. + */ +package org.springframework.web.server.support;