This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new f70ca1171086 CAMEL-26485: camel-netty-http - endpoint options are no
longer sent to the server as query parameters (#29731)
f70ca1171086 is described below
commit f70ca11710862ec39c2aec78345ef123df2b7150
Author: Claus Ibsen <[email protected]>
AuthorDate: Thu Nov 12 20:44:06 2026 +0100
CAMEL-26485: camel-netty-http - endpoint options are no longer sent to the
server as query parameters (#29731)
The netty-http producer no longer sends its own endpoint options (such as
cookieHandler, httpMethodRestrict) to the HTTP server as query parameters.
NettyHttpComponent.createEndpoint built the address URI before setProperties
bound and removed the endpoint options; it is now built after, as camel-http
does. The CAMEL-26487 split stays: the endpoint URI carries all options, the
address URI is what gets called. Upgrade guide note: a query parameter with
the
name of an endpoint option can be sent with the CamelHttpQuery header.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
.../component/netty/http/NettyHttpComponent.java | 13 ++-
.../NettyHttpEndpointOptionsNotInQueryTest.java | 110 +++++++++++++++++++++
.../ROOT/pages/camel-4x-upgrade-guide-4_24.adoc | 9 ++
3 files changed, 125 insertions(+), 7 deletions(-)
diff --git
a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java
b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java
index 2daec35a64e8..c9be6b643ba9 100644
---
a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java
+++
b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java
@@ -173,19 +173,18 @@ public class NettyHttpComponent extends NettyComponent
// validate config
config.validateConfiguration();
- // create the address uri which includes the remainder parameters
(which
- // is not configuration parameters for this component)
- URI u = new URI(UnsafeUriCharactersEncoder.encodeHttpURI(remaining));
-
- String addressUri = URISupport.createRemainingURI(u,
parameters).toString();
-
// the endpoint uri is the full uri with the endpoint options, so
endpoints that differ only in their options
// are not equal, and the address uri is the http address to call
NettyHttpEndpoint answer = new NettyHttpEndpoint(uri, this, config);
- answer.setAddressUri(addressUri);
answer.getConfiguration().setMuteException(muteException);
setProperties(answer, parameters);
+ // create the address uri with the remainder parameters, after the
endpoint options are bound
+ // (and removed), so only the query parameters that are not endpoint
options are sent to the server
+ URI u = new URI(UnsafeUriCharactersEncoder.encodeHttpURI(remaining));
+ String addressUri = URISupport.createRemainingURI(u,
parameters).toString();
+ answer.setAddressUri(addressUri);
+
// must use a copy of the binding on the endpoint to avoid sharing same
// instance that can cause side-effects
if (answer.getNettyHttpBinding() == null) {
diff --git
a/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpEndpointOptionsNotInQueryTest.java
b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpEndpointOptionsNotInQueryTest.java
new file mode 100644
index 000000000000..048f2a8cf483
--- /dev/null
+++
b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpEndpointOptionsNotInQueryTest.java
@@ -0,0 +1,110 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.netty.http;
+
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import org.apache.camel.BindToRegistry;
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.http.base.cookie.InstanceCookieHandler;
+import org.apache.camel.support.DefaultExchange;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertSame;
+
+public class NettyHttpEndpointOptionsNotInQueryTest extends
BaseNettyTestSupport {
+
+ @BindToRegistry("myCookieHandler")
+ private final InstanceCookieHandler cookieHandler = new
InstanceCookieHandler();
+
+ @Test
+ public void testEndpointOptionsAreNotSentAsQueryParameters() {
+ String uri =
"netty-http:http://localhost:{{port}}/echo?bar=1&cookieHandler=#myCookieHandler"
+ +
"&httpMethodRestrict=GET&traceEnabled=false&exchangePattern=InOut&lazyStartProducer=true"
+ + "&throwExceptionOnFailure=true";
+
+ NettyHttpEndpoint endpoint = context.getEndpoint(uri,
NettyHttpEndpoint.class);
+ // the options are bound to the endpoint
+ assertSame(cookieHandler, endpoint.getCookieHandler());
+ assertEquals("GET", endpoint.getHttpMethodRestrict());
+
+ // and only the query parameter that is not an endpoint option is in
the address
+ assertEquals("http://localhost:" + getPort() + "/echo?bar=1",
+ NettyHttpHelper.createURL(new DefaultExchange(context),
endpoint));
+
+ String query = template.requestBody(uri, null, String.class);
+ assertEquals("bar=1", query);
+ }
+
+ @Test
+ public void testOnlyEndpointOptions() {
+ String query = template.requestBody(
+
"netty-http:http://localhost:{{port}}/echo?cookieHandler=#myCookieHandler&httpMethodRestrict=GET",
null,
+ String.class);
+ // no query parameters at all
+ assertEquals("none", query);
+ }
+
+ @Test
+ public void testConsumersDifferingOnlyInHttpMethodRestrict() {
+ List<NettyHttpEndpoint> endpoints = context.getEndpoints().stream()
+ .filter(NettyHttpEndpoint.class::isInstance)
+ .map(NettyHttpEndpoint.class::cast)
+ .filter(e -> e.getConfiguration().getPath().equals("/orders"))
+ .toList();
+ // the rest consumers for GET and POST on the same path differ only in
httpMethodRestrict
+ assertEquals(2, endpoints.size());
+ assertNotEquals(endpoints.get(0), endpoints.get(1));
+ assertEquals(Set.of("GET", "POST"),
+
endpoints.stream().map(NettyHttpEndpoint::getHttpMethodRestrict).collect(Collectors.toSet()));
+
+ String out =
template.requestBodyAndHeader("netty-http:http://localhost:{{port}}/orders",
null,
+ Exchange.HTTP_METHOD, "GET", String.class);
+ assertEquals("get", out);
+ out =
template.requestBodyAndHeader("netty-http:http://localhost:{{port}}/orders",
"Hello",
+ Exchange.HTTP_METHOD, "POST", String.class);
+ assertEquals("post", out);
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ from("netty-http:http://localhost:{{port}}/echo")
+ .process(e -> {
+ String query =
e.getIn().getHeader(Exchange.HTTP_QUERY, String.class);
+ e.getMessage().setBody(query != null ? query :
"none");
+ });
+
+
restConfiguration().component("netty-http").host("localhost").port(getPort());
+
+ rest("/orders")
+ .get().to("direct:get")
+ .post().to("direct:post");
+
+ from("direct:get").transform().constant("get");
+ from("direct:post").transform().constant("post");
+ }
+ };
+ }
+}
diff --git
a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
index ed754ebdef93..58f345294854 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
@@ -5149,6 +5149,15 @@ URI shows in:
`https`, and the include and exclude patterns are matched against the new
endpoint URI.
* the `endpointName` tag of the Micrometer exchange event metrics.
+=== camel-netty-http - endpoint options are no longer sent to the server as
query parameters
+
+The `netty-http` producer no longer sends some of its endpoint options, such
as `cookieHandler`, `httpMethodRestrict`,
+`traceEnabled` and `exchangePattern`, to the HTTP server as query parameters.
For example,
+`netty-http:http://localhost:8080/foo?bar=1&cookieHandler=#myCookieHandler`
now calls
+`http://localhost:8080/foo?bar=1`. Before, the server also received the
`cookieHandler` parameter. Only the
+query parameters that are not endpoint options are sent, as the documentation
describes. To send a query parameter
+that has the same name as an endpoint option, set the query in the
`CamelHttpQuery` header.
+
=== camel-netty - hostnameVerification verifies the host instead of failing
`hostnameVerification=true` on a `netty` producer, or on a consumer with
`clientMode=true`, now checks that the