This is an automated email from the ASF dual-hosted git repository. orpiske pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
commit c065da1a8078f2df49d8d8739b7a5827afafda64 Author: Otavio Rodolfo Piske <angusyo...@gmail.com> AuthorDate: Wed May 8 09:12:17 2024 +0200 (chores) camel-http-base: code cleanup - break large and complex methods --- .../camel/http/base/HttpSendDynamicAware.java | 36 ++++++++++++++-------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/components/camel-http-base/src/main/java/org/apache/camel/http/base/HttpSendDynamicAware.java b/components/camel-http-base/src/main/java/org/apache/camel/http/base/HttpSendDynamicAware.java index 1f6658ab5d6..63f9b40faf1 100644 --- a/components/camel-http-base/src/main/java/org/apache/camel/http/base/HttpSendDynamicAware.java +++ b/components/camel-http-base/src/main/java/org/apache/camel/http/base/HttpSendDynamicAware.java @@ -139,13 +139,7 @@ public class HttpSendDynamicAware extends SendDynamicAwareSupport { boolean httpComponent = "http".equals(getScheme()) || "https".equals(getScheme()); boolean vertxHttpComponent = "vertx-http".equals(getScheme()); if (!httpComponent && !vertxHttpComponent) { - String prefix = getScheme() + "://"; - String prefix2 = getScheme() + ":"; - if (u.startsWith(prefix)) { - u = u.substring(prefix.length()); - } else if (u.startsWith(prefix2)) { - u = u.substring(prefix2.length()); - } + u = parseDefaultUri(u); } // remove query parameters @@ -154,12 +148,7 @@ public class HttpSendDynamicAware extends SendDynamicAwareSupport { } if (vertxHttpComponent && u.startsWith("vertx-http:")) { - u = u.substring(11); - // must include http prefix - String scheme = ResourceHelper.getScheme(u); - if (scheme == null) { - u = "http://" + u; - } + u = parseVertexUri(u); } // must include :// in scheme to be parsable via java.net.URI @@ -211,4 +200,25 @@ public class HttpSendDynamicAware extends SendDynamicAwareSupport { return new String[] { u, null, null }; } + private String parseDefaultUri(String u) { + String prefix = getScheme() + "://"; + String prefix2 = getScheme() + ":"; + if (u.startsWith(prefix)) { + u = u.substring(prefix.length()); + } else if (u.startsWith(prefix2)) { + u = u.substring(prefix2.length()); + } + return u; + } + + private static String parseVertexUri(String u) { + u = u.substring(11); + // must include http prefix + String scheme = ResourceHelper.getScheme(u); + if (scheme == null) { + u = "http://" + u; + } + return u; + } + }