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 0810414eb5d6 CAMEL-28017: camel-netty-http - consumer sets 
CamelHttpScheme and CamelHttpHost to null and CamelHttpPort to 80/443 (#31251)
0810414eb5d6 is described below

commit 0810414eb5d6d3cc3ca920f62aa1ff07a66591ca
Author: Guillaume Nodet <[email protected]>
AuthorDate: Wed Dec 2 21:38:02 2026 +0100

    CAMEL-28017: camel-netty-http - consumer sets CamelHttpScheme and 
CamelHttpHost to null and CamelHttpPort to 80/443 (#31251)
    
    When request.uri() is a relative path (e.g. /foo?bar=1) the parsed URI
    has null scheme and host, and port -1. The binding must fall back to
    the endpoint configuration values, as it already does when constructing
    the HTTP_URL header.
    
    Fixed populateCamelHeaders() in DefaultNettyHttpBinding to use
    configuration.isSsl(), configuration.getHost(), and configuration.getPort()
    as fallbacks when uri.getScheme()/getHost() are null or uri.getPort() is -1.
    
    Added two regression tests covering plain HTTP and HTTPS consumer cases.
    
    Follow-up commits:
    - CAMEL-28017: fix port for absolute URIs, update catalog JSON header 
descriptions
    - CAMEL-28017: add test for Host header with port suffix
    - CAMEL-28017: fix IPv6 Host header port-stripping, add IPv6 tests
    
    Co-authored-by: Claude Sonnet 4.6 <[email protected]>
---
 .../camel/catalog/components/netty-http.json       |   6 +-
 .../camel/component/netty/http/netty-http.json     |   6 +-
 .../netty/http/DefaultNettyHttpBinding.java        |  33 +++-
 .../component/netty/http/NettyHttpConstants.java   |  18 +-
 .../DefaultNettyHttpBindingCamelHeadersTest.java   | 201 +++++++++++++++++++++
 .../ROOT/pages/camel-4x-upgrade-guide-4_25.adoc    |  16 ++
 .../dsl/NettyHttpEndpointBuilderFactory.java       |  24 ++-
 7 files changed, 281 insertions(+), 23 deletions(-)

diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/netty-http.json
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/netty-http.json
index 6c63a4e06be5..893fbb80faca 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/netty-http.json
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/netty-http.json
@@ -120,9 +120,9 @@
     "CamelHttpUrl": { "index": 11, "kind": "header", "displayName": "", 
"group": "common", "label": "", "required": false, "javaType": "String", 
"deprecated": false, "autowired": false, "secret": false, "description": "The 
URL including protocol, host and port, etc: http:\/\/0.0.0.0:8080\/myapp.", 
"constantName": 
"org.apache.camel.component.netty.http.NettyHttpConstants#HTTP_URL" },
     "CamelHttpCharacterEncoding": { "index": 12, "kind": "header", 
"displayName": "", "group": "common", "label": "", "required": false, 
"javaType": "String", "deprecated": false, "autowired": false, "secret": false, 
"description": "The charset from the content-type header.", "constantName": 
"org.apache.camel.component.netty.http.NettyHttpConstants#HTTP_CHARACTER_ENCODING"
 },
     "CamelHttpUri": { "index": 13, "kind": "header", "displayName": "", 
"group": "common", "label": "", "required": false, "javaType": "String", 
"deprecated": false, "autowired": false, "secret": false, "description": "The 
URI without protocol, host and port, etc: \/myapp.", "constantName": 
"org.apache.camel.component.netty.http.NettyHttpConstants#HTTP_URI" },
-    "CamelHttpScheme": { "index": 14, "kind": "header", "displayName": "", 
"group": "consumer", "label": "consumer", "required": false, "javaType": 
"String", "deprecated": false, "autowired": false, "secret": false, 
"description": "The scheme of the request URI, http or https, when the request 
line has an absolute URI, as the requests to a proxy (httpProxy) have. 
Otherwise null.", "constantName": 
"org.apache.camel.component.netty.http.NettyHttpConstants#HTTP_SCHEME" },
-    "CamelHttpHost": { "index": 15, "kind": "header", "displayName": "", 
"group": "consumer", "label": "consumer", "required": false, "javaType": 
"String", "deprecated": false, "autowired": false, "secret": false, 
"description": "The host of the request URI, when the request line has an 
absolute URI, as the requests to a proxy (httpProxy) have. Otherwise null.", 
"constantName": 
"org.apache.camel.component.netty.http.NettyHttpConstants#HTTP_HOST" },
-    "CamelHttpPort": { "index": 16, "kind": "header", "displayName": "", 
"group": "consumer", "label": "consumer", "required": false, "javaType": 
"Integer", "deprecated": false, "autowired": false, "secret": false, 
"description": "The port of the request URI, when the request line has an 
absolute URI with a port. Otherwise 443 when ssl is enabled or the scheme is 
https, and 80 otherwise.", "constantName": 
"org.apache.camel.component.netty.http.NettyHttpConstants#HTTP_PORT" },
+    "CamelHttpScheme": { "index": 14, "kind": "header", "displayName": "", 
"group": "consumer", "label": "consumer", "required": false, "javaType": 
"String", "deprecated": false, "autowired": false, "secret": false, 
"description": "The scheme of the request URI (http or https). For relative 
request lines (e.g. \/foo?x=1, as sent by standard HTTP\/1.1 clients to a 
server) the scheme is derived from the consumer's ssl configuration. For 
absolute-URI request lines (e.g. proxy-style: http:\/ [...]
+    "CamelHttpHost": { "index": 15, "kind": "header", "displayName": "", 
"group": "consumer", "label": "consumer", "required": false, "javaType": 
"String", "deprecated": false, "autowired": false, "secret": false, 
"description": "The host of the request. For relative request lines (e.g. 
\/foo?x=1) the host is taken from the HTTP Host header first; if that is 
absent, it falls back to the consumer's configured host. For absolute-URI 
request lines (e.g. proxy-style: http:\/\/example.com\/fo [...]
+    "CamelHttpPort": { "index": 16, "kind": "header", "displayName": "", 
"group": "consumer", "label": "consumer", "required": false, "javaType": 
"Integer", "deprecated": false, "autowired": false, "secret": false, 
"description": "The port of the request. For relative request lines (e.g. 
\/foo?x=1) the port is taken from the consumer's configured port. For 
absolute-URI request lines with an explicit port (e.g. 
http:\/\/example.com:9090\/foo) the port comes from the URI. For absolute-URI  
[...]
     "CamelRestHttpUri": { "index": 17, "kind": "header", "displayName": "", 
"group": "producer", "label": "producer", "required": false, "javaType": 
"String", "deprecated": false, "autowired": false, "secret": false, 
"description": "The URI to call, set by the REST producer. It takes precedence 
over the endpoint URI, and the producer removes the header when it uses it.", 
"constantName": 
"org.apache.camel.component.netty.http.NettyHttpConstants#REST_HTTP_URI" },
     "CamelRestHttpQuery": { "index": 18, "kind": "header", "displayName": "", 
"group": "producer", "label": "producer", "required": false, "javaType": 
"String", "deprecated": false, "autowired": false, "secret": false, 
"description": "The query string, set by the REST producer. It takes precedence 
over CamelHttpRawQuery, CamelHttpQuery and the query of the endpoint URI, and 
the producer removes the header when it uses it.", "constantName": 
"org.apache.camel.component.netty.http.NettyHttp [...]
     "CamelNettyChannelHandlerContext": { "index": 19, "kind": "header", 
"displayName": "", "group": "common", "label": "", "required": false, 
"javaType": "io.netty.channel.ChannelHandlerContext", "deprecated": false, 
"autowired": false, "secret": false, "description": "The Netty 
ChannelHandlerContext of the channel that received the message.", 
"constantName": 
"org.apache.camel.component.netty.NettyConstants#NETTY_CHANNEL_HANDLER_CONTEXT" 
},
diff --git 
a/components/camel-netty-http/src/generated/resources/META-INF/org/apache/camel/component/netty/http/netty-http.json
 
b/components/camel-netty-http/src/generated/resources/META-INF/org/apache/camel/component/netty/http/netty-http.json
index 6c63a4e06be5..893fbb80faca 100644
--- 
a/components/camel-netty-http/src/generated/resources/META-INF/org/apache/camel/component/netty/http/netty-http.json
+++ 
b/components/camel-netty-http/src/generated/resources/META-INF/org/apache/camel/component/netty/http/netty-http.json
@@ -120,9 +120,9 @@
     "CamelHttpUrl": { "index": 11, "kind": "header", "displayName": "", 
"group": "common", "label": "", "required": false, "javaType": "String", 
"deprecated": false, "autowired": false, "secret": false, "description": "The 
URL including protocol, host and port, etc: http:\/\/0.0.0.0:8080\/myapp.", 
"constantName": 
"org.apache.camel.component.netty.http.NettyHttpConstants#HTTP_URL" },
     "CamelHttpCharacterEncoding": { "index": 12, "kind": "header", 
"displayName": "", "group": "common", "label": "", "required": false, 
"javaType": "String", "deprecated": false, "autowired": false, "secret": false, 
"description": "The charset from the content-type header.", "constantName": 
"org.apache.camel.component.netty.http.NettyHttpConstants#HTTP_CHARACTER_ENCODING"
 },
     "CamelHttpUri": { "index": 13, "kind": "header", "displayName": "", 
"group": "common", "label": "", "required": false, "javaType": "String", 
"deprecated": false, "autowired": false, "secret": false, "description": "The 
URI without protocol, host and port, etc: \/myapp.", "constantName": 
"org.apache.camel.component.netty.http.NettyHttpConstants#HTTP_URI" },
-    "CamelHttpScheme": { "index": 14, "kind": "header", "displayName": "", 
"group": "consumer", "label": "consumer", "required": false, "javaType": 
"String", "deprecated": false, "autowired": false, "secret": false, 
"description": "The scheme of the request URI, http or https, when the request 
line has an absolute URI, as the requests to a proxy (httpProxy) have. 
Otherwise null.", "constantName": 
"org.apache.camel.component.netty.http.NettyHttpConstants#HTTP_SCHEME" },
-    "CamelHttpHost": { "index": 15, "kind": "header", "displayName": "", 
"group": "consumer", "label": "consumer", "required": false, "javaType": 
"String", "deprecated": false, "autowired": false, "secret": false, 
"description": "The host of the request URI, when the request line has an 
absolute URI, as the requests to a proxy (httpProxy) have. Otherwise null.", 
"constantName": 
"org.apache.camel.component.netty.http.NettyHttpConstants#HTTP_HOST" },
-    "CamelHttpPort": { "index": 16, "kind": "header", "displayName": "", 
"group": "consumer", "label": "consumer", "required": false, "javaType": 
"Integer", "deprecated": false, "autowired": false, "secret": false, 
"description": "The port of the request URI, when the request line has an 
absolute URI with a port. Otherwise 443 when ssl is enabled or the scheme is 
https, and 80 otherwise.", "constantName": 
"org.apache.camel.component.netty.http.NettyHttpConstants#HTTP_PORT" },
+    "CamelHttpScheme": { "index": 14, "kind": "header", "displayName": "", 
"group": "consumer", "label": "consumer", "required": false, "javaType": 
"String", "deprecated": false, "autowired": false, "secret": false, 
"description": "The scheme of the request URI (http or https). For relative 
request lines (e.g. \/foo?x=1, as sent by standard HTTP\/1.1 clients to a 
server) the scheme is derived from the consumer's ssl configuration. For 
absolute-URI request lines (e.g. proxy-style: http:\/ [...]
+    "CamelHttpHost": { "index": 15, "kind": "header", "displayName": "", 
"group": "consumer", "label": "consumer", "required": false, "javaType": 
"String", "deprecated": false, "autowired": false, "secret": false, 
"description": "The host of the request. For relative request lines (e.g. 
\/foo?x=1) the host is taken from the HTTP Host header first; if that is 
absent, it falls back to the consumer's configured host. For absolute-URI 
request lines (e.g. proxy-style: http:\/\/example.com\/fo [...]
+    "CamelHttpPort": { "index": 16, "kind": "header", "displayName": "", 
"group": "consumer", "label": "consumer", "required": false, "javaType": 
"Integer", "deprecated": false, "autowired": false, "secret": false, 
"description": "The port of the request. For relative request lines (e.g. 
\/foo?x=1) the port is taken from the consumer's configured port. For 
absolute-URI request lines with an explicit port (e.g. 
http:\/\/example.com:9090\/foo) the port comes from the URI. For absolute-URI  
[...]
     "CamelRestHttpUri": { "index": 17, "kind": "header", "displayName": "", 
"group": "producer", "label": "producer", "required": false, "javaType": 
"String", "deprecated": false, "autowired": false, "secret": false, 
"description": "The URI to call, set by the REST producer. It takes precedence 
over the endpoint URI, and the producer removes the header when it uses it.", 
"constantName": 
"org.apache.camel.component.netty.http.NettyHttpConstants#REST_HTTP_URI" },
     "CamelRestHttpQuery": { "index": 18, "kind": "header", "displayName": "", 
"group": "producer", "label": "producer", "required": false, "javaType": 
"String", "deprecated": false, "autowired": false, "secret": false, 
"description": "The query string, set by the REST producer. It takes precedence 
over CamelHttpRawQuery, CamelHttpQuery and the query of the endpoint URI, and 
the producer removes the header when it uses it.", "constantName": 
"org.apache.camel.component.netty.http.NettyHttp [...]
     "CamelNettyChannelHandlerContext": { "index": 19, "kind": "header", 
"displayName": "", "group": "common", "label": "", "required": false, 
"javaType": "io.netty.channel.ChannelHandlerContext", "deprecated": false, 
"autowired": false, "secret": false, "description": "The Netty 
ChannelHandlerContext of the channel that received the message.", 
"constantName": 
"org.apache.camel.component.netty.NettyConstants#NETTY_CHANNEL_HANDLER_CONTEXT" 
},
diff --git 
a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/DefaultNettyHttpBinding.java
 
b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/DefaultNettyHttpBinding.java
index b693a724f882..2341b2c99652 100644
--- 
a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/DefaultNettyHttpBinding.java
+++ 
b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/DefaultNettyHttpBinding.java
@@ -175,11 +175,38 @@ public class DefaultNettyHttpBinding implements 
NettyHttpBinding, Cloneable {
         headers.put(NettyHttpConstants.HTTP_URI, uri.getPath());
         headers.put(NettyHttpConstants.HTTP_QUERY, uri.getQuery());
         headers.put(NettyHttpConstants.HTTP_RAW_QUERY, uri.getRawQuery());
-        headers.put(NettyHttpConstants.HTTP_SCHEME, uri.getScheme());
-        headers.put(NettyHttpConstants.HTTP_HOST, uri.getHost());
+        // when the request URI is relative (e.g. /foo?x=1), uri.getScheme() 
and
+        // uri.getHost() return null; fall back to the endpoint configuration.
+        // For absolute URIs (e.g. proxy-style: GET http://example.com/foo 
HTTP/1.1),
+        // use the URI's own values so the proxy forwards to the correct 
target.
+        final boolean isRelativeUri = uri.getHost() == null;
+        final boolean ssl = configuration.isSsl() || 
"https".equals(uri.getScheme());
+        headers.put(NettyHttpConstants.HTTP_SCHEME, uri.getScheme() != null ? 
uri.getScheme() : (ssl ? "https" : "http"));
+        if (isRelativeUri) {
+            // Relative request line: prefer the Host HTTP header (sent by all 
HTTP/1.1 clients),
+            // then fall back to configuration.getHost() (consistent with 
platform-http-vertx).
+            String hostHeader = request.headers().get(HttpHeaderNames.HOST);
+            if (hostHeader != null && !hostHeader.isEmpty()) {
+                // Strip optional port from the Host header value (e.g. 
"example.com:8080" -> "example.com").
+                // Guard against IPv6 literals: for "Host: [::1]" 
lastIndexOf(':') hits a colon inside the
+                // brackets, not a port separator.  Only strip when the colon 
comes after the closing ']'
+                // (or when there is no '[' at all), per RFC 7230 §5.4.
+                int colonIdx = hostHeader.lastIndexOf(':');
+                if (colonIdx > 0 && !(hostHeader.startsWith("[") && colonIdx 
<= hostHeader.lastIndexOf(']'))) {
+                    hostHeader = hostHeader.substring(0, colonIdx);
+                }
+            }
+            headers.put(NettyHttpConstants.HTTP_HOST,
+                    hostHeader != null && !hostHeader.isEmpty() ? hostHeader : 
configuration.getHost());
+        } else {
+            headers.put(NettyHttpConstants.HTTP_HOST, uri.getHost());
+        }
         final int port = uri.getPort();
+        // For relative URIs the request line has no port; use the consumer's 
configured port.
+        // For absolute URIs without an explicit port (e.g. GET 
http://example.com/foo) keep
+        // the conventional 80/443 default so proxy forwarding targets the 
correct port.
         headers.put(NettyHttpConstants.HTTP_PORT,
-                port > 0 ? port : configuration.isSsl() || 
"https".equals(uri.getScheme()) ? 443 : 80);
+                port > 0 ? port : isRelativeUri ? configuration.getPort() : 
(ssl ? 443 : 80));
 
         // strip the starting endpoint path so the path is relative to the 
endpoint uri
         final String path = stripPath(configuration, uri);
diff --git 
a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpConstants.java
 
b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpConstants.java
index e1070a6d2e81..ed1ae8397e82 100644
--- 
a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpConstants.java
+++ 
b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpConstants.java
@@ -89,18 +89,24 @@ public final class NettyHttpConstants {
               javaType = "String")
     public static final String HTTP_URI = Exchange.HTTP_URI;
     @Metadata(label = "consumer", description = """
-            The scheme of the request URI, http or https, when the request 
line has an absolute URI, as the requests
-            to a proxy (httpProxy) have. Otherwise null.""",
+            The scheme of the request URI (http or https). For relative 
request lines (e.g. /foo?x=1,
+            as sent by standard HTTP/1.1 clients to a server) the scheme is 
derived from the consumer's
+            ssl configuration. For absolute-URI request lines (e.g. 
proxy-style: http://example.com/foo)
+            the scheme comes from the URI itself.""",
               javaType = "String")
     public static final String HTTP_SCHEME = Exchange.HTTP_SCHEME;
     @Metadata(label = "consumer", description = """
-            The host of the request URI, when the request line has an absolute 
URI, as the requests to a proxy
-            (httpProxy) have. Otherwise null.""",
+            The host of the request. For relative request lines (e.g. 
/foo?x=1) the host is taken from
+            the HTTP Host header first; if that is absent, it falls back to 
the consumer's configured host.
+            For absolute-URI request lines (e.g. proxy-style: 
http://example.com/foo) the host comes from
+            the URI itself.""",
               javaType = "String")
     public static final String HTTP_HOST = Exchange.HTTP_HOST;
     @Metadata(label = "consumer", description = """
-            The port of the request URI, when the request line has an absolute 
URI with a port. Otherwise 443 when
-            ssl is enabled or the scheme is https, and 80 otherwise.""",
+            The port of the request. For relative request lines (e.g. 
/foo?x=1) the port is taken from
+            the consumer's configured port. For absolute-URI request lines 
with an explicit port (e.g.
+            http://example.com:9090/foo) the port comes from the URI. For 
absolute-URI request lines
+            without a port the conventional default is used: 443 for https, 80 
for http.""",
               javaType = "Integer")
     public static final String HTTP_PORT = Exchange.HTTP_PORT;
     @Metadata(label = "producer", description = """
diff --git 
a/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/DefaultNettyHttpBindingCamelHeadersTest.java
 
b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/DefaultNettyHttpBindingCamelHeadersTest.java
index 038b225d2a69..c8bb311c1475 100644
--- 
a/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/DefaultNettyHttpBindingCamelHeadersTest.java
+++ 
b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/DefaultNettyHttpBindingCamelHeadersTest.java
@@ -20,6 +20,10 @@ import java.nio.charset.StandardCharsets;
 import java.util.HashMap;
 import java.util.Map;
 
+import io.netty.handler.codec.http.DefaultHttpRequest;
+import io.netty.handler.codec.http.HttpHeaderNames;
+import io.netty.handler.codec.http.HttpMethod;
+import io.netty.handler.codec.http.HttpVersion;
 import org.apache.camel.CamelContext;
 import org.apache.camel.Exchange;
 import org.apache.camel.impl.DefaultCamelContext;
@@ -56,4 +60,201 @@ public class DefaultNettyHttpBindingCamelHeadersTest {
                 binding.shouldUrlDecodeHeader(configuration, "content-type", 
"text/plain; a=b%20c", StandardCharsets.UTF_8));
         assertEquals("b c", binding.shouldUrlDecodeHeader(configuration, 
"foo", "b%20c", StandardCharsets.UTF_8));
     }
+
+    /**
+     * CAMEL-28017: when request.uri() is a relative path (e.g. /foo?x=1), the 
parsed URI has null scheme/host and port
+     * -1; the binding must fall back to the endpoint configuration values.
+     */
+    @Test
+    public void testRelativeUriUsesConfigurationForSchemeHostPort() throws 
Exception {
+        CamelContext context = new DefaultCamelContext();
+        Exchange exchange = new DefaultExchange(context);
+
+        NettyHttpConfiguration configuration = new NettyHttpConfiguration();
+        configuration.setHost("myhost");
+        configuration.setPort(8080);
+        configuration.setSsl(false);
+
+        DefaultHttpRequest request = new 
DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/foo?x=1");
+
+        Map<String, Object> headers = new HashMap<>();
+        new DefaultNettyHttpBinding().populateCamelHeaders(request, headers, 
exchange, configuration);
+
+        assertEquals("http", headers.get(NettyHttpConstants.HTTP_SCHEME));
+        assertEquals("myhost", headers.get(NettyHttpConstants.HTTP_HOST));
+        assertEquals(8080, headers.get(NettyHttpConstants.HTTP_PORT));
+    }
+
+    /**
+     * CAMEL-28017: same as above but for HTTPS (ssl=true); scheme must be 
"https" and port must come from config.
+     */
+    @Test
+    public void testRelativeUriSslUsesConfigurationForSchemeHostPort() throws 
Exception {
+        CamelContext context = new DefaultCamelContext();
+        Exchange exchange = new DefaultExchange(context);
+
+        NettyHttpConfiguration configuration = new NettyHttpConfiguration();
+        configuration.setHost("securehost");
+        configuration.setPort(8443);
+        configuration.setSsl(true);
+
+        DefaultHttpRequest request = new 
DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/secure/path");
+
+        Map<String, Object> headers = new HashMap<>();
+        new DefaultNettyHttpBinding().populateCamelHeaders(request, headers, 
exchange, configuration);
+
+        assertEquals("https", headers.get(NettyHttpConstants.HTTP_SCHEME));
+        assertEquals("securehost", headers.get(NettyHttpConstants.HTTP_HOST));
+        assertEquals(8443, headers.get(NettyHttpConstants.HTTP_PORT));
+    }
+
+    /**
+     * CAMEL-28017: for relative URIs the Host HTTP header takes precedence 
over configuration.getHost().
+     */
+    @Test
+    public void testRelativeUriPrefersHostHeader() throws Exception {
+        CamelContext context = new DefaultCamelContext();
+        Exchange exchange = new DefaultExchange(context);
+
+        NettyHttpConfiguration configuration = new NettyHttpConfiguration();
+        configuration.setHost("0.0.0.0");
+        configuration.setPort(8080);
+        configuration.setSsl(false);
+
+        DefaultHttpRequest request = new 
DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/foo");
+        request.headers().set(HttpHeaderNames.HOST, "realhost");
+
+        Map<String, Object> headers = new HashMap<>();
+        new DefaultNettyHttpBinding().populateCamelHeaders(request, headers, 
exchange, configuration);
+
+        assertEquals("http", headers.get(NettyHttpConstants.HTTP_SCHEME));
+        assertEquals("realhost", headers.get(NettyHttpConstants.HTTP_HOST));
+        assertEquals(8080, headers.get(NettyHttpConstants.HTTP_PORT));
+    }
+
+    /**
+     * CAMEL-28017: for relative URIs, when the Host header includes a port 
(e.g. "realhost:9090"), only the hostname
+     * part must be stored in CamelHttpHost; CamelHttpPort must still come 
from the consumer's configured port.
+     */
+    @Test
+    public void testRelativeUriHostHeaderWithPort() throws Exception {
+        CamelContext context = new DefaultCamelContext();
+        Exchange exchange = new DefaultExchange(context);
+
+        NettyHttpConfiguration configuration = new NettyHttpConfiguration();
+        configuration.setHost("0.0.0.0");
+        configuration.setPort(8080);
+        configuration.setSsl(false);
+
+        DefaultHttpRequest request = new 
DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/foo");
+        request.headers().set(HttpHeaderNames.HOST, "realhost:9090");
+
+        Map<String, Object> headers = new HashMap<>();
+        new DefaultNettyHttpBinding().populateCamelHeaders(request, headers, 
exchange, configuration);
+
+        // Host header port suffix must be stripped; CamelHttpPort is the 
consumer port, not 9090
+        assertEquals("realhost", headers.get(NettyHttpConstants.HTTP_HOST));
+        assertEquals(8080, headers.get(NettyHttpConstants.HTTP_PORT));
+    }
+
+    /**
+     * CAMEL-28017: IPv6 Host header without port (e.g. "[::1]") must not be 
corrupted by the port-stripping logic;
+     * lastIndexOf(':') on "[::1]" hits a colon inside the brackets, not a 
port separator (RFC 7230 §5.4).
+     */
+    @Test
+    public void testRelativeUriIpv6HostHeaderWithoutPort() throws Exception {
+        CamelContext context = new DefaultCamelContext();
+        Exchange exchange = new DefaultExchange(context);
+
+        NettyHttpConfiguration configuration = new NettyHttpConfiguration();
+        configuration.setHost("0.0.0.0");
+        configuration.setPort(8080);
+        configuration.setSsl(false);
+
+        DefaultHttpRequest request = new 
DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/foo");
+        request.headers().set(HttpHeaderNames.HOST, "[::1]");
+
+        Map<String, Object> headers = new HashMap<>();
+        new DefaultNettyHttpBinding().populateCamelHeaders(request, headers, 
exchange, configuration);
+
+        // IPv6 literal must be preserved verbatim, not truncated to "[:"
+        assertEquals("[::1]", headers.get(NettyHttpConstants.HTTP_HOST));
+        assertEquals(8080, headers.get(NettyHttpConstants.HTTP_PORT));
+    }
+
+    /**
+     * CAMEL-28017: IPv6 Host header with port (e.g. "[::1]:9090") must strip 
the port suffix while keeping the
+     * bracketed address intact (RFC 7230 §5.4).
+     */
+    @Test
+    public void testRelativeUriIpv6HostHeaderWithPort() throws Exception {
+        CamelContext context = new DefaultCamelContext();
+        Exchange exchange = new DefaultExchange(context);
+
+        NettyHttpConfiguration configuration = new NettyHttpConfiguration();
+        configuration.setHost("0.0.0.0");
+        configuration.setPort(8080);
+        configuration.setSsl(false);
+
+        DefaultHttpRequest request = new 
DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/foo");
+        request.headers().set(HttpHeaderNames.HOST, "[::1]:9090");
+
+        Map<String, Object> headers = new HashMap<>();
+        new DefaultNettyHttpBinding().populateCamelHeaders(request, headers, 
exchange, configuration);
+
+        // Port suffix after the closing bracket must be stripped; bracketed 
address must be intact
+        assertEquals("[::1]", headers.get(NettyHttpConstants.HTTP_HOST));
+        assertEquals(8080, headers.get(NettyHttpConstants.HTTP_PORT));
+    }
+
+    /**
+     * CAMEL-28017: proxy-style absolute URI (GET http://example.com/foo 
HTTP/1.1) must use the URI's own scheme and
+     * host, and the conventional default port 80, not the proxy's configured 
port.
+     */
+    @Test
+    public void testAbsoluteUriWithoutPortUsesConventionalDefault() throws 
Exception {
+        CamelContext context = new DefaultCamelContext();
+        Exchange exchange = new DefaultExchange(context);
+
+        // Simulate a proxy endpoint on port 3128
+        NettyHttpConfiguration configuration = new NettyHttpConfiguration();
+        configuration.setHost("0.0.0.0");
+        configuration.setPort(3128);
+        configuration.setSsl(false);
+
+        DefaultHttpRequest request
+                = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, 
"http://example.com/foo";);
+
+        Map<String, Object> headers = new HashMap<>();
+        new DefaultNettyHttpBinding().populateCamelHeaders(request, headers, 
exchange, configuration);
+
+        assertEquals("http", headers.get(NettyHttpConstants.HTTP_SCHEME));
+        assertEquals("example.com", headers.get(NettyHttpConstants.HTTP_HOST));
+        // No port in the URI → conventional default is 80 (not the proxy's 
3128)
+        assertEquals(80, headers.get(NettyHttpConstants.HTTP_PORT));
+    }
+
+    /**
+     * CAMEL-28017: proxy-style absolute URI with an explicit port must use 
the URI's port.
+     */
+    @Test
+    public void testAbsoluteUriWithExplicitPortUsesUriPort() throws Exception {
+        CamelContext context = new DefaultCamelContext();
+        Exchange exchange = new DefaultExchange(context);
+
+        NettyHttpConfiguration configuration = new NettyHttpConfiguration();
+        configuration.setHost("0.0.0.0");
+        configuration.setPort(8080);
+        configuration.setSsl(false);
+
+        DefaultHttpRequest request
+                = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, 
"http://example.com:9090/foo";);
+
+        Map<String, Object> headers = new HashMap<>();
+        new DefaultNettyHttpBinding().populateCamelHeaders(request, headers, 
exchange, configuration);
+
+        assertEquals("http", headers.get(NettyHttpConstants.HTTP_SCHEME));
+        assertEquals("example.com", headers.get(NettyHttpConstants.HTTP_HOST));
+        assertEquals(9090, headers.get(NettyHttpConstants.HTTP_PORT));
+    }
 }
diff --git 
a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_25.adoc 
b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_25.adoc
index 3a0694b8ba06..eeb5819b9fa4 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_25.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_25.adoc
@@ -13,6 +13,22 @@ See the xref:camel-upgrade-recipes-tool.adoc[documentation] 
page for details.
 
 == Upgrading Camel 4.24 to 4.25
 
+=== camel-netty-http - CamelHttpScheme, CamelHttpHost and CamelHttpPort 
populated for relative request lines
+
+The `camel-netty-http` consumer now populates `CamelHttpScheme`, 
`CamelHttpHost` and `CamelHttpPort` even when
+the incoming request line is relative (e.g. `GET /foo?x=1 HTTP/1.1`), which is 
the standard form used by
+direct HTTP/1.1 clients.
+
+* `CamelHttpScheme` — derived from the consumer's ssl configuration (`https` 
when ssl is enabled, `http` otherwise).
+  Previously it was `null` for relative request lines.
+* `CamelHttpHost` — taken from the HTTP `Host` header first; falls back to the 
consumer's configured host.
+  Previously it was `null` for relative request lines.
+* `CamelHttpPort` — the consumer's configured port. Previously it was 80 or 
443 regardless of the actual port.
+
+For absolute-URI request lines (proxy-style: `GET http://example.com/foo 
HTTP/1.1`) the behaviour is unchanged:
+scheme, host and port come from the URI. When the absolute URI carries no 
port, the conventional default
+(80 for http, 443 for https) is used as before.
+
 === Rest DSL - CORS credentials require a configured origin
 
 When CORS is enabled with `Access-Control-Allow-Credentials=true` 
(`corsAllowCredentials(true)`) and
diff --git 
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/NettyHttpEndpointBuilderFactory.java
 
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/NettyHttpEndpointBuilderFactory.java
index 476187b1c718..d495576344dd 100644
--- 
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/NettyHttpEndpointBuilderFactory.java
+++ 
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/NettyHttpEndpointBuilderFactory.java
@@ -5834,9 +5834,11 @@ public interface NettyHttpEndpointBuilderFactory {
             return "CamelHttpUri";
         }
         /**
-         * The scheme of the request URI, http or https, when the request line
-         * has an absolute URI, as the requests to a proxy (httpProxy) have.
-         * Otherwise null.
+         * The scheme of the request URI (http or https). For relative request
+         * lines (e.g. /foo?x=1, as sent by standard HTTP/1.1 clients to a
+         * server) the scheme is derived from the consumer's ssl configuration.
+         * For absolute-URI request lines (e.g. proxy-style:
+         * http://example.com/foo) the scheme comes from the URI itself.
          * 
          * The option is a: {@code String} type.
          * 
@@ -5848,8 +5850,11 @@ public interface NettyHttpEndpointBuilderFactory {
             return "CamelHttpScheme";
         }
         /**
-         * The host of the request URI, when the request line has an absolute
-         * URI, as the requests to a proxy (httpProxy) have. Otherwise null.
+         * The host of the request. For relative request lines (e.g. /foo?x=1)
+         * the host is taken from the HTTP Host header first; if that is 
absent,
+         * it falls back to the consumer's configured host. For absolute-URI
+         * request lines (e.g. proxy-style: http://example.com/foo) the host
+         * comes from the URI itself.
          * 
          * The option is a: {@code String} type.
          * 
@@ -5861,9 +5866,12 @@ public interface NettyHttpEndpointBuilderFactory {
             return "CamelHttpHost";
         }
         /**
-         * The port of the request URI, when the request line has an absolute
-         * URI with a port. Otherwise 443 when ssl is enabled or the scheme is
-         * https, and 80 otherwise.
+         * The port of the request. For relative request lines (e.g. /foo?x=1)
+         * the port is taken from the consumer's configured port. For
+         * absolute-URI request lines with an explicit port (e.g.
+         * http://example.com:9090/foo) the port comes from the URI. For
+         * absolute-URI request lines without a port the conventional default 
is
+         * used: 443 for https, 80 for http.
          * 
          * The option is a: {@code Integer} type.
          * 

Reply via email to