Andrea Cosentino created CAMEL-24577:
----------------------------------------
Summary: camel-platform-http-starter - path variable headers are
derived from the undecoded request URI
Key: CAMEL-24577
URL: https://issues.apache.org/jira/browse/CAMEL-24577
Project: Camel
Issue Type: Improvement
Components: camel-platform-http, camel-spring-boot-starters
Reporter: Andrea Cosentino
Assignee: Andrea Cosentino
Fix For: 4.23.0
{{SpringBootPlatformHttpBinding.populateRequestParameters()}} evaluates REST
path placeholders against
{{getRawPath(request)}}:
{code:java}
String path = getRawPath(request);
...
HttpHelper.evalPlaceholders(message.getHeaders(), path, consumerPath);
{code}
and the override returns the undecoded request URI:
{code:java}
@Override
protected String getRawPath(HttpServletRequest request) {
String uri = request.getRequestURI();
{code}
So path-variable headers are built from a value that is still percent-encoded
and still carries matrix
parameters, which can differ from the path Spring actually matched the request
against. The Vert.x engine uses
the decoded parameters.
*Why this was deferred from CAMEL-24496*
The obvious fix - extracting the variables from the decoded {{RequestPath}}
Spring has already parsed - is wider
than it looks. The base-class {{getRawPath}} also feeds {{Exchange.HTTP_PATH}}
for every request, not only
placeholder evaluation, so changing the override changes a widely used header.
The override also exists on purpose: CAMEL-22116 added it so Spring Boot could
supply its own logic, and
CAMEL-23191 refined it for servlet context-path handling. Any change here has
to preserve both.
*Proposal*
Extract path variables from {{ServletRequestPathUtils.getParsedRequestPath}}
(or the handler mapping's
URI-template-variables attribute) for the placeholder evaluation only, leaving
{{getRawPath}} and therefore
{{Exchange.HTTP_PATH}} unchanged. Add tests covering a percent-encoded segment
and a segment carrying a matrix
parameter, asserting the header value matches what Spring matched.
Split out of CAMEL-24496, which is resolved.
----
_This issue was drafted by Claude Code on behalf of Andrea Cosentino._
--
This message was sent by Atlassian Jira
(v8.20.10#820010)