use of org.springframework.web.server.support.HttpRequestPathHelper in project spring-framework by spring-projects.
the class RequestMappingInfoHandlerMappingTests method handleMatchMatrixVariablesDecoding.
@Test
public void handleMatchMatrixVariablesDecoding() throws Exception {
HttpRequestPathHelper urlPathHelper = new HttpRequestPathHelper();
urlPathHelper.setUrlDecode(false);
this.handlerMapping.setPathHelper(urlPathHelper);
ServerWebExchange exchange = get("/").toExchange();
handleMatch(exchange, "/path{filter}", "/path;mvar=a%2fb");
MultiValueMap<String, String> matrixVariables = getMatrixVariables(exchange, "filter");
Map<String, String> uriVariables = getUriTemplateVariables(exchange);
assertNotNull(matrixVariables);
assertEquals(Collections.singletonList("a/b"), matrixVariables.get("mvar"));
assertEquals(";mvar=a/b", uriVariables.get("filter"));
}
use of org.springframework.web.server.support.HttpRequestPathHelper in project spring-framework by spring-projects.
the class RequestMappingInfoHandlerMappingTests method handleMatchUriTemplateVariablesDecode.
// SPR-9098
@Test
public void handleMatchUriTemplateVariablesDecode() throws Exception {
RequestMappingInfo key = paths("/{group}/{identifier}").build();
URI url = URI.create("/group/a%2Fb");
ServerWebExchange exchange = MockServerHttpRequest.method(HttpMethod.GET, url).toExchange();
HttpRequestPathHelper pathHelper = new HttpRequestPathHelper();
pathHelper.setUrlDecode(false);
String lookupPath = pathHelper.getLookupPathForRequest(exchange);
this.handlerMapping.setPathHelper(pathHelper);
this.handlerMapping.handleMatch(key, lookupPath, exchange);
String name = HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE;
@SuppressWarnings("unchecked") Map<String, String> uriVariables = (Map<String, String>) exchange.getAttributes().get(name);
assertNotNull(uriVariables);
assertEquals("group", uriVariables.get("group"));
assertEquals("a/b", uriVariables.get("identifier"));
}
Aggregations