Browse Source

ServerRequest.path() should return raw path

After this commit, ServerRequest.path() returns the raw, unencoded path,
as that is expected by the PathPatternParser.
pull/1459/merge
Arjen Poutsma 9 years ago
parent
commit
7018804e84
  1. 2
      spring-webflux/src/main/java/org/springframework/web/reactive/function/server/ServerRequest.java
  2. 11
      spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RequestPredicatesTests.java

2
spring-webflux/src/main/java/org/springframework/web/reactive/function/server/ServerRequest.java

@ -67,7 +67,7 @@ public interface ServerRequest {
* Return the request path. * Return the request path.
*/ */
default String path() { default String path() {
return uri().getPath(); return uri().getRawPath();
} }
/** /**

11
spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RequestPredicatesTests.java

@ -95,6 +95,17 @@ public class RequestPredicatesTests {
assertFalse(predicate.test(request)); assertFalse(predicate.test(request));
} }
@Test
public void pathEncoded() throws Exception {
URI uri = URI.create("http://localhost/foo%20bar");
RequestPredicate predicate = RequestPredicates.path("/foo bar");
MockServerRequest request = MockServerRequest.builder().uri(uri).build();
assertTrue(predicate.test(request));
request = MockServerRequest.builder().build();
assertFalse(predicate.test(request));
}
@Test @Test
public void pathPredicates() throws Exception { public void pathPredicates() throws Exception {
PathPatternParser parser = new PathPatternParser(); PathPatternParser parser = new PathPatternParser();

Loading…
Cancel
Save