This is an automated email from the ASF dual-hosted git repository. zregvart pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
commit 8a242ab267fff4c2ca7aead7d7e37e7a8a814c57 Author: Zoran Regvart <[email protected]> AuthorDate: Fri May 22 12:58:12 2020 +0200 CAMEL-15101: header binding mismatch This makes sure that the Camel message headers are bound correctly with respect to the URL given on the request. If using `https` scheme or configured with `ssl=true` when the port is not specified this sets the `Exchange.HTTP_PORT` to `433` instead of `80`; and when absolute URL is specified on the Netty `HttpRequest`, this makes sure that the `Exchange.HTTP_URL` contains that URL instead of concatenation of the URL from configuration and the URL from request. --- .../camel/component/netty/http/DefaultNettyHttpBinding.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 c1b6ac6..20d18cf 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 @@ -150,9 +150,9 @@ public class DefaultNettyHttpBinding implements NettyHttpBinding, Cloneable { // we want the full path for the url, as the client may provide the url in the HTTP headers as absolute or relative, eg // /foo // http://servername/foo - String http = configuration.isSsl() ? "https://" : "http://"; - if (!s.startsWith(http)) { - if (configuration.getPort() != 80) { + if (!s.startsWith("http://") && !s.startsWith("https://")) { + String http = configuration.isSsl() ? "https://" : "http://"; + if (configuration.getPort() != 80 && configuration.getPort() != 443) { s = http + configuration.getHost() + ":" + configuration.getPort() + s; } else { s = http + configuration.getHost() + s; @@ -169,7 +169,7 @@ public class DefaultNettyHttpBinding implements NettyHttpBinding, Cloneable { headers.put(Exchange.HTTP_SCHEME, uri.getScheme()); headers.put(Exchange.HTTP_HOST, uri.getHost()); final int port = uri.getPort(); - headers.put(Exchange.HTTP_PORT, port > 0 ? port : 80); + headers.put(Exchange.HTTP_PORT, port > 0 ? port : configuration.isSsl() || "https".equals(uri.getScheme()) ? 443 : 80); // strip the starting endpoint path so the path is relative to the endpoint uri String path = uri.getRawPath();
