Skip to content

Commit

Permalink
Save query parameters in WebSessionServerRequestCache
Browse files Browse the repository at this point in the history
Previously, URL query parameters were lost when saving a request
in WebSessionServerRequestCache. Now it is properly saved and
restored.

Fixes: gh-6421
  • Loading branch information
denisw authored and rwinch committed Jan 15, 2019
1 parent 7f2f12c commit 548dc44
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ public Mono<ServerHttpRequest> removeMatchingRequest(
}

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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ public void saveRequestGetRequestWhenGetThenFound() {
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));
Expand Down

0 comments on commit 548dc44

Please sign in to comment.