CAMEL-15012: camel-http - Support using proxyHost,proxyPort parameters.
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java
index 28255bd..64a931c 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java
@@ -184,6 +184,13 @@
}
String proxyAuthHost = getParameter(parameters, "proxyAuthHost", String.class);
Integer proxyAuthPort = getParameter(parameters, "proxyAuthPort", Integer.class);
+ // fallback to alternative option name
+ if (proxyAuthHost == null) {
+ proxyAuthHost = getParameter(parameters, "proxyHost", String.class);
+ }
+ if (proxyAuthPort == null) {
+ proxyAuthPort = getParameter(parameters, "proxyPort", Integer.class);
+ }
if (proxyAuthHost != null && proxyAuthPort != null) {
String proxyAuthUsername = getParameter(parameters, "proxyAuthUsername", String.class);
@@ -191,6 +198,8 @@
String proxyAuthDomain = getParameter(parameters, "proxyAuthDomain", String.class);
String proxyAuthNtHost = getParameter(parameters, "proxyAuthNtHost", String.class);
+ LOG.debug("Configuring HTTP client to use HTTP proxy {}:{}", proxyAuthHost, proxyAuthPort);
+
if (proxyAuthUsername != null && proxyAuthPassword != null) {
return CompositeHttpConfigurer.combineConfigurers(
configurer, new ProxyHttpClientConfigurer(proxyAuthHost, proxyAuthPort, proxyAuthScheme, proxyAuthUsername, proxyAuthPassword, proxyAuthDomain, proxyAuthNtHost));
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProxyServerTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProxyServerTest.java
index 3589e63..bd2c5be 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProxyServerTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProxyServerTest.java
@@ -113,6 +113,15 @@
assertExchange(exchange);
}
+ @Test
+ public void httpGetWithProxyAndWithoutUserTwo() throws Exception {
+
+ Exchange exchange = template.request("http://" + getProxyHost() + ":" + getProxyPort() + "?proxyHost=" + getProxyHost() + "&proxyPort=" + getProxyPort(), exchange1 -> {
+ });
+
+ assertExchange(exchange);
+ }
+
private String getProxyHost() {
return proxy.getInetAddress().getHostName();
}