Recently I found a strange behaviour after adding a Filter to our project that uses ServerRequest.from
. After I added the filter the contextPath was gone and the pathWithinApplication contained the full path.
As we are using a reverse Proxy and want to return correct location headers we are dependent on the contextPath set by the ForwardedHeaderTransformer
.
My question is if this is intended behaviour or is this a bug in the framework.
I think I found the culprit of this behaviour here:
public BuiltServerHttpRequest(String id, HttpMethod method, URI uri, HttpHeaders headers,
MultiValueMap<String, HttpCookie> cookies, Flux<DataBuffer> body) {
this.id = id;
this.method = method;
this.uri = uri;
this.path = RequestPath.parse(uri, null);
this.headers = HttpHeaders.readOnlyHttpHeaders(headers);
this.cookies = unmodifiableCopy(cookies);
this.queryParams = parseQueryParams(uri);
this.body = body;
}
in the this.path = RequestPath.parse(uri, null);
where the context path is explicitly set to null.
The issue looks similar to https://github.com/spring-projects/spring-framework/issues/25279 where the behaviour was fixed for mutating ServerHttpRequests