Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Jenkinsfile.talend
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ org.apache.camel:camel-drill,\
org.apache.camel:camel-dynamic-router,\
org.apache.camel:camel-file,\
org.apache.camel:camel-google-pubsub,\
org.apache.camel:camel-http-common,\
org.apache.camel:camel-http,\
org.apache.camel:camel-infinispan,\
org.apache.camel:camel-jaxb,\
Expand Down
2 changes: 2 additions & 0 deletions components/camel-http-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@

<name>Camel :: HTTP :: Common</name>
<description>Camel HTTP common</description>
<version>${revision}</version>

<properties>
<revision>${camel-http-common.tesb.version}</revision>
<firstVersion>2.16.0</firstVersion>
</properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ public abstract class HttpCommonEndpoint extends DefaultEndpoint
private String proxyHost;
@UriParam(label = "producer,proxy", description = "Proxy port to use")
private int proxyPort;
@UriParam(label = "producer,proxy", enums = "http,https", description = "Proxy authentication scheme to use")
@UriParam(label = "producer,proxy", enums = "http,https", defaultValue = "http",
description = "Proxy server connection protocol scheme. Defaults to http regardless of the target endpoint scheme,"
+ " because most corporate HTTP proxies expect a plain HTTP connection on their listener port.")
private String proxyAuthScheme;
@UriParam(label = "producer,proxy", enums = "Basic,Digest,NTLM", description = "Proxy authentication method to use")
private String proxyAuthMethod;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ public class HttpConfiguration implements Serializable {
private String proxyHost;
@Metadata(label = "producer,proxy", description = "Proxy port to use")
private int proxyPort;
@Metadata(label = "producer,proxy", enums = "http,https", description = "Authentication scheme to use")
@Metadata(label = "producer,proxy", enums = "http,https", defaultValue = "http",
description = "Proxy server connection protocol scheme. Defaults to http regardless of the target endpoint scheme,"
+ " because most corporate HTTP proxies expect a plain HTTP connection on their listener port.")
private String proxyAuthScheme;
@Metadata(label = "producer,proxy", enums = "Basic,Digest,NTLM", description = "Proxy authentication method to use")
private String proxyAuthMethod;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ public class HttpComponent extends HttpCommonComponent implements RestProducerFa
protected Timeout responseTimeout = Timeout.ofMilliseconds(0);

// proxy
@Metadata(label = "producer,proxy", enums = "http,https", description = "Proxy authentication protocol scheme")
@Metadata(label = "producer,proxy", enums = "http,https", defaultValue = "http",
description = "Proxy server connection protocol scheme. Defaults to http regardless of the target endpoint scheme,"
+ " because most corporate HTTP proxies expect a plain HTTP connection on their listener port.")
protected String proxyAuthScheme;
@Metadata(label = "producer,proxy", enums = "Basic,Digest,NTLM", description = "Proxy authentication method to use")
protected String proxyAuthMethod;
Expand Down Expand Up @@ -222,7 +224,7 @@ protected HttpClientConfigurer createHttpClientConfigurer(Map<String, Object> pa
}
HttpCredentialsHelper credentialsProvider = new HttpCredentialsHelper();
configurer = configureBasicAuthentication(parameters, configurer, credentialsProvider);
configurer = configureHttpProxy(parameters, configurer, secure, credentialsProvider);
configurer = configureHttpProxy(parameters, configurer, credentialsProvider);
configurer = configureOAuth2Authentication(parameters, configurer);

return configurer;
Expand Down Expand Up @@ -270,12 +272,12 @@ private HttpClientConfigurer configureBasicAuthentication(
}

private HttpClientConfigurer configureHttpProxy(
Map<String, Object> parameters, HttpClientConfigurer configurer, boolean secure,
Map<String, Object> parameters, HttpClientConfigurer configurer,
HttpCredentialsHelper credentialsProvider) {
String proxyAuthScheme = getParameter(parameters, "proxyAuthScheme", String.class, getProxyAuthScheme());
if (proxyAuthScheme == null) {
// fallback and use either http or https depending on secure
proxyAuthScheme = secure ? "https" : "http";
// proxy connection itself uses http by default regardless of the target endpoint scheme
proxyAuthScheme = "http";
}
String proxyAuthHost = getParameter(parameters, "proxyAuthHost", String.class, getProxyAuthHost());
Integer proxyAuthPort = getParameter(parameters, "proxyAuthPort", Integer.class, getProxyAuthPort());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.apache.camel.Producer;
import org.apache.camel.api.management.ManagedAttribute;
import org.apache.camel.api.management.ManagedResource;
import org.apache.camel.http.base.HttpHelper;
import org.apache.camel.http.base.cookie.CookieHandler;
import org.apache.camel.http.common.HttpCommonEndpoint;
import org.apache.camel.spi.Metadata;
Expand Down Expand Up @@ -255,9 +254,9 @@ protected HttpClient createHttpClient() {
String host = getCamelContext().getGlobalOption("http.proxyHost");
int port = Integer.parseInt(getCamelContext().getGlobalOption("http.proxyPort"));
String scheme = getCamelContext().getGlobalOption("http.proxyScheme");
// fallback and use either http or https depending on secure
// proxy connection uses http by default regardless of the target endpoint scheme
if (scheme == null) {
scheme = HttpHelper.isSecureConnection(getEndpointUri()) ? "https" : "http";
scheme = "http";
}
LOG.debug(
"CamelContext properties http.proxyHost, http.proxyPort, and http.proxyScheme detected. Using http proxy host: {} port: {} scheme: {}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package org.apache.camel.component.http;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand All @@ -26,6 +27,8 @@
import org.apache.camel.component.http.interceptor.RequestProxyBasicAuth;
import org.apache.camel.component.http.interceptor.ResponseProxyBasicUnauthorized;
import org.apache.camel.util.URISupport;
import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.HttpRequestInterceptor;
import org.apache.hc.core5.http.HttpResponseInterceptor;
import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
Expand All @@ -36,6 +39,7 @@
import org.junit.jupiter.api.Test;

import static org.apache.camel.component.http.HttpMethods.GET;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class HttpProxyServerTest extends BaseHttpTest {
Expand Down Expand Up @@ -129,6 +133,30 @@ public void httpGetWithProxyOnComponent() {
assertExchange(exchange);
}

@Test
public void httpsTargetWithProxyDefaultsToHttpProxyScheme() throws Exception {
// CAMEL-24632: proxy scheme must default to "http" regardless of the target endpoint scheme
HttpEndpoint endpoint = context.getEndpoint(
"https://www.example.com?proxyHost=myproxy&proxyPort=8080", HttpEndpoint.class);

HttpClientConfigurer configurer = endpoint.getHttpClientConfigurer();
assertThat(configurer).isNotNull();

HttpClientBuilder builder = HttpClientBuilder.create();
configurer.configureHttpClient(builder);

Field proxyField = HttpClientBuilder.class.getDeclaredField("proxy");
proxyField.setAccessible(true);
HttpHost proxy = (HttpHost) proxyField.get(builder);

assertThat(proxy).isNotNull();
assertThat(proxy.getHostName()).isEqualTo("myproxy");
assertThat(proxy.getPort()).isEqualTo(8080);
assertThat(proxy.getSchemeName())
.as("Proxy scheme must be http even when the target endpoint is https")
.isEqualTo("http");
}

private String getHost() {
return "127.0.0.1";
}
Expand Down
7 changes: 4 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@
<camel-dynamic-router.tesb.version>4.8.1.20250320</camel-dynamic-router.tesb.version>
<camel-file.tesb.version>4.8.1.20250320</camel-file.tesb.version>
<camel-google-pubsub.tesb.version>4.8.1.20260608</camel-google-pubsub.tesb.version>
<camel-http.tesb.version>4.8.1.20250320</camel-http.tesb.version>
<camel-http.tesb.version>4.8.1.20260909</camel-http.tesb.version>
<camel-http-common.tesb.version>4.8.1.20260909</camel-http-common.tesb.version>
<camel-infinispan.tesb.version>4.8.1.20260608</camel-infinispan.tesb.version>
<camel-jaxb.tesb.version>4.8.1.20250320</camel-jaxb.tesb.version>
<camel-jms.tesb.version>4.8.1.20260608</camel-jms.tesb.version>
Expand Down Expand Up @@ -179,8 +180,8 @@
<camel-management.tesb.version>4.8.1.20250320</camel-management.tesb.version>
<camel-management-api.tesb.version>4.8.1.20250320</camel-management-api.tesb.version>
<camel-yaml-io.tesb.version>4.8.1.20250320</camel-yaml-io.tesb.version>
<camel-componentdsl.tesb.version>4.8.1.20260608</camel-componentdsl.tesb.version>
<camel-endpointdsl.tesb.version>4.8.1.20260608</camel-endpointdsl.tesb.version>
<camel-componentdsl.tesb.version>4.8.1.20260909</camel-componentdsl.tesb.version>
<camel-endpointdsl.tesb.version>4.8.1.20260909</camel-endpointdsl.tesb.version>
<camel-jbang-container.tesb.version>4.8.1.20250320</camel-jbang-container.tesb.version>
<camel-jbang-core.tesb.version>4.8.1.20250320</camel-jbang-core.tesb.version>
<camel-jbang-main.tesb.version>4.8.1.20250320</camel-jbang-main.tesb.version>
Expand Down
Loading