Save query parameters in WebSessionServerRequestCache
Previously, URL query parameters were lost when saving a request in WebSessionServerRequestCache. Now it is properly saved and restored.
This commit is contained in:
parent
c0e66a9ba1
commit
3be11a22cd
|
@ -90,7 +90,9 @@ public class WebSessionServerRequestCache implements ServerRequestCache {
|
|||
}
|
||||
|
||||
private static String pathInApplication(ServerHttpRequest request) {
|
||||
return request.getPath().pathWithinApplication().value();
|
||||
String path = request.getPath().pathWithinApplication().value();
|
||||
String query = request.getURI().getRawQuery();
|
||||
return path + (query != null ? "?" + query : "");
|
||||
}
|
||||
|
||||
private static ServerWebExchangeMatcher createDefaultRequestMacher() {
|
||||
|
|
|
@ -44,6 +44,16 @@ public class WebSessionServerRequestCacheTests {
|
|||
assertThat(saved).isEqualTo(exchange.getRequest().getURI());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void saveRequestGetRequestWithQueryParamsWhenGetThenFound() {
|
||||
MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/secured/").queryParam("key", "value").accept(MediaType.TEXT_HTML));
|
||||
this.cache.saveRequest(exchange).block();
|
||||
|
||||
URI saved = this.cache.getRedirectUri(exchange).block();
|
||||
|
||||
assertThat(saved).isEqualTo(exchange.getRequest().getURI());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void saveRequestGetRequestWhenFaviconThenNotFound() {
|
||||
MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/favicon.png").accept(MediaType.TEXT_HTML));
|
||||
|
|
Loading…
Reference in New Issue