-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Description
Affects: 5.3.3
The Javadoc for ServerHttpRequest.getPath() reads:
Returns a structured representation of the request path including the context path + path within application portions, path segments with encoded and decoded values, and path parameters.
However, getPath().toString() actually results in the path only up to (but excluding) the first "?". Any query parameters that were part of the original URI are not included, contrary to what the Javadoc claims.
For example, this Kotlin/JUnit5 test
@Test
fun getPathShouldContainParams() {
val exchange = MockServerWebExchange.from(MockServerHttpRequest.get("http://test.com/items?id=5"))
assertThat(exchange.request.path).isEqualTo("/items?id=5")
}fails with this message:
org.opentest4j.AssertionFailedError: expected:<["/items?id=5"]> but was:<[/items]>
Expected :/items?id=5
Actual :/items
When debugging into the test, I could see that the returned RequestPath object doesn't contain any info about the parameters.
I first noticed this in production, i.e. this als happens with real requests, not just with mocked ones.
Expected behavior:
ServerHttpRequest.getPath() returns an object that knows about the parameters, and returns them as part of its toString().