Browse Source

Use pre-parsed PathContainer in WebMvc.fn

This commit makes the default ServerRequest implementation use a pre-
parsed path container, instead of parsing the path for each invocation
of pathContainer().
pull/25006/head
Arjen Poutsma 6 years ago
parent
commit
8e81360eba
  1. 10
      spring-webmvc/src/main/java/org/springframework/web/servlet/function/DefaultServerRequest.java

10
spring-webmvc/src/main/java/org/springframework/web/servlet/function/DefaultServerRequest.java

@ -52,6 +52,7 @@ import org.springframework.http.HttpRange; @@ -52,6 +52,7 @@ import org.springframework.http.HttpRange;
import org.springframework.http.MediaType;
import org.springframework.http.converter.GenericHttpMessageConverter;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.server.PathContainer;
import org.springframework.http.server.ServletServerHttpRequest;
import org.springframework.lang.Nullable;
import org.springframework.util.CollectionUtils;
@ -76,6 +77,8 @@ class DefaultServerRequest implements ServerRequest { @@ -76,6 +77,8 @@ class DefaultServerRequest implements ServerRequest {
private final ServletServerHttpRequest serverHttpRequest;
private final PathContainer pathContainer;
private final Headers headers;
private final List<HttpMessageConverter<?>> messageConverters;
@ -98,6 +101,8 @@ class DefaultServerRequest implements ServerRequest { @@ -98,6 +101,8 @@ class DefaultServerRequest implements ServerRequest {
this.headers = new DefaultRequestHeaders(this.serverHttpRequest.getHeaders());
this.params = CollectionUtils.toMultiValueMap(new ServletParametersMap(servletRequest));
this.attributes = new ServletAttributesMap(servletRequest);
this.pathContainer = PathContainer.parsePath(path());
}
private static List<MediaType> allSupportedMediaTypes(List<HttpMessageConverter<?>> messageConverters) {
@ -133,6 +138,11 @@ class DefaultServerRequest implements ServerRequest { @@ -133,6 +138,11 @@ class DefaultServerRequest implements ServerRequest {
return path;
}
@Override
public PathContainer pathContainer() {
return this.pathContainer;
}
@Override
public Headers headers() {
return this.headers;

Loading…
Cancel
Save