You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by nf...@apache.org on 2023/03/17 11:55:28 UTC

[camel] branch CAMEL-18995/upgrade-httpcomponents-5 updated (e9459cf5762 -> 78d2264be7a)

This is an automated email from the ASF dual-hosted git repository.

nfilotto pushed a change to branch CAMEL-18995/upgrade-httpcomponents-5
in repository https://gitbox.apache.org/repos/asf/camel.git


 discard e9459cf5762 CAMEL-18995: camel-box - Upgrade to HttpComponents 5.x
 discard 88963375f1c CAMEL-18995: camel-cxf - Upgrade to HttpComponents 5.x
 discard 1b8b19f4ce2 CAMEL-18995: camel-http-common - Upgrade to HttpComponents 5.x
 discard a16038dd0d0 CAMEL-18995: camel-http-base - Upgrade to HttpComponents 5.x
 discard 810e77367d1 CAMEL-18995: camel-workday - Upgrade to HttpComponents 5.x
 discard bab0d5e0a12 CAMEL-18995: camel-wordpress - Upgrade to HttpComponents 5.x
 discard 865bfb42698 CAMEL-18995: camel-weather - Upgrade to HttpComponents 5.x
 discard 432364bdd35 CAMEL-18995: camel-splunk-hec - Upgrade to HttpComponents 5.x
 discard 747062ddad1 CAMEL-18995: camel-oaipmh - Upgrade to HttpComponents 5.x
 discard 686858c5aee CAMEL-18995: camel-graphql - Upgrade to HttpComponents 5.x
 discard 5805296d9af CAMEL-18995: camel-geocoder - Upgrade to HttpComponents 5.x
 discard f9d563d667a CAMEL-18995: camel-cm-sms - Upgrade to HttpComponents 5.x
 discard 5ec7f6eb17c CAMEL-18995: camel-undertow - Upgrade to HttpComponents 5.x
 discard c939125e52d CAMEL-18995: camel-jetty - Upgrade to HttpComponents 5.x
 discard 2b16481aa51 CAMEL-18995: camel-http - Upgrade to HttpComponents 5.x
     new f03ca71e289 CAMEL-18995: camel-http - Upgrade to HttpComponents 5.x
     new 24722f20e32 CAMEL-18995: camel-jetty - Upgrade to HttpComponents 5.x
     new 9b53322769e CAMEL-18995: camel-undertow - Upgrade to HttpComponents 5.x
     new 615d951f269 CAMEL-18995: camel-cm-sms - Upgrade to HttpComponents 5.x
     new 09354ae1fcc CAMEL-18995: camel-geocoder - Upgrade to HttpComponents 5.x
     new f2b4f875b34 CAMEL-18995: camel-graphql - Upgrade to HttpComponents 5.x
     new 56ce8e2780b CAMEL-18995: camel-oaipmh - Upgrade to HttpComponents 5.x
     new 5fc43ea0877 CAMEL-18995: camel-splunk-hec - Upgrade to HttpComponents 5.x
     new 76a20c0bee6 CAMEL-18995: camel-weather - Upgrade to HttpComponents 5.x
     new 8c12bd6e62e CAMEL-18995: camel-wordpress - Upgrade to HttpComponents 5.x
     new 220e2a4ece0 CAMEL-18995: camel-workday - Upgrade to HttpComponents 5.x
     new b3495fcc026 CAMEL-18995: camel-http-base - Upgrade to HttpComponents 5.x
     new 0e716e34a31 CAMEL-18995: camel-http-common - Upgrade to HttpComponents 5.x
     new 2d49cc30a53 CAMEL-18995: camel-cxf - Upgrade to HttpComponents 5.x
     new 78d2264be7a CAMEL-18995: camel-box - Upgrade to HttpComponents 5.x

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (e9459cf5762)
            \
             N -- N -- N   refs/heads/CAMEL-18995/upgrade-httpcomponents-5 (78d2264be7a)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 15 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../java/org/apache/camel/component/http/HttpMethods.java   |  6 +++---
 .../apache/camel/component/http/HttpPollingConsumer.java    |  8 ++++----
 .../java/org/apache/camel/component/http/HttpProducer.java  | 13 ++++++-------
 3 files changed, 13 insertions(+), 14 deletions(-)


[camel] 06/15: CAMEL-18995: camel-graphql - Upgrade to HttpComponents 5.x

Posted by nf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

nfilotto pushed a commit to branch CAMEL-18995/upgrade-httpcomponents-5
in repository https://gitbox.apache.org/repos/asf/camel.git

commit f2b4f875b346b0da12b728d579751f4160eb95bd
Author: Nicolas Filotto <nf...@talend.com>
AuthorDate: Fri Mar 17 12:28:35 2023 +0100

    CAMEL-18995: camel-graphql - Upgrade to HttpComponents 5.x
---
 components/camel-graphql/pom.xml                   |  6 +-
 .../camel/component/graphql/GraphqlEndpoint.java   | 31 +++++-----
 .../camel/component/graphql/GraphqlProducer.java   | 16 ++---
 .../component/graphql/server/GraphqlServer.java    | 72 +++++++++++-----------
 4 files changed, 63 insertions(+), 62 deletions(-)

diff --git a/components/camel-graphql/pom.xml b/components/camel-graphql/pom.xml
index a19af884ff1..5bee1fd5803 100644
--- a/components/camel-graphql/pom.xml
+++ b/components/camel-graphql/pom.xml
@@ -43,9 +43,9 @@
         </dependency>
 
         <dependency>
-            <groupId>org.apache.httpcomponents</groupId>
-            <artifactId>httpclient</artifactId>
-            <version>${httpclient4-version}</version>
+            <groupId>org.apache.httpcomponents.client5</groupId>
+            <artifactId>httpclient5</artifactId>
+            <version>${httpclient-version}</version>
         </dependency>
 
         <!-- for testing -->
diff --git a/components/camel-graphql/src/main/java/org/apache/camel/component/graphql/GraphqlEndpoint.java b/components/camel-graphql/src/main/java/org/apache/camel/component/graphql/GraphqlEndpoint.java
index cedf3b409e9..80869870fc8 100644
--- a/components/camel-graphql/src/main/java/org/apache/camel/component/graphql/GraphqlEndpoint.java
+++ b/components/camel-graphql/src/main/java/org/apache/camel/component/graphql/GraphqlEndpoint.java
@@ -34,17 +34,16 @@ import org.apache.camel.support.DefaultEndpoint;
 import org.apache.camel.util.IOHelper;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.util.json.JsonObject;
-import org.apache.http.HttpHeaders;
-import org.apache.http.HttpHost;
-import org.apache.http.auth.AuthScope;
-import org.apache.http.auth.UsernamePasswordCredentials;
-import org.apache.http.client.CredentialsProvider;
-import org.apache.http.client.utils.HttpClientUtils;
-import org.apache.http.impl.client.BasicCredentialsProvider;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClientBuilder;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.message.BasicHeader;
+import org.apache.hc.client5.http.auth.AuthScope;
+import org.apache.hc.client5.http.auth.CredentialsStore;
+import org.apache.hc.client5.http.auth.UsernamePasswordCredentials;
+import org.apache.hc.client5.http.impl.auth.BasicCredentialsProvider;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
+import org.apache.hc.client5.http.impl.classic.HttpClients;
+import org.apache.hc.core5.http.HttpHeaders;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.message.BasicHeader;
 
 /**
  * Send GraphQL queries and mutations to external systems.
@@ -87,7 +86,9 @@ public class GraphqlEndpoint extends DefaultEndpoint {
 
     @Override
     protected void doStop() throws Exception {
-        HttpClientUtils.closeQuietly(this.httpClient);
+        if (httpClient != null) {
+            httpClient.close();
+        }
     }
 
     @Override
@@ -124,8 +125,10 @@ public class GraphqlEndpoint extends DefaultEndpoint {
                     Arrays.asList(new BasicHeader(HttpHeaders.AUTHORIZATION, authType + " " + accessToken)));
         }
         if (username != null && password != null) {
-            CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
-            credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(username, password));
+            CredentialsStore credentialsProvider = new BasicCredentialsProvider();
+            credentialsProvider.setCredentials(
+                    new AuthScope(null, -1),
+                    new UsernamePasswordCredentials(username, password.toCharArray()));
             httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
         }
         return httpClientBuilder.build();
diff --git a/components/camel-graphql/src/main/java/org/apache/camel/component/graphql/GraphqlProducer.java b/components/camel-graphql/src/main/java/org/apache/camel/component/graphql/GraphqlProducer.java
index 9478bab248c..7bbfab7ec45 100644
--- a/components/camel-graphql/src/main/java/org/apache/camel/component/graphql/GraphqlProducer.java
+++ b/components/camel-graphql/src/main/java/org/apache/camel/component/graphql/GraphqlProducer.java
@@ -23,13 +23,13 @@ import org.apache.camel.Exchange;
 import org.apache.camel.InvalidPayloadException;
 import org.apache.camel.support.DefaultAsyncProducer;
 import org.apache.camel.util.json.JsonObject;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpHeaders;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.ContentType;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.util.EntityUtils;
+import org.apache.hc.client5.http.classic.methods.HttpPost;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.core5.http.ContentType;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.HttpHeaders;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
+import org.apache.hc.core5.http.io.entity.StringEntity;
 
 public class GraphqlProducer extends DefaultAsyncProducer {
 
@@ -49,7 +49,7 @@ public class GraphqlProducer extends DefaultAsyncProducer {
             URI httpUri = getEndpoint().getHttpUri();
             String requestBody = buildRequestBody(getQuery(exchange), getEndpoint().getOperationName(),
                     getVariables(exchange));
-            HttpEntity requestEntity = new StringEntity(requestBody, ContentType.create("application/json", "UTF-8"));
+            HttpEntity requestEntity = new StringEntity(requestBody, ContentType.APPLICATION_JSON);
 
             HttpPost httpPost = new HttpPost(httpUri);
             httpPost.setHeader(HttpHeaders.ACCEPT, "application/json");
diff --git a/components/camel-graphql/src/test/java/org/apache/camel/component/graphql/server/GraphqlServer.java b/components/camel-graphql/src/test/java/org/apache/camel/component/graphql/server/GraphqlServer.java
index 1e56aaa50c9..4621f5f77f9 100644
--- a/components/camel-graphql/src/test/java/org/apache/camel/component/graphql/server/GraphqlServer.java
+++ b/components/camel-graphql/src/test/java/org/apache/camel/component/graphql/server/GraphqlServer.java
@@ -18,23 +18,22 @@ package org.apache.camel.component.graphql.server;
 
 import java.io.IOException;
 import java.util.Map;
-import java.util.concurrent.TimeUnit;
 
 import com.fasterxml.jackson.core.type.TypeReference;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import graphql.ExecutionInput;
 import graphql.ExecutionResult;
 import graphql.GraphQL;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpEntityEnclosingRequest;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.protocol.HttpRequestHandler;
-import org.apache.http.util.EntityUtils;
+import org.apache.hc.core5.http.ClassicHttpRequest;
+import org.apache.hc.core5.http.ClassicHttpResponse;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.io.HttpRequestHandler;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
+import org.apache.hc.core5.http.io.entity.StringEntity;
+import org.apache.hc.core5.http.protocol.HttpContext;
 
 public class GraphqlServer {
 
@@ -44,7 +43,7 @@ public class GraphqlServer {
     public GraphqlServer() {
         this.graphql = GraphqlFactory.newGraphQL();
         this.server = ServerBootstrap.bootstrap()
-                .registerHandler("/graphql", new GraphqlHandler())
+                .register("/graphql", new GraphqlHandler())
                 .create();
     }
 
@@ -53,7 +52,7 @@ public class GraphqlServer {
     }
 
     public void shutdown() {
-        server.shutdown(0, TimeUnit.SECONDS);
+        server.close();
     }
 
     public int getPort() {
@@ -64,33 +63,32 @@ public class GraphqlServer {
 
         private final ObjectMapper objectMapper = new ObjectMapper();
 
-        public void handle(HttpRequest request, HttpResponse response, HttpContext context)
-                throws IOException {
-            if (request instanceof HttpEntityEnclosingRequest) {
-                HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity();
-                String json = EntityUtils.toString(entity);
-
-                Map<String, Object> map = jsonToMap(json);
-                String query = (String) map.get("query");
-                String operationName = (String) map.get("operationName");
-                Map<String, Object> variables = (Map<String, Object>) map.get("variables");
-
-                ExecutionInput executionInput = ExecutionInput.newExecutionInput()
-                        .query(query)
-                        .operationName(operationName)
-                        .variables(variables)
-                        .build();
-                ExecutionResult executionResult = graphql.execute(executionInput);
-                Map<String, Object> resultMap = executionResult.toSpecification();
-                String result = objectMapper.writeValueAsString(resultMap);
-
-                response.setHeader("Content-Type", "application/json; charset=UTF-8");
-                response.setEntity(new StringEntity(result));
-            }
+        @SuppressWarnings("unchecked")
+        public void handle(ClassicHttpRequest request, ClassicHttpResponse response, HttpContext context)
+                throws HttpException, IOException {
+            HttpEntity entity = request.getEntity();
+            String json = EntityUtils.toString(entity);
+
+            Map<String, Object> map = jsonToMap(json);
+            String query = (String) map.get("query");
+            String operationName = (String) map.get("operationName");
+            Map<String, Object> variables = (Map<String, Object>) map.get("variables");
+
+            ExecutionInput executionInput = ExecutionInput.newExecutionInput()
+                    .query(query)
+                    .operationName(operationName)
+                    .variables(variables)
+                    .build();
+            ExecutionResult executionResult = graphql.execute(executionInput);
+            Map<String, Object> resultMap = executionResult.toSpecification();
+            String result = objectMapper.writeValueAsString(resultMap);
+
+            response.setHeader("Content-Type", "application/json; charset=UTF-8");
+            response.setEntity(new StringEntity(result));
         }
 
         private Map<String, Object> jsonToMap(String json) throws IOException {
-            return objectMapper.readValue(json, new TypeReference<Map<String, Object>>() {
+            return objectMapper.readValue(json, new TypeReference<>() {
             });
         }
 


[camel] 13/15: CAMEL-18995: camel-http-common - Upgrade to HttpComponents 5.x

Posted by nf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

nfilotto pushed a commit to branch CAMEL-18995/upgrade-httpcomponents-5
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 0e716e34a315e695e033dbf6056aacb37097dcfa
Author: Nicolas Filotto <nf...@talend.com>
AuthorDate: Fri Mar 17 12:37:41 2023 +0100

    CAMEL-18995: camel-http-common - Upgrade to HttpComponents 5.x
---
 .../src/main/java/org/apache/camel/http/common/HttpHelper.java          | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpHelper.java b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpHelper.java
index ef7fcf1565b..9ca91573cbe 100644
--- a/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpHelper.java
+++ b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpHelper.java
@@ -118,7 +118,7 @@ public final class HttpHelper {
             return null;
         }
 
-        Object answer = null;
+        Object answer;
         ObjectInputStream ois = new CamelObjectInputStream(is, context);
         try {
             answer = ois.readObject();


[camel] 08/15: CAMEL-18995: camel-splunk-hec - Upgrade to HttpComponents 5.x

Posted by nf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

nfilotto pushed a commit to branch CAMEL-18995/upgrade-httpcomponents-5
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 5fc43ea08777f44e0b6a128af66815b452c8315c
Author: Nicolas Filotto <nf...@talend.com>
AuthorDate: Fri Mar 17 12:31:37 2023 +0100

    CAMEL-18995: camel-splunk-hec - Upgrade to HttpComponents 5.x
---
 components/camel-splunk-hec/pom.xml                |  6 +--
 .../component/splunkhec/SplunkHECProducer.java     | 60 +++++++++++++---------
 2 files changed, 39 insertions(+), 27 deletions(-)

diff --git a/components/camel-splunk-hec/pom.xml b/components/camel-splunk-hec/pom.xml
index 6fc08cd3681..380f8823b89 100644
--- a/components/camel-splunk-hec/pom.xml
+++ b/components/camel-splunk-hec/pom.xml
@@ -43,9 +43,9 @@
             <version>${jackson2-version}</version>
         </dependency>
         <dependency>
-            <groupId>org.apache.httpcomponents</groupId>
-            <artifactId>httpclient</artifactId>
-            <version>${httpclient4-version}</version>
+            <groupId>org.apache.httpcomponents.client5</groupId>
+            <artifactId>httpclient5</artifactId>
+            <version>${httpclient-version}</version>
         </dependency>
         <dependency>
             <groupId>commons-validator</groupId>
diff --git a/components/camel-splunk-hec/src/main/java/org/apache/camel/component/splunkhec/SplunkHECProducer.java b/components/camel-splunk-hec/src/main/java/org/apache/camel/component/splunkhec/SplunkHECProducer.java
index f0438ad26cf..9caacf18e86 100644
--- a/components/camel-splunk-hec/src/main/java/org/apache/camel/component/splunkhec/SplunkHECProducer.java
+++ b/components/camel-splunk-hec/src/main/java/org/apache/camel/component/splunkhec/SplunkHECProducer.java
@@ -25,23 +25,25 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.apache.camel.support.DefaultProducer;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.conn.ssl.NoopHostnameVerifier;
-import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
-import org.apache.http.entity.ContentType;
-import org.apache.http.entity.EntityTemplate;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClientBuilder;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.ssl.SSLContextBuilder;
+import org.apache.hc.client5.http.classic.methods.HttpPost;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
+import org.apache.hc.client5.http.impl.classic.HttpClients;
+import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager;
+import org.apache.hc.client5.http.socket.ConnectionSocketFactory;
+import org.apache.hc.client5.http.ssl.NoopHostnameVerifier;
+import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory;
+import org.apache.hc.core5.http.ContentType;
+import org.apache.hc.core5.http.config.RegistryBuilder;
+import org.apache.hc.core5.http.io.entity.EntityTemplate;
+import org.apache.hc.core5.ssl.SSLContextBuilder;
 
 /**
  * The Splunk HEC producer.
  */
 public class SplunkHECProducer extends DefaultProducer {
     private static final ObjectMapper MAPPER = new ObjectMapper();
-    private SplunkHECEndpoint endpoint;
+    private final SplunkHECEndpoint endpoint;
     private CloseableHttpClient httpClient;
 
     public SplunkHECProducer(SplunkHECEndpoint endpoint) {
@@ -53,14 +55,22 @@ public class SplunkHECProducer extends DefaultProducer {
     protected void doStart() throws Exception {
         super.doStart();
         HttpClientBuilder builder = HttpClients.custom()
-                .setUserAgent("Camel Splunk HEC/" + getEndpoint().getCamelContext().getVersion()).setMaxConnTotal(10);
+                .setUserAgent("Camel Splunk HEC/" + getEndpoint().getCamelContext().getVersion());
+        PoolingHttpClientConnectionManager connManager;
         if (endpoint.getConfiguration().isSkipTlsVerify()) {
             SSLContextBuilder sslbuilder = new SSLContextBuilder();
             sslbuilder.loadTrustMaterial(null, (chain, authType) -> true);
             SSLConnectionSocketFactory sslsf
                     = new SSLConnectionSocketFactory(sslbuilder.build(), NoopHostnameVerifier.INSTANCE);
-            builder.setSSLSocketFactory(sslsf);
+            RegistryBuilder<ConnectionSocketFactory> registryBuilder = RegistryBuilder.create();
+            registryBuilder.register("https", sslsf);
+
+            connManager = new PoolingHttpClientConnectionManager(registryBuilder.build());
+        } else {
+            connManager = new PoolingHttpClientConnectionManager();
         }
+        connManager.setMaxTotal(10);
+        builder.setConnectionManager(connManager);
         httpClient = builder.build();
     }
 
@@ -73,19 +83,21 @@ public class SplunkHECProducer extends DefaultProducer {
                                          + endpoint.getSplunkURL() + endpoint.getConfiguration().getSplunkEndpoint());
         httppost.addHeader("Authorization", " Splunk " + endpoint.getToken());
 
-        EntityTemplate entityTemplate = new EntityTemplate(outputStream -> MAPPER.writer().writeValue(outputStream, payload));
-        entityTemplate.setContentType(ContentType.APPLICATION_JSON.getMimeType());
+        EntityTemplate entityTemplate = new EntityTemplate(
+                -1, ContentType.APPLICATION_JSON, null, outputStream -> MAPPER.writer().writeValue(outputStream, payload));
 
         httppost.setEntity(entityTemplate);
-        try (CloseableHttpResponse response = httpClient.execute(httppost)) {
-            if (response.getStatusLine().getStatusCode() != 200) {
-                ByteArrayOutputStream output = new ByteArrayOutputStream();
-                response.getEntity().writeTo(output);
-
-                throw new RuntimeException(
-                        response.getStatusLine().toString() + "\n" + new String(output.toByteArray(), StandardCharsets.UTF_8));
-            }
-        }
+        httpClient.execute(
+                httppost,
+                response -> {
+                    if (response.getCode() != 200) {
+                        ByteArrayOutputStream output = new ByteArrayOutputStream();
+                        response.getEntity().writeTo(output);
+
+                        throw new RuntimeException(response + "\n" + output.toString(StandardCharsets.UTF_8));
+                    }
+                    return null;
+                });
     }
 
     @Override


[camel] 09/15: CAMEL-18995: camel-weather - Upgrade to HttpComponents 5.x

Posted by nf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

nfilotto pushed a commit to branch CAMEL-18995/upgrade-httpcomponents-5
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 76a20c0bee6046fc14d50dc7f7060576ecec1133
Author: Nicolas Filotto <nf...@talend.com>
AuthorDate: Fri Mar 17 12:32:41 2023 +0100

    CAMEL-18995: camel-weather - Upgrade to HttpComponents 5.x
---
 components/camel-weather/pom.xml                   |  6 +-
 .../weather/WeatherEndpointConfigurer.java         |  4 +-
 .../apache/camel/component/weather/weather.json    |  2 +-
 .../component/weather/WeatherConfiguration.java    |  4 +-
 .../camel/component/weather/WeatherConsumer.java   | 73 +++++++++++++---------
 .../camel/component/weather/WeatherEndpoint.java   | 11 ++--
 .../camel/component/weather/WeatherProducer.java   | 65 ++++++++++---------
 .../geolocation/FreeGeoIpGeoLocationProvider.java  | 52 +++++++--------
 8 files changed, 121 insertions(+), 96 deletions(-)

diff --git a/components/camel-weather/pom.xml b/components/camel-weather/pom.xml
index 3bdddc179df..81dc0a30502 100644
--- a/components/camel-weather/pom.xml
+++ b/components/camel-weather/pom.xml
@@ -38,9 +38,9 @@
         </dependency>
 
         <dependency>
-            <groupId>org.apache.httpcomponents</groupId>
-            <artifactId>httpclient</artifactId>
-            <version>${httpclient4-version}</version>
+            <groupId>org.apache.httpcomponents.client5</groupId>
+            <artifactId>httpclient5</artifactId>
+            <version>${httpclient-version}</version>
         </dependency>
 
         <!-- Jackson -->
diff --git a/components/camel-weather/src/generated/java/org/apache/camel/component/weather/WeatherEndpointConfigurer.java b/components/camel-weather/src/generated/java/org/apache/camel/component/weather/WeatherEndpointConfigurer.java
index 03f3f49b6f4..185e87319ad 100644
--- a/components/camel-weather/src/generated/java/org/apache/camel/component/weather/WeatherEndpointConfigurer.java
+++ b/components/camel-weather/src/generated/java/org/apache/camel/component/weather/WeatherEndpointConfigurer.java
@@ -46,7 +46,7 @@ public class WeatherEndpointConfigurer extends PropertyConfigurerSupport impleme
         case "headername":
         case "headerName": target.getConfiguration().setHeaderName(property(camelContext, java.lang.String.class, value)); return true;
         case "httpclient":
-        case "httpClient": target.getConfiguration().setHttpClient(property(camelContext, org.apache.http.impl.client.CloseableHttpClient.class, value)); return true;
+        case "httpClient": target.getConfiguration().setHttpClient(property(camelContext, org.apache.hc.client5.http.impl.classic.CloseableHttpClient.class, value)); return true;
         case "ids": target.getConfiguration().setIds(property(camelContext, java.lang.String.class, value)); return true;
         case "initialdelay":
         case "initialDelay": target.setInitialDelay(property(camelContext, long.class, value)); return true;
@@ -118,7 +118,7 @@ public class WeatherEndpointConfigurer extends PropertyConfigurerSupport impleme
         case "headername":
         case "headerName": return java.lang.String.class;
         case "httpclient":
-        case "httpClient": return org.apache.http.impl.client.CloseableHttpClient.class;
+        case "httpClient": return org.apache.hc.client5.http.impl.classic.CloseableHttpClient.class;
         case "ids": return java.lang.String.class;
         case "initialdelay":
         case "initialDelay": return long.class;
diff --git a/components/camel-weather/src/generated/resources/org/apache/camel/component/weather/weather.json b/components/camel-weather/src/generated/resources/org/apache/camel/component/weather/weather.json
index b0172ed7151..d0864797e1b 100644
--- a/components/camel-weather/src/generated/resources/org/apache/camel/component/weather/weather.json
+++ b/components/camel-weather/src/generated/resources/org/apache/camel/component/weather/weather.json
@@ -46,7 +46,7 @@
     "pollStrategy": { "kind": "parameter", "displayName": "Poll Strategy", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "object", "javaType": "org.apache.camel.spi.PollingConsumerPollStrategy", "deprecated": false, "autowired": false, "secret": false, "description": "A pluggable org.apache.camel.PollingConsumerPollingStrategy allowing you to provide your custom implementation to control error handling usually occurred during the poll operation  [...]
     "lazyStartProducer": { "kind": "parameter", "displayName": "Lazy Start Producer", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may other [...]
     "geoLocationProvider": { "kind": "parameter", "displayName": "Geo Location Provider", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.component.weather.geolocation.GeoLocationProvider", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.weather.WeatherConfiguration", "configurationField": "configuration", "description": "A custum geolocation provider to determine the  [...]
-    "httpClient": { "kind": "parameter", "displayName": "Http Client", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.http.impl.client.CloseableHttpClient", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.weather.WeatherConfiguration", "configurationField": "configuration", "description": "To use an existing configured http client (for example with http proxy)" },
+    "httpClient": { "kind": "parameter", "displayName": "Http Client", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.hc.client5.http.impl.classic.CloseableHttpClient", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.weather.WeatherConfiguration", "configurationField": "configuration", "description": "To use an existing configured http client (for example with http proxy)" },
     "cnt": { "kind": "parameter", "displayName": "Cnt", "group": "filter", "label": "filter", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.weather.WeatherConfiguration", "configurationField": "configuration", "description": "Number of results to be found" },
     "ids": { "kind": "parameter", "displayName": "Ids", "group": "filter", "label": "filter", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.weather.WeatherConfiguration", "configurationField": "configuration", "description": "List of id's of city\/stations. You can separate multiple ids by comma." },
     "lat": { "kind": "parameter", "displayName": "Lat", "group": "filter", "label": "filter", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.weather.WeatherConfiguration", "configurationField": "configuration", "description": "Latitude of location. You can use lat and lon options instead of location. For boxed queries this is the bottom latitude." },
diff --git a/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherConfiguration.java b/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherConfiguration.java
index 99c0c92d905..fc192fb6008 100644
--- a/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherConfiguration.java
+++ b/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherConfiguration.java
@@ -28,8 +28,8 @@ import org.apache.camel.spi.UriParam;
 import org.apache.camel.spi.UriParams;
 import org.apache.camel.spi.UriPath;
 import org.apache.camel.support.ObjectHelper;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.HttpClients;
 
 import static org.apache.camel.component.weather.WeatherLanguage.en;
 import static org.apache.camel.component.weather.WeatherMode.JSON;
diff --git a/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherConsumer.java b/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherConsumer.java
index 850f3dafcbb..3b9bc75afc7 100644
--- a/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherConsumer.java
+++ b/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherConsumer.java
@@ -18,13 +18,13 @@ package org.apache.camel.component.weather;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
+import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.support.ScheduledPollConsumer;
 import org.apache.camel.util.ObjectHelper;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.util.EntityUtils;
+import org.apache.hc.client5.http.classic.HttpClient;
+import org.apache.hc.client5.http.classic.methods.HttpGet;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -56,33 +56,48 @@ public class WeatherConsumer extends ScheduledPollConsumer {
         HttpClient httpClient = getEndpoint().getConfiguration().getHttpClient();
         HttpGet getMethod = new HttpGet(query);
         try {
-            HttpResponse response = httpClient.execute(getMethod);
-            if (HttpStatus.SC_OK != response.getStatusLine().getStatusCode()) {
-                LOG.warn("HTTP call for weather returned error status code {} - {} as a result with query: {}", status,
-                        response.getStatusLine().getStatusCode(), query);
-                return 0;
-            }
-            String weather = EntityUtils.toString(response.getEntity(), "UTF-8");
-            LOG.debug("Got back the Weather information {}", weather);
-            if (ObjectHelper.isEmpty(weather)) {
-                // empty response
-                return 0;
-            }
+            return httpClient.execute(
+                    getMethod,
+                    response -> {
+                        try {
+                            if (HttpStatus.SC_OK != response.getCode()) {
+                                LOG.warn("HTTP call for weather returned error status code {} - {} as a result with query: {}",
+                                        status,
+                                        response.getCode(), query);
+                                return 0;
+                            }
+                            String weather = EntityUtils.toString(response.getEntity(), "UTF-8");
+                            LOG.debug("Got back the Weather information {}", weather);
+                            if (ObjectHelper.isEmpty(weather)) {
+                                // empty response
+                                return 0;
+                            }
 
-            Exchange exchange = getEndpoint().createExchange();
-            String header = getEndpoint().getConfiguration().getHeaderName();
-            if (header != null) {
-                exchange.getIn().setHeader(header, weather);
-            } else {
-                exchange.getIn().setBody(weather);
-            }
-            exchange.getIn().setHeader(WeatherConstants.WEATHER_QUERY, query);
+                            Exchange exchange = getEndpoint().createExchange();
+                            String header = getEndpoint().getConfiguration().getHeaderName();
+                            if (header != null) {
+                                exchange.getIn().setHeader(header, weather);
+                            } else {
+                                exchange.getIn().setBody(weather);
+                            }
+                            exchange.getIn().setHeader(WeatherConstants.WEATHER_QUERY, query);
 
-            getProcessor().process(exchange);
+                            try {
+                                getProcessor().process(exchange);
+                            } catch (Exception e) {
+                                throw new RuntimeCamelException(e);
+                            }
 
-            return 1;
-        } finally {
-            getMethod.releaseConnection();
+                            return 1;
+                        } finally {
+                            getMethod.reset();
+                        }
+                    });
+        } catch (RuntimeCamelException e) {
+            if (e.getCause() instanceof Exception ex) {
+                throw ex;
+            }
+            throw e;
         }
     }
 
diff --git a/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherEndpoint.java b/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherEndpoint.java
index bf8ed254633..a5cb97c08b4 100644
--- a/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherEndpoint.java
+++ b/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherEndpoint.java
@@ -23,7 +23,7 @@ import org.apache.camel.Producer;
 import org.apache.camel.spi.UriEndpoint;
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.support.DefaultPollingEndpoint;
-import org.apache.http.client.utils.HttpClientUtils;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
 
 /**
  * Poll the weather information from Open Weather Map.
@@ -33,9 +33,9 @@ import org.apache.http.client.utils.HttpClientUtils;
 public class WeatherEndpoint extends DefaultPollingEndpoint {
 
     @UriParam
-    private WeatherConfiguration configuration;
+    private final WeatherConfiguration configuration;
 
-    private WeatherQuery weatherQuery;
+    private final WeatherQuery weatherQuery;
 
     public WeatherEndpoint(String uri, WeatherComponent component, WeatherConfiguration properties) {
         super(uri, component);
@@ -71,7 +71,10 @@ public class WeatherEndpoint extends DefaultPollingEndpoint {
     protected void doStop() throws Exception {
         super.doStop();
 
-        HttpClientUtils.closeQuietly(getConfiguration().getHttpClient());
+        CloseableHttpClient client = getConfiguration().getHttpClient();
+        if (client != null) {
+            client.close();
+        }
     }
 
 }
diff --git a/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherProducer.java b/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherProducer.java
index 4e623ee46b5..fb18d562aee 100644
--- a/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherProducer.java
+++ b/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherProducer.java
@@ -19,11 +19,10 @@ package org.apache.camel.component.weather;
 import org.apache.camel.Exchange;
 import org.apache.camel.support.DefaultProducer;
 import org.apache.camel.util.ObjectHelper;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.util.EntityUtils;
+import org.apache.hc.client5.http.classic.HttpClient;
+import org.apache.hc.client5.http.classic.methods.HttpGet;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -52,32 +51,38 @@ public class WeatherProducer extends DefaultProducer {
         }
 
         HttpClient httpClient = getEndpoint().getConfiguration().getHttpClient();
-        HttpGet method = new HttpGet(q);
-        try {
-            LOG.debug("Going to execute the Weather query {}", q);
-            HttpResponse response = httpClient.execute(method);
-            if (HttpStatus.SC_OK != response.getStatusLine().getStatusCode()) {
-                throw new IllegalStateException(
-                        "Got the invalid http status value '" + response.getStatusLine().getStatusCode()
-                                                + "' as the result of the query '" + query + "'");
-            }
-            String weather = EntityUtils.toString(response.getEntity(), "UTF-8");
-            LOG.debug("Got back the Weather information {}", weather);
+        String uri = q;
+        HttpGet method = new HttpGet(uri);
+        httpClient.execute(
+                method,
+                response -> {
+                    try {
+                        LOG.debug("Going to execute the Weather query {}", uri);
+                        if (HttpStatus.SC_OK != response.getCode()) {
+                            throw new IllegalStateException(
+                                    "Got the invalid http status value '" + response.getCode()
+                                                            + "' as the result of the query '" + query + "'");
+                        }
+                        String weather = EntityUtils.toString(response.getEntity(), "UTF-8");
+                        LOG.debug("Got back the Weather information {}", weather);
 
-            if (ObjectHelper.isEmpty(weather)) {
-                throw new IllegalStateException(
-                        "Got the unexpected value '" + weather + "' as the result of the query '" + q + "'");
-            }
+                        if (ObjectHelper.isEmpty(weather)) {
+                            throw new IllegalStateException(
+                                    "Got the unexpected value '" + weather + "' as the result of the query '" + uri + "'");
+                        }
+
+                        String header = getEndpoint().getConfiguration().getHeaderName();
+                        if (header != null) {
+                            exchange.getIn().setHeader(header, weather);
+                        } else {
+                            exchange.getIn().setBody(weather);
+                        }
+                        exchange.getIn().setHeader(WeatherConstants.WEATHER_QUERY, uri);
+                        return null;
+                    } finally {
+                        method.reset();
+                    }
+                });
 
-            String header = getEndpoint().getConfiguration().getHeaderName();
-            if (header != null) {
-                exchange.getIn().setHeader(header, weather);
-            } else {
-                exchange.getIn().setBody(weather);
-            }
-            exchange.getIn().setHeader(WeatherConstants.WEATHER_QUERY, q);
-        } finally {
-            method.releaseConnection();
-        }
     }
 }
diff --git a/components/camel-weather/src/main/java/org/apache/camel/component/weather/geolocation/FreeGeoIpGeoLocationProvider.java b/components/camel-weather/src/main/java/org/apache/camel/component/weather/geolocation/FreeGeoIpGeoLocationProvider.java
index 3b2cde4a8de..1776075b9aa 100644
--- a/components/camel-weather/src/main/java/org/apache/camel/component/weather/geolocation/FreeGeoIpGeoLocationProvider.java
+++ b/components/camel-weather/src/main/java/org/apache/camel/component/weather/geolocation/FreeGeoIpGeoLocationProvider.java
@@ -19,11 +19,10 @@ package org.apache.camel.component.weather.geolocation;
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import org.apache.camel.component.weather.WeatherConfiguration;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.util.EntityUtils;
+import org.apache.hc.client5.http.classic.HttpClient;
+import org.apache.hc.client5.http.classic.methods.HttpGet;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
 
 import static org.apache.camel.util.ObjectHelper.isEmpty;
 import static org.apache.camel.util.ObjectHelper.notNull;
@@ -49,28 +48,31 @@ public class FreeGeoIpGeoLocationProvider implements GeoLocationProvider {
         String url = String.format("http://api.ipstack.com/%s?access_key=%s&legacy=1&output=json",
                 configuration.getGeolocationRequestHostIP(), configuration.getGeolocationAccessKey());
         HttpGet getMethod = new HttpGet(url);
-        try {
-            HttpResponse response = httpClient.execute(getMethod);
-            if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
-                throw new IllegalStateException(
-                        "Got the unexpected http-status '" + response.getStatusLine().getStatusCode()
-                                                + "' for the geolocation");
-            }
-            String geoLocation = EntityUtils.toString(response.getEntity(), "UTF-8");
-            if (isEmpty(geoLocation)) {
-                throw new IllegalStateException("Got the unexpected value '" + geoLocation + "' for the geolocation");
-            }
+        return httpClient.execute(
+                getMethod,
+                response -> {
+                    try {
+                        if (response.getCode() != HttpStatus.SC_OK) {
+                            throw new IllegalStateException(
+                                    "Got the unexpected http-status '" + response.getCode()
+                                                            + "' for the geolocation");
+                        }
+                        String geoLocation = EntityUtils.toString(response.getEntity(), "UTF-8");
+                        if (isEmpty(geoLocation)) {
+                            throw new IllegalStateException(
+                                    "Got the unexpected value '" + geoLocation + "' for the geolocation");
+                        }
 
-            ObjectMapper mapper = new ObjectMapper();
-            JsonNode node = mapper.readValue(geoLocation, JsonNode.class);
-            JsonNode latitudeNode = notNull(node.get("latitude"), "latitude");
-            JsonNode longitudeNode = notNull(node.get("longitude"), "longitude");
-
-            return new GeoLocation(longitudeNode.asText(), latitudeNode.asText());
-        } finally {
-            getMethod.releaseConnection();
-        }
+                        ObjectMapper mapper = new ObjectMapper();
+                        JsonNode node = mapper.readValue(geoLocation, JsonNode.class);
+                        JsonNode latitudeNode = notNull(node.get("latitude"), "latitude");
+                        JsonNode longitudeNode = notNull(node.get("longitude"), "longitude");
 
+                        return new GeoLocation(longitudeNode.asText(), latitudeNode.asText());
+                    } finally {
+                        getMethod.reset();
+                    }
+                });
     }
 
 }


[camel] 11/15: CAMEL-18995: camel-workday - Upgrade to HttpComponents 5.x

Posted by nf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

nfilotto pushed a commit to branch CAMEL-18995/upgrade-httpcomponents-5
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 220e2a4ece04d12350bcd12940ffffcc5841516e
Author: Nicolas Filotto <nf...@talend.com>
AuthorDate: Fri Mar 17 12:33:27 2023 +0100

    CAMEL-18995: camel-workday - Upgrade to HttpComponents 5.x
---
 components/camel-workday/pom.xml                   | 11 +---
 .../workday/WorkdayEndpointConfigurer.java         |  4 +-
 .../apache/camel/component/workday/workday.json    |  2 +-
 .../component/workday/WorkdayConfiguration.java    |  2 +-
 .../workday/auth/AuthClientForIntegration.java     | 62 +++++++++---------
 ...cationClient.java => AuthenticationClient.java} |  8 +--
 .../workday/producer/WorkdayDefaultProducer.java   | 74 +++++++++++++---------
 7 files changed, 88 insertions(+), 75 deletions(-)

diff --git a/components/camel-workday/pom.xml b/components/camel-workday/pom.xml
index c46089089bd..f346db51d4c 100644
--- a/components/camel-workday/pom.xml
+++ b/components/camel-workday/pom.xml
@@ -35,14 +35,9 @@
 
   <dependencies>
     <dependency>
-      <groupId>org.apache.httpcomponents</groupId>
-      <artifactId>httpclient</artifactId>
-      <version>${httpclient4-version}</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.httpcomponents</groupId>
-      <artifactId>httpmime</artifactId>
-      <version>${httpclient4-version}</version>
+      <groupId>org.apache.httpcomponents.client5</groupId>
+      <artifactId>httpclient5</artifactId>
+      <version>${httpclient-version}</version>
     </dependency>
     <dependency>
       <groupId>org.apache.camel</groupId>
diff --git a/components/camel-workday/src/generated/java/org/apache/camel/component/workday/WorkdayEndpointConfigurer.java b/components/camel-workday/src/generated/java/org/apache/camel/component/workday/WorkdayEndpointConfigurer.java
index 09421ccdaf2..082f98a3bb8 100644
--- a/components/camel-workday/src/generated/java/org/apache/camel/component/workday/WorkdayEndpointConfigurer.java
+++ b/components/camel-workday/src/generated/java/org/apache/camel/component/workday/WorkdayEndpointConfigurer.java
@@ -27,7 +27,7 @@ public class WorkdayEndpointConfigurer extends PropertyConfigurerSupport impleme
         case "clientSecret": target.getWorkdayConfiguration().setClientSecret(property(camelContext, java.lang.String.class, value)); return true;
         case "host": target.getWorkdayConfiguration().setHost(property(camelContext, java.lang.String.class, value)); return true;
         case "httpconnectionmanager":
-        case "httpConnectionManager": target.getWorkdayConfiguration().setHttpConnectionManager(property(camelContext, org.apache.http.impl.conn.PoolingHttpClientConnectionManager.class, value)); return true;
+        case "httpConnectionManager": target.getWorkdayConfiguration().setHttpConnectionManager(property(camelContext, org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager.class, value)); return true;
         case "lazystartproducer":
         case "lazyStartProducer": target.setLazyStartProducer(property(camelContext, boolean.class, value)); return true;
         case "reportformat":
@@ -48,7 +48,7 @@ public class WorkdayEndpointConfigurer extends PropertyConfigurerSupport impleme
         case "clientSecret": return java.lang.String.class;
         case "host": return java.lang.String.class;
         case "httpconnectionmanager":
-        case "httpConnectionManager": return org.apache.http.impl.conn.PoolingHttpClientConnectionManager.class;
+        case "httpConnectionManager": return org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager.class;
         case "lazystartproducer":
         case "lazyStartProducer": return boolean.class;
         case "reportformat":
diff --git a/components/camel-workday/src/generated/resources/org/apache/camel/component/workday/workday.json b/components/camel-workday/src/generated/resources/org/apache/camel/component/workday/workday.json
index 3898e573953..2ba60b9d80a 100644
--- a/components/camel-workday/src/generated/resources/org/apache/camel/component/workday/workday.json
+++ b/components/camel-workday/src/generated/resources/org/apache/camel/component/workday/workday.json
@@ -32,7 +32,7 @@
     "entity": { "kind": "path", "displayName": "Entity", "group": "producer", "label": "", "required": true, "type": "object", "javaType": "org.apache.camel.component.workday.WorkdayConfiguration.Entity", "enum": [ "report", "commonAPI" ], "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.workday.WorkdayConfiguration", "configurationField": "workdayConfiguration", "description": "The entity to be requested o [...]
     "path": { "kind": "path", "displayName": "Path", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.workday.WorkdayConfiguration", "configurationField": "workdayConfiguration", "description": "The API path to access an entity structure." },
     "lazyStartProducer": { "kind": "parameter", "displayName": "Lazy Start Producer", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may other [...]
-    "httpConnectionManager": { "kind": "parameter", "displayName": "Http Connection Manager", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.http.impl.conn.PoolingHttpClientConnectionManager", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.workday.WorkdayConfiguration", "configurationField": "workdayConfiguration", "description": "Pool connection manager for advanced confi [...]
+    "httpConnectionManager": { "kind": "parameter", "displayName": "Http Connection Manager", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.workday.WorkdayConfiguration", "configurationField": "workdayConfiguration", "description": "Pool connection manager for advan [...]
     "reportFormat": { "kind": "parameter", "displayName": "Report Format", "group": "format", "label": "format", "required": false, "type": "string", "javaType": "java.lang.String", "enum": [ "json" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "json", "configurationClass": "org.apache.camel.component.workday.WorkdayConfiguration", "configurationField": "workdayConfiguration", "description": "Workday Report as a service output format." },
     "host": { "kind": "parameter", "displayName": "Host", "group": "host", "label": "host", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.workday.WorkdayConfiguration", "configurationField": "workdayConfiguration", "description": "Workday Host name." },
     "clientId": { "kind": "parameter", "displayName": "Client Id", "group": "security", "label": "security", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.workday.WorkdayConfiguration", "configurationField": "workdayConfiguration", "description": "Workday client Id generated by API client for integrations." },
diff --git a/components/camel-workday/src/main/java/org/apache/camel/component/workday/WorkdayConfiguration.java b/components/camel-workday/src/main/java/org/apache/camel/component/workday/WorkdayConfiguration.java
index 3ed01112d7c..d1041ba9436 100644
--- a/components/camel-workday/src/main/java/org/apache/camel/component/workday/WorkdayConfiguration.java
+++ b/components/camel-workday/src/main/java/org/apache/camel/component/workday/WorkdayConfiguration.java
@@ -25,7 +25,7 @@ import org.apache.camel.spi.UriParam;
 import org.apache.camel.spi.UriParams;
 import org.apache.camel.spi.UriPath;
 import org.apache.camel.util.ObjectHelper;
-import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
+import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager;
 
 @UriParams
 public class WorkdayConfiguration {
diff --git a/components/camel-workday/src/main/java/org/apache/camel/component/workday/auth/AuthClientForIntegration.java b/components/camel-workday/src/main/java/org/apache/camel/component/workday/auth/AuthClientForIntegration.java
index 242514628f9..31bf771d7a8 100644
--- a/components/camel-workday/src/main/java/org/apache/camel/component/workday/auth/AuthClientForIntegration.java
+++ b/components/camel-workday/src/main/java/org/apache/camel/component/workday/auth/AuthClientForIntegration.java
@@ -18,22 +18,22 @@ package org.apache.camel.component.workday.auth;
 
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
-import java.io.UnsupportedEncodingException;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Base64;
 import java.util.List;
 
 import org.apache.camel.component.workday.WorkdayConfiguration;
-import org.apache.http.HttpStatus;
-import org.apache.http.NameValuePair;
-import org.apache.http.client.entity.UrlEncodedFormEntity;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.client.methods.HttpRequestBase;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.message.BasicNameValuePair;
+import org.apache.hc.client5.http.classic.methods.HttpPost;
+import org.apache.hc.client5.http.classic.methods.HttpUriRequest;
+import org.apache.hc.client5.http.entity.UrlEncodedFormEntity;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.NameValuePair;
+import org.apache.hc.core5.http.message.BasicNameValuePair;
 
-public class AuthClientForIntegration implements AutheticationClient {
+public class AuthClientForIntegration implements AuthenticationClient {
 
     public static final String BASE_TOKEN_ENDPOINT = "https://%s/ccx/oauth2/%s/token";
 
@@ -49,15 +49,14 @@ public class AuthClientForIntegration implements AutheticationClient {
 
     private static final String CONTENT_TYPE = "application/x-www-form-urlencoded";
 
-    private WorkdayConfiguration workdayConfiguration;
+    private final WorkdayConfiguration workdayConfiguration;
 
     public AuthClientForIntegration(WorkdayConfiguration workdayConfiguration) {
         this.workdayConfiguration = workdayConfiguration;
     }
 
     @Override
-    public void configure(CloseableHttpClient httpClient, HttpRequestBase method) throws IOException {
-
+    public void configure(CloseableHttpClient httpClient, HttpUriRequest method) throws IOException {
         String bearerToken = getBearerToken(httpClient);
         method.addHeader(AUTHORIZATION_HEADER, "Bearer " + bearerToken);
 
@@ -69,33 +68,36 @@ public class AuthClientForIntegration implements AutheticationClient {
 
         HttpPost httpPost = createPostMethod(tokenUrl);
 
-        CloseableHttpResponse httpResponse = httpClient.execute(httpPost);
-
-        if (httpResponse.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
-            throw new IllegalStateException(
-                    "Got the invalid http status value '" + httpResponse.getStatusLine()
-                                            + "' as the result of the Token Request '" + tokenUrl + "'");
-        }
+        return httpClient.execute(
+                httpPost,
+                httpResponse -> {
+                    if (httpResponse.getCode() != HttpStatus.SC_OK) {
+                        throw new IllegalStateException(
+                                "Got the invalid http status value '" + httpResponse
+                                                        + "' as the result of the Token Request '" + tokenUrl + "'");
+                    }
+
+                    try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
+                        httpResponse.getEntity().writeTo(baos);
+                        return parseResponse(baos.toString());
+                    }
+                });
 
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        httpResponse.getEntity().writeTo(baos);
-        return parseResponse(baos.toString());
     }
 
-    private HttpPost createPostMethod(String tokenUrl) throws UnsupportedEncodingException {
+    private HttpPost createPostMethod(String tokenUrl) {
 
-        List<NameValuePair> nvps = new ArrayList<NameValuePair>();
+        List<NameValuePair> nvps = new ArrayList<>();
         nvps.add(new BasicNameValuePair(GRANT_TYPE, REFRESH_TOKEN));
         nvps.add(new BasicNameValuePair(REFRESH_TOKEN, workdayConfiguration.getTokenRefresh()));
 
         HttpPost postMethod = new HttpPost(tokenUrl);
         postMethod.addHeader(CONTENT_TYPE_HEADER, CONTENT_TYPE);
         postMethod.addHeader(AUTHORIZATION_HEADER,
-                "Basic " + new String(
-                        Base64.getEncoder()
-                                .encode((workdayConfiguration.getClientId() + ":" + workdayConfiguration.getClientSecret())
-                                        .getBytes())));
-        postMethod.setEntity(new UrlEncodedFormEntity(nvps, "UTF-8"));
+                "Basic " + Arrays.toString(Base64.getEncoder()
+                        .encode((workdayConfiguration.getClientId() + ":" + workdayConfiguration.getClientSecret())
+                                .getBytes())));
+        postMethod.setEntity(new UrlEncodedFormEntity(nvps, StandardCharsets.UTF_8));
 
         return postMethod;
     }
diff --git a/components/camel-workday/src/main/java/org/apache/camel/component/workday/auth/AutheticationClient.java b/components/camel-workday/src/main/java/org/apache/camel/component/workday/auth/AuthenticationClient.java
similarity index 76%
rename from components/camel-workday/src/main/java/org/apache/camel/component/workday/auth/AutheticationClient.java
rename to components/camel-workday/src/main/java/org/apache/camel/component/workday/auth/AuthenticationClient.java
index cc99354e7b7..8bb959a1f35 100644
--- a/components/camel-workday/src/main/java/org/apache/camel/component/workday/auth/AutheticationClient.java
+++ b/components/camel-workday/src/main/java/org/apache/camel/component/workday/auth/AuthenticationClient.java
@@ -18,11 +18,11 @@ package org.apache.camel.component.workday.auth;
 
 import java.io.IOException;
 
-import org.apache.http.client.methods.HttpRequestBase;
-import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.hc.client5.http.classic.methods.HttpUriRequest;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
 
-public interface AutheticationClient {
+public interface AuthenticationClient {
 
-    void configure(CloseableHttpClient httpClient, HttpRequestBase method) throws IOException;
+    void configure(CloseableHttpClient httpClient, HttpUriRequest request) throws IOException;
 
 }
diff --git a/components/camel-workday/src/main/java/org/apache/camel/component/workday/producer/WorkdayDefaultProducer.java b/components/camel-workday/src/main/java/org/apache/camel/component/workday/producer/WorkdayDefaultProducer.java
index c89b126985b..2162f06cdf6 100644
--- a/components/camel-workday/src/main/java/org/apache/camel/component/workday/producer/WorkdayDefaultProducer.java
+++ b/components/camel-workday/src/main/java/org/apache/camel/component/workday/producer/WorkdayDefaultProducer.java
@@ -17,18 +17,19 @@
 package org.apache.camel.component.workday.producer;
 
 import org.apache.camel.Exchange;
+import org.apache.camel.NoTypeConversionAvailableException;
+import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.component.workday.WorkdayConfiguration;
 import org.apache.camel.component.workday.WorkdayEndpoint;
 import org.apache.camel.component.workday.auth.AuthClientForIntegration;
-import org.apache.camel.component.workday.auth.AutheticationClient;
+import org.apache.camel.component.workday.auth.AuthenticationClient;
 import org.apache.camel.spi.Metadata;
 import org.apache.camel.support.DefaultProducer;
-import org.apache.http.HttpStatus;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClientBuilder;
-import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
+import org.apache.hc.client5.http.classic.methods.HttpGet;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
+import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager;
+import org.apache.hc.core5.http.HttpStatus;
 
 /**
  * The Workday Default producer.
@@ -38,14 +39,14 @@ public abstract class WorkdayDefaultProducer extends DefaultProducer {
     @Metadata(description = "The workday URL", javaType = "String")
     public static final String WORKDAY_URL_HEADER = "CamelWorkdayURL";
 
-    private WorkdayEndpoint endpoint;
+    private final WorkdayEndpoint endpoint;
 
-    private AutheticationClient autheticationClient;
+    private final AuthenticationClient authenticationClient;
 
     public WorkdayDefaultProducer(WorkdayEndpoint endpoint) {
         super(endpoint);
         this.endpoint = endpoint;
-        this.autheticationClient = new AuthClientForIntegration(this.endpoint.getWorkdayConfiguration());
+        this.authenticationClient = new AuthClientForIntegration(this.endpoint.getWorkdayConfiguration());
     }
 
     @Override
@@ -60,26 +61,41 @@ public abstract class WorkdayDefaultProducer extends DefaultProducer {
         String workdayUri = prepareUri(endpoint.getWorkdayConfiguration());
 
         HttpGet httpGet = new HttpGet(workdayUri);
-        this.autheticationClient.configure(httpClient, httpGet);
-
-        CloseableHttpResponse httpResponse = httpClient.execute(httpGet);
-
-        if (httpResponse.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
-            throw new IllegalStateException(
-                    "Got the invalid http status value '" + httpResponse.getStatusLine() + "' as the result of the RAAS '"
-                                            + workdayUri + "'");
-        }
-
-        String report = getEndpoint().getCamelContext().getTypeConverter().mandatoryConvertTo(String.class,
-                httpResponse.getEntity().getContent());
-
-        if (report.isEmpty()) {
-            throw new IllegalStateException(
-                    "Got the unexpected value '" + report + "' as the result of the report '" + workdayUri + "'");
+        this.authenticationClient.configure(httpClient, httpGet);
+
+        try {
+            httpClient.execute(
+                    httpGet,
+                    httpResponse -> {
+                        if (httpResponse.getCode() != HttpStatus.SC_OK) {
+                            throw new IllegalStateException(
+                                    "Got the invalid http status value '" + httpResponse + "' as the result of the RAAS '"
+                                                            + workdayUri + "'");
+                        }
+
+                        try {
+                            String report = getEndpoint().getCamelContext().getTypeConverter().mandatoryConvertTo(String.class,
+                                    httpResponse.getEntity().getContent());
+
+                            if (report.isEmpty()) {
+                                throw new IllegalStateException(
+                                        "Got the unexpected value '" + report + "' as the result of the report '" + workdayUri
+                                                                + "'");
+                            }
+
+                            exchange.getIn().setBody(report);
+                            exchange.getIn().setHeader(WORKDAY_URL_HEADER, workdayUri);
+                            return null;
+                        } catch (NoTypeConversionAvailableException e) {
+                            throw new RuntimeCamelException(e);
+                        }
+                    });
+        } catch (RuntimeCamelException e) {
+            if (e.getCause() instanceof Exception ex) {
+                throw ex;
+            }
+            throw e;
         }
-
-        exchange.getIn().setBody(report);
-        exchange.getIn().setHeader(WORKDAY_URL_HEADER, workdayUri);
     }
 
     public abstract String prepareUri(WorkdayConfiguration configuration) throws Exception;


[camel] 02/15: CAMEL-18995: camel-jetty - Upgrade to HttpComponents 5.x

Posted by nf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

nfilotto pushed a commit to branch CAMEL-18995/upgrade-httpcomponents-5
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 24722f20e32e5dc42249ea7f7dc0da2605f7c1da
Author: Nicolas Filotto <nf...@talend.com>
AuthorDate: Fri Mar 17 12:25:20 2023 +0100

    CAMEL-18995: camel-jetty - Upgrade to HttpComponents 5.x
---
 components/camel-jetty/pom.xml                     | 12 +---
 .../camel/component/jetty/CustomFiltersTest.java   | 32 +++++----
 .../camel/component/jetty/EnableCORSTest.java      | 37 +++++------
 .../camel/component/jetty/HttpBasicAuthTest.java   |  6 +-
 .../jetty/HttpBridgeMultipartRouteTest.java        | 30 ++++-----
 .../component/jetty/HttpGZipEncodingTest.java      |  6 +-
 .../camel/component/jetty/HttpHeaderCaseTest.java  | 23 +++----
 .../component/jetty/HttpMethodRestrictTest.java    | 34 +++++-----
 .../component/jetty/HttpProducerSOTimeoutTest.java |  4 +-
 .../camel/component/jetty/HttpRouteTest.java       | 76 ++++++++++------------
 .../jetty/JettyComponentMuteExceptionTest.java     | 23 ++++---
 .../jetty/JettyEndpointSetHttpTraceTest.java       | 25 +++----
 .../component/jetty/JettyHttpContentTypeTest.java  | 10 +--
 .../component/jetty/JettyMuteExceptionTest.java    | 24 ++++---
 .../jetty/JettySwitchingStatusCode204Test.java     | 50 +++++++-------
 .../camel/component/jetty/MultiPartFormTest.java   | 24 +++----
 .../jetty/MultiPartFormWithCustomFilterTest.java   | 37 ++++++-----
 .../component/jetty/MultiThreadedHttpGetTest.java  |  8 ++-
 .../component/jetty/SpringHttpsRouteTest.java      |  2 +-
 19 files changed, 221 insertions(+), 242 deletions(-)

diff --git a/components/camel-jetty/pom.xml b/components/camel-jetty/pom.xml
index 5c15c205334..c6b815729b0 100644
--- a/components/camel-jetty/pom.xml
+++ b/components/camel-jetty/pom.xml
@@ -155,15 +155,9 @@
             <scope>test</scope>
         </dependency>
         <dependency>
-            <groupId>org.apache.httpcomponents</groupId>
-            <artifactId>httpclient</artifactId>
-            <version>${httpclient4-version}</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.httpcomponents</groupId>
-            <artifactId>httpmime</artifactId>
-            <version>${httpclient4-version}</version>
+            <groupId>org.apache.httpcomponents.client5</groupId>
+            <artifactId>httpclient5</artifactId>
+            <version>${httpclient-version}</version>
             <scope>test</scope>
         </dependency>
         <dependency>
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/CustomFiltersTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/CustomFiltersTest.java
index 28107e03e39..6e57728a886 100644
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/CustomFiltersTest.java
+++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/CustomFiltersTest.java
@@ -33,12 +33,12 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.util.EntityUtils;
+import org.apache.hc.client5.http.classic.methods.HttpPost;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.classic.HttpClients;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
+import org.apache.hc.core5.http.io.entity.StringEntity;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -69,23 +69,21 @@ public class CustomFiltersTest extends BaseJettyTest {
     }
 
     private void sendRequestAndVerify(String url) throws Exception {
-        CloseableHttpClient client = HttpClients.createDefault();
-
         HttpPost httppost = new HttpPost(url);
         httppost.setEntity(new StringEntity("This is a test"));
 
-        HttpResponse response = client.execute(httppost);
-
-        assertEquals(200, response.getStatusLine().getStatusCode(), "Get a wrong response status");
-        String responseString = EntityUtils.toString(response.getEntity(), "UTF-8");
+        try (CloseableHttpClient client = HttpClients.createDefault();
+             CloseableHttpResponse response = client.execute(httppost)) {
 
-        assertEquals("This is a test response", responseString, "Get a wrong result");
-        assertEquals("true", response.getFirstHeader("MyTestFilter").getValue(), "Did not use custom multipart filter");
+            assertEquals(200, response.getCode(), "Get a wrong response status");
+            String responseString = EntityUtils.toString(response.getEntity(), "UTF-8");
 
-        // just make sure the KeyWord header is set
-        assertEquals("KEY", response.getFirstHeader("KeyWord").getValue(), "Did not set the right KeyWord header");
+            assertEquals("This is a test response", responseString, "Get a wrong result");
+            assertEquals("true", response.getFirstHeader("MyTestFilter").getValue(), "Did not use custom multipart filter");
 
-        client.close();
+            // just make sure the KeyWord header is set
+            assertEquals("KEY", response.getFirstHeader("KeyWord").getValue(), "Did not set the right KeyWord header");
+        }
     }
 
     @Test
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/EnableCORSTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/EnableCORSTest.java
index 8cf15d34cae..5d067835054 100644
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/EnableCORSTest.java
+++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/EnableCORSTest.java
@@ -17,10 +17,10 @@
 package org.apache.camel.component.jetty;
 
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
+import org.apache.hc.client5.http.classic.methods.HttpGet;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.classic.HttpClients;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -31,38 +31,33 @@ public class EnableCORSTest extends BaseJettyTest {
 
     @Test
     public void testCORSdisabled() throws Exception {
-        CloseableHttpClient client = HttpClients.createDefault();
-
         HttpGet httpMethod = new HttpGet("http://localhost:" + getPort() + "/test1");
         httpMethod.addHeader("Origin", "http://localhost:9000");
         httpMethod.addHeader("Referer", "http://localhost:9000");
+        try (CloseableHttpClient client = HttpClients.createDefault();
+             CloseableHttpResponse response = client.execute(httpMethod)) {
 
-        HttpResponse response = client.execute(httpMethod);
-
-        assertEquals(200, response.getStatusLine().getStatusCode(), "Get a wrong response status");
-
-        Object responseHeader = response.getFirstHeader("Access-Control-Allow-Credentials");
-        assertNull(responseHeader, "Access-Control-Allow-Credentials HEADER should not be set");
+            assertEquals(200, response.getCode(), "Get a wrong response status");
 
-        client.close();
+            Object responseHeader = response.getFirstHeader("Access-Control-Allow-Credentials");
+            assertNull(responseHeader, "Access-Control-Allow-Credentials HEADER should not be set");
+        }
     }
 
     @Test
     public void testCORSenabled() throws Exception {
-        CloseableHttpClient client = HttpClients.createDefault();
-
         HttpGet httpMethod = new HttpGet("http://localhost:" + getPort2() + "/test2");
         httpMethod.addHeader("Origin", "http://localhost:9000");
         httpMethod.addHeader("Referer", "http://localhost:9000");
 
-        HttpResponse response = client.execute(httpMethod);
-
-        assertEquals(200, response.getStatusLine().getStatusCode(), "Get a wrong response status");
+        try (CloseableHttpClient client = HttpClients.createDefault();
+             CloseableHttpResponse response = client.execute(httpMethod)) {
 
-        String responseHeader = response.getFirstHeader("Access-Control-Allow-Credentials").getValue();
-        assertTrue(Boolean.parseBoolean(responseHeader), "CORS not enabled");
+            assertEquals(200, response.getCode(), "Get a wrong response status");
 
-        client.close();
+            String responseHeader = response.getFirstHeader("Access-Control-Allow-Credentials").getValue();
+            assertTrue(Boolean.parseBoolean(responseHeader), "CORS not enabled");
+        }
     }
 
     @Override
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpBasicAuthTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpBasicAuthTest.java
index 61990160c21..b7c61c325cd 100644
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpBasicAuthTest.java
+++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpBasicAuthTest.java
@@ -17,7 +17,7 @@
 package org.apache.camel.component.jetty;
 
 import java.security.Principal;
-import java.util.Arrays;
+import java.util.List;
 
 import jakarta.servlet.http.HttpServletRequest;
 
@@ -53,11 +53,11 @@ public class HttpBasicAuthTest extends BaseJettyTest {
 
         ConstraintSecurityHandler sh = new ConstraintSecurityHandler();
         sh.setAuthenticator(new BasicAuthenticator());
-        sh.setConstraintMappings(Arrays.asList(new ConstraintMapping[] { cm }));
+        sh.setConstraintMappings(List.of(cm));
 
         HashLoginService loginService = new HashLoginService("MyRealm", "src/test/resources/myRealm.properties");
         sh.setLoginService(loginService);
-        sh.setConstraintMappings(Arrays.asList(new ConstraintMapping[] { cm }));
+        sh.setConstraintMappings(List.of(cm));
 
         return sh;
     }
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpBridgeMultipartRouteTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpBridgeMultipartRouteTest.java
index a8234021922..18362525387 100644
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpBridgeMultipartRouteTest.java
+++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpBridgeMultipartRouteTest.java
@@ -24,13 +24,13 @@ import org.apache.camel.attachment.AttachmentMessage;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.http.HttpEndpoint;
 import org.apache.camel.support.DefaultHeaderFilterStrategy;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.mime.MultipartEntityBuilder;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.util.EntityUtils;
+import org.apache.hc.client5.http.classic.methods.HttpPost;
+import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.classic.HttpClients;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -53,21 +53,19 @@ public class HttpBridgeMultipartRouteTest extends BaseJettyTest {
     public void testHttpClient() throws Exception {
         File jpg = new File("src/test/resources/java.jpg");
         String body = "TEST";
-
-        CloseableHttpClient client = HttpClients.createDefault();
         HttpPost method = new HttpPost("http://localhost:" + port2 + "/test/hello");
         HttpEntity entity = MultipartEntityBuilder.create().addTextBody("body", body).addBinaryBody(jpg.getName(), jpg).build();
         method.setEntity(entity);
 
-        HttpResponse response = client.execute(method);
-
-        String responseString = EntityUtils.toString(response.getEntity(), "UTF-8");
-        assertEquals(body, responseString);
+        try (CloseableHttpClient client = HttpClients.createDefault();
+             CloseableHttpResponse response = client.execute(method)) {
 
-        String numAttachments = response.getFirstHeader("numAttachments").getValue();
-        assertEquals("2", numAttachments);
+            String responseString = EntityUtils.toString(response.getEntity(), "UTF-8");
+            assertEquals(body, responseString);
 
-        client.close();
+            String numAttachments = response.getFirstHeader("numAttachments").getValue();
+            assertEquals("2", numAttachments);
+        }
     }
 
     @Override
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpGZipEncodingTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpGZipEncodingTest.java
index bf955f6ae37..54f8ca71d5f 100644
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpGZipEncodingTest.java
+++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpGZipEncodingTest.java
@@ -26,13 +26,13 @@ import org.apache.camel.builder.ExpressionBuilder;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.http.HttpClientConfigurer;
 import org.apache.camel.spi.Registry;
-import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
 import org.junit.jupiter.api.Disabled;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 
-@Disabled("TODO: investigate for Camel 3.0.  The test actally works fine, but the "
+@Disabled("TODO: investigate for Camel 3.0.  The test actually works fine, but the "
           + "test needs to be verified as http supports gzip by default, so some tests may "
           + "have to be changed to stay meaningful.")
 public class HttpGZipEncodingTest extends BaseJettyTest {
@@ -95,7 +95,7 @@ public class HttpGZipEncodingTest extends BaseJettyTest {
                         exchange.getMessage().setHeader(Exchange.CONTENT_ENCODING, "gzip");
                         // check the Accept Encoding header
                         String header = exchange.getIn().getHeader("Accept-Encoding", String.class);
-                        if (header != null && header.indexOf("gzip") > -1) {
+                        if (header != null && header.contains("gzip")) {
                             exchange.getMessage().setBody("<b>Hello World for gzip</b>");
                         } else {
                             exchange.getMessage().setBody("<b>Hello World</b>");
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpHeaderCaseTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpHeaderCaseTest.java
index fadd835bb35..5e9968da093 100644
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpHeaderCaseTest.java
+++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpHeaderCaseTest.java
@@ -22,11 +22,11 @@ import java.util.Map;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.util.EntityUtils;
+import org.apache.hc.client5.http.classic.methods.HttpPost;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.classic.HttpClients;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -35,19 +35,20 @@ public class HttpHeaderCaseTest extends BaseJettyTest {
 
     @Test
     public void testHttpHeaderCase() throws Exception {
-        CloseableHttpClient client = HttpClients.createDefault();
         HttpPost method = new HttpPost("http://localhost:" + getPort() + "/myapp/mytest");
 
         method.addHeader("clientHeader", "fooBAR");
         method.addHeader("OTHER", "123");
         method.addHeader("beer", "Carlsberg");
 
-        HttpResponse response = client.execute(method);
-        String responseString = EntityUtils.toString(response.getEntity(), "UTF-8");
+        try (CloseableHttpClient client = HttpClients.createDefault();
+             CloseableHttpResponse response = client.execute(method)) {
+            String responseString = EntityUtils.toString(response.getEntity(), "UTF-8");
 
-        assertEquals("Bye World", responseString);
-        assertEquals("aBc123", response.getFirstHeader("MyCaseHeader").getValue());
-        assertEquals("456DEf", response.getFirstHeader("otherCaseHeader").getValue());
+            assertEquals("Bye World", responseString);
+            assertEquals("aBc123", response.getFirstHeader("MyCaseHeader").getValue());
+            assertEquals("456DEf", response.getFirstHeader("otherCaseHeader").getValue());
+        }
     }
 
     @Override
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpMethodRestrictTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpMethodRestrictTest.java
index 5e3f09c32d0..bd48d928769 100644
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpMethodRestrictTest.java
+++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpMethodRestrictTest.java
@@ -20,13 +20,13 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.util.EntityUtils;
+import org.apache.hc.client5.http.classic.methods.HttpGet;
+import org.apache.hc.client5.http.classic.methods.HttpPost;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.classic.HttpClients;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
+import org.apache.hc.core5.http.io.entity.StringEntity;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -39,25 +39,25 @@ public class HttpMethodRestrictTest extends BaseJettyTest {
 
     @Test
     public void testProperHttpMethod() throws Exception {
-        CloseableHttpClient client = HttpClients.createDefault();
         HttpPost httpPost = new HttpPost(getUrl());
         httpPost.setEntity(new StringEntity("This is a test"));
-        HttpResponse response = client.execute(httpPost);
+        try (CloseableHttpClient client = HttpClients.createDefault();
+             CloseableHttpResponse response = client.execute(httpPost)) {
 
-        assertEquals(200, response.getStatusLine().getStatusCode(), "Get a wrong response status");
-        String responseString = EntityUtils.toString(response.getEntity(), "UTF-8");
-        assertEquals("This is a test response", responseString, "Get a wrong result");
-
-        client.close();
+            assertEquals(200, response.getCode(), "Get a wrong response status");
+            String responseString = EntityUtils.toString(response.getEntity(), "UTF-8");
+            assertEquals("This is a test response", responseString, "Get a wrong result");
+        }
     }
 
     @Test
     public void testImproperHttpMethod() throws Exception {
-        CloseableHttpClient client = HttpClients.createDefault();
         HttpGet httpGet = new HttpGet(getUrl());
-        HttpResponse response = client.execute(httpGet);
+        try (CloseableHttpClient client = HttpClients.createDefault();
+             CloseableHttpResponse response = client.execute(httpGet)) {
 
-        assertEquals(405, response.getStatusLine().getStatusCode(), "Get a wrong response status");
+            assertEquals(405, response.getCode(), "Get a wrong response status");
+        }
     }
 
     @Override
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpProducerSOTimeoutTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpProducerSOTimeoutTest.java
index 337c95e29d7..bb7e5401d55 100644
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpProducerSOTimeoutTest.java
+++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpProducerSOTimeoutTest.java
@@ -37,7 +37,7 @@ public class HttpProducerSOTimeoutTest extends BaseJettyTest {
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedMessageCount(1);
 
-        String out = template.requestBody("http://localhost:{{port}}/myservice?socketTimeout=5000", null, String.class);
+        String out = template.requestBody("http://localhost:{{port}}/myservice?responseTimeout=5000", null, String.class);
         assertEquals("Bye World", out);
 
         MockEndpoint.assertIsSatisfied(context);
@@ -50,7 +50,7 @@ public class HttpProducerSOTimeoutTest extends BaseJettyTest {
 
         try {
             // we use a timeout of 1 second
-            template.requestBody("http://localhost:{{port}}/myservice?socketTimeout=1000", null, String.class);
+            template.requestBody("http://localhost:{{port}}/myservice?responseTimeout=1000", null, String.class);
             fail("Should throw an exception");
         } catch (RuntimeCamelException e) {
             assertIsInstanceOf(SocketTimeoutException.class, e.getCause());
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpRouteTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpRouteTest.java
index 12142982029..3566f2b913f 100644
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpRouteTest.java
+++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpRouteTest.java
@@ -33,14 +33,14 @@ import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.converter.stream.InputStreamCache;
 import org.apache.camel.http.common.HttpMessage;
 import org.apache.camel.test.AvailablePortFinder;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.client.methods.HttpPut;
-import org.apache.http.entity.ContentType;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
+import org.apache.hc.client5.http.classic.methods.HttpGet;
+import org.apache.hc.client5.http.classic.methods.HttpPost;
+import org.apache.hc.client5.http.classic.methods.HttpPut;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.classic.HttpClients;
+import org.apache.hc.core5.http.ContentType;
+import org.apache.hc.core5.http.io.entity.StringEntity;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.RegisterExtension;
 import org.slf4j.Logger;
@@ -114,55 +114,47 @@ public class HttpRouteTest extends BaseJettyTest {
 
     @Test
     public void testPostParameter() throws Exception {
-        CloseableHttpClient client = HttpClients.createDefault();
         HttpPost post = new HttpPost("http://localhost:" + port1 + "/parameter");
         post.addHeader("request", "PostParameter");
         post.addHeader("others", "bloggs");
-
-        HttpResponse response = client.execute(post);
-        String out = context.getTypeConverter().convertTo(String.class, response.getEntity().getContent());
-        assertEquals("PostParameter", out, "Get a wrong output ");
-
-        client.close();
+        try (CloseableHttpClient client = HttpClients.createDefault();
+             CloseableHttpResponse response = client.execute(post)) {
+            String out = context.getTypeConverter().convertTo(String.class, response.getEntity().getContent());
+            assertEquals("PostParameter", out, "Get a wrong output ");
+        }
     }
 
     @Test
     public void testPostXMLMessage() throws Exception {
-        CloseableHttpClient client = HttpClients.createDefault();
         HttpPost post = new HttpPost("http://localhost:" + port1 + "/postxml");
         post.setEntity(new StringEntity(POST_MESSAGE, ContentType.APPLICATION_XML));
-
-        HttpResponse response = client.execute(post);
-        String out = context.getTypeConverter().convertTo(String.class, response.getEntity().getContent());
-        assertEquals("OK", out, "Get a wrong output ");
-
-        client.close();
+        try (CloseableHttpClient client = HttpClients.createDefault();
+             CloseableHttpResponse response = client.execute(post)) {
+            String out = context.getTypeConverter().convertTo(String.class, response.getEntity().getContent());
+            assertEquals("OK", out, "Get a wrong output ");
+        }
     }
 
     @Test
     public void testPostParameterInURI() throws Exception {
-        CloseableHttpClient client = HttpClients.createDefault();
         HttpPost post = new HttpPost("http://localhost:" + port1 + "/parameter?request=PostParameter&others=bloggs");
         post.setEntity(new StringEntity(POST_MESSAGE, ContentType.APPLICATION_XML));
-
-        HttpResponse response = client.execute(post);
-        String out = context.getTypeConverter().convertTo(String.class, response.getEntity().getContent());
-        assertEquals("PostParameter", out, "Get a wrong output ");
-
-        client.close();
+        try (CloseableHttpClient client = HttpClients.createDefault();
+             CloseableHttpResponse response = client.execute(post)) {
+            String out = context.getTypeConverter().convertTo(String.class, response.getEntity().getContent());
+            assertEquals("PostParameter", out, "Get a wrong output ");
+        }
     }
 
     @Test
     public void testPutParameterInURI() throws Exception {
-        CloseableHttpClient client = HttpClients.createDefault();
         HttpPut put = new HttpPut("http://localhost:" + port1 + "/parameter?request=PutParameter&others=bloggs");
         put.setEntity(new StringEntity(POST_MESSAGE, ContentType.APPLICATION_XML));
-
-        HttpResponse response = client.execute(put);
-        String out = context.getTypeConverter().convertTo(String.class, response.getEntity().getContent());
-        assertEquals("PutParameter", out, "Get a wrong output ");
-
-        client.close();
+        try (CloseableHttpClient client = HttpClients.createDefault();
+             CloseableHttpResponse response = client.execute(put)) {
+            String out = context.getTypeConverter().convertTo(String.class, response.getEntity().getContent());
+            assertEquals("PutParameter", out, "Get a wrong output ");
+        }
     }
 
     @Test
@@ -185,14 +177,12 @@ public class HttpRouteTest extends BaseJettyTest {
 
     @Test
     public void testResponseCode() throws Exception {
-        CloseableHttpClient client = HttpClients.createDefault();
         HttpGet get = new HttpGet("http://localhost:" + port1 + "/responseCode");
-
-        HttpResponse response = client.execute(get);
-        // just make sure we get the right
-        assertEquals(400, response.getStatusLine().getStatusCode(), "Get a wrong status code.");
-
-        client.close();
+        try (CloseableHttpClient client = HttpClients.createDefault();
+             CloseableHttpResponse response = client.execute(get)) {
+            // just make sure we get the right
+            assertEquals(400, response.getCode(), "Get a wrong status code.");
+        }
     }
 
     protected void invokeHttpEndpoint() {
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyComponentMuteExceptionTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyComponentMuteExceptionTest.java
index 668a7dfbe04..7b28c201d62 100644
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyComponentMuteExceptionTest.java
+++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyComponentMuteExceptionTest.java
@@ -18,11 +18,11 @@ package org.apache.camel.component.jetty;
 
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.jetty11.JettyHttpComponent11;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.util.EntityUtils;
+import org.apache.hc.client5.http.classic.methods.HttpGet;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.classic.HttpClients;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -31,17 +31,16 @@ public class JettyComponentMuteExceptionTest extends BaseJettyTest {
 
     @Test
     public void testMuteException() throws Exception {
-        CloseableHttpClient client = HttpClients.createDefault();
-
         HttpGet get = new HttpGet("http://localhost:" + getPort() + "/foo");
         get.addHeader("Accept", "application/text");
-        HttpResponse response = client.execute(get);
 
-        String responseString = EntityUtils.toString(response.getEntity(), "UTF-8");
-        assertEquals("", responseString);
-        assertEquals(500, response.getStatusLine().getStatusCode());
+        try (CloseableHttpClient client = HttpClients.createDefault();
+             CloseableHttpResponse response = client.execute(get)) {
 
-        client.close();
+            String responseString = EntityUtils.toString(response.getEntity(), "UTF-8");
+            assertEquals("", responseString);
+            assertEquals(500, response.getCode());
+        }
     }
 
     @Override
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyEndpointSetHttpTraceTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyEndpointSetHttpTraceTest.java
index ffbcc9843b5..615535b8111 100644
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyEndpointSetHttpTraceTest.java
+++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyEndpointSetHttpTraceTest.java
@@ -18,10 +18,11 @@ package org.apache.camel.component.jetty;
 
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.test.AvailablePortFinder;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpTrace;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
+import org.apache.hc.client5.http.classic.methods.HttpTrace;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.classic.HttpClients;
+import org.apache.hc.core5.http.HttpResponse;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.RegisterExtension;
 
@@ -37,16 +38,16 @@ public class JettyEndpointSetHttpTraceTest extends BaseJettyTest {
 
     @Test
     public void testTraceDisabled() throws Exception {
-        CloseableHttpClient client = HttpClients.createDefault();
 
         HttpTrace trace = new HttpTrace("http://localhost:" + portTraceOff + "/myservice");
-        HttpResponse response = client.execute(trace);
 
-        // TRACE shouldn't be allowed by default
-        assertEquals(405, response.getStatusLine().getStatusCode());
-        trace.releaseConnection();
+        try (CloseableHttpClient client = HttpClients.createDefault();
+             CloseableHttpResponse response = client.execute(trace)) {
 
-        client.close();
+            // TRACE shouldn't be allowed by default
+            assertEquals(405, response.getCode());
+            trace.reset();
+        }
     }
 
     @Test
@@ -57,8 +58,8 @@ public class JettyEndpointSetHttpTraceTest extends BaseJettyTest {
         HttpResponse response = client.execute(trace);
 
         // TRACE is allowed
-        assertEquals(200, response.getStatusLine().getStatusCode());
-        trace.releaseConnection();
+        assertEquals(200, response.getCode());
+        trace.reset();
 
         client.close();
     }
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyHttpContentTypeTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyHttpContentTypeTest.java
index 80de48c8c86..677b29da8c9 100644
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyHttpContentTypeTest.java
+++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyHttpContentTypeTest.java
@@ -27,12 +27,12 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
 
 public class JettyHttpContentTypeTest extends BaseJettyTest {
 
-    private static final String CHARSET = "iso-8859-1";
+    private static final String CHARSET = "ISO-8859-1";
 
     @Test
     public void testContentType() throws Exception {
         getMockEndpoint("mock:input").expectedBodiesReceived("Hello World");
-        getMockEndpoint("mock:input").expectedHeaderReceived(Exchange.CONTENT_TYPE, "text/plain; charset=\"" + CHARSET + "\"");
+        getMockEndpoint("mock:input").expectedHeaderReceived(Exchange.CONTENT_TYPE, "text/plain; charset=" + CHARSET);
         getMockEndpoint("mock:input").expectedHeaderReceived(Exchange.HTTP_CHARACTER_ENCODING, CHARSET);
         getMockEndpoint("mock:input").expectedHeaderReceived(Exchange.HTTP_URL, "http://127.0.0.1:" + getPort() + "/foo");
         getMockEndpoint("mock:input").expectedPropertyReceived(Exchange.CHARSET_NAME, CHARSET);
@@ -49,10 +49,10 @@ public class JettyHttpContentTypeTest extends BaseJettyTest {
     public void testContentTypeWithAction() throws Exception {
         getMockEndpoint("mock:input").expectedBodiesReceived("Hello World");
         getMockEndpoint("mock:input").expectedHeaderReceived(Exchange.CONTENT_TYPE,
-                "text/plain;charset=\"" + CHARSET + "\";action=\"http://somewhere.com/foo\"");
-        getMockEndpoint("mock:input").expectedHeaderReceived(Exchange.HTTP_CHARACTER_ENCODING, CHARSET);
+                "text/plain; charset=" + CHARSET + "; action=\"http://somewhere.com/foo\"");
+        getMockEndpoint("mock:input").expectedHeaderReceived(Exchange.HTTP_CHARACTER_ENCODING, "iso-8859-1");
         getMockEndpoint("mock:input").expectedHeaderReceived(Exchange.HTTP_URL, "http://127.0.0.1:" + getPort() + "/foo");
-        getMockEndpoint("mock:input").expectedPropertyReceived(Exchange.CHARSET_NAME, CHARSET);
+        getMockEndpoint("mock:input").expectedPropertyReceived(Exchange.CHARSET_NAME, "iso-8859-1");
 
         byte[] data = "Hello World".getBytes(Charset.forName(CHARSET));
         String out = template.requestBodyAndHeader("http://127.0.0.1:{{port}}/foo", data, "content-type",
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyMuteExceptionTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyMuteExceptionTest.java
index d175029fd51..e92f294f884 100644
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyMuteExceptionTest.java
+++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyMuteExceptionTest.java
@@ -17,11 +17,11 @@
 package org.apache.camel.component.jetty;
 
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.util.EntityUtils;
+import org.apache.hc.client5.http.classic.methods.HttpGet;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.classic.HttpClients;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -30,17 +30,15 @@ public class JettyMuteExceptionTest extends BaseJettyTest {
 
     @Test
     public void testMuteException() throws Exception {
-        CloseableHttpClient client = HttpClients.createDefault();
-
         HttpGet get = new HttpGet("http://localhost:" + getPort() + "/foo");
         get.addHeader("Accept", "application/text");
-        HttpResponse response = client.execute(get);
-
-        String responseString = EntityUtils.toString(response.getEntity(), "UTF-8");
-        assertEquals("", responseString);
-        assertEquals(500, response.getStatusLine().getStatusCode());
+        try (CloseableHttpClient client = HttpClients.createDefault();
+             CloseableHttpResponse response = client.execute(get)) {
 
-        client.close();
+            String responseString = EntityUtils.toString(response.getEntity(), "UTF-8");
+            assertEquals("", responseString);
+            assertEquals(500, response.getCode());
+        }
     }
 
     @Override
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettySwitchingStatusCode204Test.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettySwitchingStatusCode204Test.java
index 6a08e63fbe7..d06218a7d35 100644
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettySwitchingStatusCode204Test.java
+++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettySwitchingStatusCode204Test.java
@@ -18,12 +18,12 @@ package org.apache.camel.component.jetty;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpUriRequest;
-import org.apache.http.impl.client.HttpClientBuilder;
-import org.apache.http.util.EntityUtils;
+import org.apache.hc.client5.http.classic.methods.HttpGet;
+import org.apache.hc.client5.http.classic.methods.HttpUriRequest;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.classic.HttpClients;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -35,11 +35,11 @@ public class JettySwitchingStatusCode204Test extends BaseJettyTest {
     @Test
     public void testSwitchNoBodyTo204ViaHttp() throws Exception {
         HttpUriRequest request = new HttpGet("http://localhost:" + getPort() + "/bar");
-        HttpClient httpClient = HttpClientBuilder.create().build();
-        HttpResponse httpResponse = httpClient.execute(request);
-
-        assertEquals(204, httpResponse.getStatusLine().getStatusCode());
-        assertNull(httpResponse.getEntity());
+        try (CloseableHttpClient httpClient = HttpClients.createDefault();
+             CloseableHttpResponse httpResponse = httpClient.execute(request)) {
+            assertEquals(204, httpResponse.getCode());
+            assertNull(httpResponse.getEntity());
+        }
     }
 
     @Test
@@ -48,7 +48,7 @@ public class JettySwitchingStatusCode204Test extends BaseJettyTest {
         Exchange outExchange = template.send("http://localhost:{{port}}/bar", inExchange);
 
         assertEquals(204, outExchange.getMessage().getHeader(Exchange.HTTP_RESPONSE_CODE));
-        assertEquals(null, outExchange.getMessage().getBody(String.class));
+        assertNull(outExchange.getMessage().getBody(String.class));
     }
 
     @Test
@@ -57,18 +57,18 @@ public class JettySwitchingStatusCode204Test extends BaseJettyTest {
         Exchange outExchange = template.send("direct:bar", inExchange);
 
         assertEquals(204, outExchange.getMessage().getHeader(Exchange.HTTP_RESPONSE_CODE));
-        assertEquals(null, outExchange.getMessage().getBody(String.class));
+        assertNull(outExchange.getMessage().getBody(String.class));
     }
 
     @Test
     public void testNoSwitchingNoCodeViaHttp() throws Exception {
         HttpUriRequest request = new HttpGet("http://localhost:" + getPort() + "/foo");
-        HttpClient httpClient = HttpClientBuilder.create().build();
-        HttpResponse httpResponse = httpClient.execute(request);
-
-        assertEquals(200, httpResponse.getStatusLine().getStatusCode());
-        assertNotNull(httpResponse.getEntity());
-        assertEquals("No Content", EntityUtils.toString(httpResponse.getEntity()));
+        try (CloseableHttpClient httpClient = HttpClients.createDefault();
+             CloseableHttpResponse httpResponse = httpClient.execute(request)) {
+            assertEquals(200, httpResponse.getCode());
+            assertNotNull(httpResponse.getEntity());
+            assertEquals("No Content", EntityUtils.toString(httpResponse.getEntity()));
+        }
     }
 
     @Test
@@ -92,12 +92,12 @@ public class JettySwitchingStatusCode204Test extends BaseJettyTest {
     @Test
     public void testNoSwitchingNoBodyViaHttp() throws Exception {
         HttpUriRequest request = new HttpGet("http://localhost:" + getPort() + "/foobar");
-        HttpClient httpClient = HttpClientBuilder.create().build();
-        HttpResponse httpResponse = httpClient.execute(request);
-
-        assertEquals(200, httpResponse.getStatusLine().getStatusCode());
-        assertNotNull(httpResponse.getEntity());
-        assertEquals("", EntityUtils.toString(httpResponse.getEntity()));
+        try (CloseableHttpClient httpClient = HttpClients.createDefault();
+             CloseableHttpResponse httpResponse = httpClient.execute(request)) {
+            assertEquals(200, httpResponse.getCode());
+            assertNotNull(httpResponse.getEntity());
+            assertEquals("", EntityUtils.toString(httpResponse.getEntity()));
+        }
     }
 
     @Test
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/MultiPartFormTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/MultiPartFormTest.java
index 9393cb70022..62a6f863692 100644
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/MultiPartFormTest.java
+++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/MultiPartFormTest.java
@@ -25,11 +25,12 @@ import org.apache.camel.Processor;
 import org.apache.camel.attachment.AttachmentMessage;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.util.IOHelper;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.mime.MultipartEntityBuilder;
-import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.hc.client5.http.classic.methods.HttpPost;
+import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.classic.HttpClients;
+import org.apache.hc.core5.http.HttpEntity;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -46,16 +47,17 @@ public class MultiPartFormTest extends BaseJettyTest {
 
     @Test
     public void testSendMultiPartForm() throws Exception {
-        org.apache.http.client.HttpClient client = HttpClientBuilder.create().build();
         HttpPost post = new HttpPost("http://localhost:" + getPort() + "/test");
         post.setEntity(createMultipartRequestEntity());
-        HttpResponse response = client.execute(post);
-        int status = response.getStatusLine().getStatusCode();
+        try (CloseableHttpClient client = HttpClients.createDefault();
+             CloseableHttpResponse response = client.execute(post)) {
+            int status = response.getCode();
 
-        assertEquals(200, status, "Get a wrong response status");
-        String result = IOHelper.loadText(response.getEntity().getContent()).trim();
+            assertEquals(200, status, "Get a wrong response status");
+            String result = IOHelper.loadText(response.getEntity().getContent()).trim();
 
-        assertEquals("A binary file of some kind", result, "Get a wrong result");
+            assertEquals("A binary file of some kind", result, "Get a wrong result");
+        }
     }
 
     @Test
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/MultiPartFormWithCustomFilterTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/MultiPartFormWithCustomFilterTest.java
index 8041c26d9f7..a021265e272 100644
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/MultiPartFormWithCustomFilterTest.java
+++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/MultiPartFormWithCustomFilterTest.java
@@ -31,13 +31,13 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.attachment.AttachmentMessage;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.mime.MultipartEntityBuilder;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.util.EntityUtils;
+import org.apache.hc.client5.http.classic.methods.HttpPost;
+import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.classic.HttpClients;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -62,7 +62,6 @@ public class MultiPartFormWithCustomFilterTest extends BaseJettyTest {
 
     @Test
     public void testSendMultiPartForm() throws Exception {
-        CloseableHttpClient client = HttpClients.createDefault();
 
         File file = new File("src/test/resources/log4j2.properties");
         HttpPost httppost = new HttpPost("http://localhost:" + getPort() + "/test");
@@ -71,19 +70,19 @@ public class MultiPartFormWithCustomFilterTest extends BaseJettyTest {
                 .addBinaryBody(file.getName(), file).build();
         httppost.setEntity(entity);
 
-        HttpResponse response = client.execute(httppost);
-        assertEquals(200, response.getStatusLine().getStatusCode(), "Get a wrong response status");
-        String responseString = EntityUtils.toString(response.getEntity(), "UTF-8");
+        try (CloseableHttpClient client = HttpClients.createDefault();
+             CloseableHttpResponse response = client.execute(httppost)) {
+            assertEquals(200, response.getCode(), "Get a wrong response status");
+            String responseString = EntityUtils.toString(response.getEntity(), "UTF-8");
 
-        assertEquals("A binary file of some kind", responseString, "Get a wrong result");
-        assertNotNull(response.getFirstHeader("MyMultipartFilter").getValue(), "Did not use custom multipart filter");
+            assertEquals("A binary file of some kind", responseString, "Get a wrong result");
+            assertNotNull(response.getFirstHeader("MyMultipartFilter").getValue(), "Did not use custom multipart filter");
 
-        client.close();
+        }
     }
 
     @Test
     public void testSendMultiPartFormOverrideEnableMultpartFilterFalse() throws Exception {
-        CloseableHttpClient client = HttpClients.createDefault();
 
         File file = new File("src/test/resources/log4j2.properties");
 
@@ -92,10 +91,12 @@ public class MultiPartFormWithCustomFilterTest extends BaseJettyTest {
                 .addBinaryBody(file.getName(), file).build();
         httppost.setEntity(entity);
 
-        HttpResponse response = client.execute(httppost);
+        try (CloseableHttpClient client = HttpClients.createDefault();
+             CloseableHttpResponse response = client.execute(httppost)) {
 
-        assertEquals(200, response.getStatusLine().getStatusCode(), "Get a wrong response status");
-        assertNotNull(response.getFirstHeader("MyMultipartFilter").getValue(), "Did not use custom multipart filter");
+            assertEquals(200, response.getCode(), "Get a wrong response status");
+            assertNotNull(response.getFirstHeader("MyMultipartFilter").getValue(), "Did not use custom multipart filter");
+        }
     }
 
     @Override
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/MultiThreadedHttpGetTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/MultiThreadedHttpGetTest.java
index 7dadee6f2ba..501b6ae1a3f 100644
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/MultiThreadedHttpGetTest.java
+++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/MultiThreadedHttpGetTest.java
@@ -24,7 +24,7 @@ import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.http.HttpComponent;
 import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
+import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager;
 import org.junit.jupiter.api.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -105,10 +105,12 @@ public class MultiThreadedHttpGetTest extends BaseJettyTest {
     protected RouteBuilder createRouteBuilder() {
         return new RouteBuilder() {
             public void configure() {
-                from("seda:withConversion?concurrentConsumers=5").to("http://localhost:{{port}}/search")
+                from("seda:withConversion?concurrentConsumers=5")
+                        .to("http://localhost:{{port}}/search")
                         .convertBodyTo(String.class).to("mock:results");
 
-                from("seda:withoutConversion?concurrentConsumers=5").to("http://localhost:{{port}}/search").to("mock:results");
+                from("seda:withoutConversion?concurrentConsumers=5")
+                        .to("http://localhost:{{port}}/search").to("mock:results");
 
                 from("jetty:http://localhost:{{port}}/search").process(new Processor() {
                     public void process(Exchange exchange) {
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/SpringHttpsRouteTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/SpringHttpsRouteTest.java
index f02fffbe091..c0b82af32c5 100644
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/SpringHttpsRouteTest.java
+++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/SpringHttpsRouteTest.java
@@ -68,7 +68,7 @@ public class SpringHttpsRouteTest {
 
     @BeforeEach
     public void setUp() {
-        // ensure jsse clients can validate the self signed dummy localhost
+        // ensure jsse clients can validate the self-signed dummy localhost
         // cert,
         // use the server keystore as the trust store for these tests
         URL trustStoreUrl = Thread.currentThread().getContextClassLoader().getResource("jsse/localhost.p12");


[camel] 03/15: CAMEL-18995: camel-undertow - Upgrade to HttpComponents 5.x

Posted by nf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

nfilotto pushed a commit to branch CAMEL-18995/upgrade-httpcomponents-5
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 9b53322769e8882f330ab453f148bc02c36644a2
Author: Nicolas Filotto <nf...@talend.com>
AuthorDate: Fri Mar 17 12:25:45 2023 +0100

    CAMEL-18995: camel-undertow - Upgrade to HttpComponents 5.x
---
 components/camel-undertow/pom.xml                  |  6 ---
 .../component/undertow/MultiPartFormTest.java      | 26 +++++++------
 .../UndertowComponentMuteExceptionTest.java        | 43 ++++++++++-----------
 .../undertow/UndertowMethodRestricTest.java        | 39 +++++++++----------
 .../undertow/UndertowMuteExceptionTest.java        | 44 ++++++++++-----------
 .../undertow/UndertowSwitchingStatus204Test.java   | 45 ++++++++++++----------
 .../undertow/UndertowTransferExceptionTest.java    | 25 ++++++------
 7 files changed, 108 insertions(+), 120 deletions(-)

diff --git a/components/camel-undertow/pom.xml b/components/camel-undertow/pom.xml
index 4005eadd8c1..bed907f351d 100644
--- a/components/camel-undertow/pom.xml
+++ b/components/camel-undertow/pom.xml
@@ -137,12 +137,6 @@
             <artifactId>junit-jupiter</artifactId>
             <scope>test</scope>
         </dependency>
-        <dependency>
-            <groupId>org.apache.httpcomponents</groupId>
-            <artifactId>httpmime</artifactId>
-            <version>${httpclient4-version}</version>
-            <scope>test</scope>
-        </dependency>
         <dependency>
             <groupId>org.eclipse.jetty.http2</groupId>
             <artifactId>http2-client</artifactId>
diff --git a/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/MultiPartFormTest.java b/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/MultiPartFormTest.java
index fcb9593b279..751370d6ddd 100644
--- a/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/MultiPartFormTest.java
+++ b/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/MultiPartFormTest.java
@@ -24,11 +24,12 @@ import jakarta.activation.DataHandler;
 import org.apache.camel.attachment.AttachmentMessage;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.util.IOHelper;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.mime.MultipartEntityBuilder;
-import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.hc.client5.http.classic.methods.HttpPost;
+import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.classic.HttpClients;
+import org.apache.hc.core5.http.HttpEntity;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -47,20 +48,21 @@ public class MultiPartFormTest extends BaseUndertowTest {
 
     @Test
     public void testSendMultiPartForm() throws Exception {
-        org.apache.http.client.HttpClient client = HttpClientBuilder.create().build();
         HttpPost post = new HttpPost("http://localhost:" + getPort() + "/test");
         post.setEntity(createMultipartRequestEntity());
-        HttpResponse response = client.execute(post);
-        int status = response.getStatusLine().getStatusCode();
+        try (CloseableHttpClient httpClient = HttpClients.createDefault();
+             CloseableHttpResponse response = httpClient.execute(post)) {
+            int status = response.getCode();
 
-        assertEquals(200, status, "Get a wrong response status");
-        String result = IOHelper.loadText(response.getEntity().getContent()).trim();
+            assertEquals(200, status, "Get a wrong response status");
+            String result = IOHelper.loadText(response.getEntity().getContent()).trim();
 
-        assertEquals("A binary file of some kind", result, "Get a wrong result");
+            assertEquals("A binary file of some kind", result, "Get a wrong result");
+        }
     }
 
     @Test
-    public void testSendMultiPartFormFromCamelHttpComponnent() {
+    public void testSendMultiPartFormFromCamelHttpComponent() {
         String result
                 = template.requestBody("http://localhost:" + getPort() + "/test", createMultipartRequestEntity(), String.class);
         assertEquals("A binary file of some kind", result, "Get a wrong result");
diff --git a/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/UndertowComponentMuteExceptionTest.java b/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/UndertowComponentMuteExceptionTest.java
index adf88c63b62..e499a48df92 100644
--- a/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/UndertowComponentMuteExceptionTest.java
+++ b/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/UndertowComponentMuteExceptionTest.java
@@ -17,11 +17,11 @@
 package org.apache.camel.component.undertow;
 
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.util.EntityUtils;
+import org.apache.hc.client5.http.classic.methods.HttpGet;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.classic.HttpClients;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -31,36 +31,33 @@ public class UndertowComponentMuteExceptionTest extends BaseUndertowTest {
 
     @Test
     public void muteExceptionTest() throws Exception {
-        CloseableHttpClient client = HttpClients.createDefault();
-
         HttpGet get = new HttpGet("http://localhost:" + getPort() + "/test/mute");
         get.addHeader("Accept", "application/text");
-        HttpResponse response = client.execute(get);
-
-        String responseString = EntityUtils.toString(response.getEntity(), "UTF-8");
-        assertNotNull(responseString);
-        assertEquals("", responseString);
-        assertEquals(500, response.getStatusLine().getStatusCode());
-
-        client.close();
+        try (CloseableHttpClient httpClient = HttpClients.createDefault();
+             CloseableHttpResponse response = httpClient.execute(get)) {
+
+            String responseString = EntityUtils.toString(response.getEntity(), "UTF-8");
+            assertNotNull(responseString);
+            assertEquals("", responseString);
+            assertEquals(500, response.getCode());
+        }
     }
 
     @Test
     public void muteExceptionWithTransferExceptionTest() throws Exception {
-        CloseableHttpClient client = HttpClients.createDefault();
 
         HttpGet get = new HttpGet("http://localhost:" + getPort() + "/test/muteWithTransfer");
         get.addHeader("Accept", "application/text");
 
-        HttpResponse response = client.execute(get);
-
-        String responseString = EntityUtils.toString(response.getEntity(), "UTF-8");
-        assertNotNull(responseString);
-        assertEquals("", responseString);
+        try (CloseableHttpClient httpClient = HttpClients.createDefault();
+             CloseableHttpResponse response = httpClient.execute(get)) {
 
-        assertEquals(500, response.getStatusLine().getStatusCode());
+            String responseString = EntityUtils.toString(response.getEntity(), "UTF-8");
+            assertNotNull(responseString);
+            assertEquals("", responseString);
 
-        client.close();
+            assertEquals(500, response.getCode());
+        }
     }
 
     @Override
diff --git a/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/UndertowMethodRestricTest.java b/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/UndertowMethodRestricTest.java
index b2aceae041d..bccbd4ae01d 100644
--- a/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/UndertowMethodRestricTest.java
+++ b/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/UndertowMethodRestricTest.java
@@ -18,13 +18,13 @@ package org.apache.camel.component.undertow;
 
 import org.apache.camel.Message;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.util.EntityUtils;
+import org.apache.hc.client5.http.classic.methods.HttpGet;
+import org.apache.hc.client5.http.classic.methods.HttpPost;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.classic.HttpClients;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
+import org.apache.hc.core5.http.io.entity.StringEntity;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
 
@@ -41,31 +41,28 @@ public class UndertowMethodRestricTest extends BaseUndertowTest {
 
     @Test
     public void testProperHttpMethod() throws Exception {
-        CloseableHttpClient client = HttpClients.createDefault();
-
         HttpPost httpPost = new HttpPost(url);
         httpPost.setEntity(new StringEntity("This is a test"));
 
-        HttpResponse response = client.execute(httpPost);
-
-        assertEquals(200, response.getStatusLine().getStatusCode());
-        String responseString = EntityUtils.toString(response.getEntity(), "UTF-8");
-        assertEquals("This is a test response", responseString);
+        try (CloseableHttpClient httpClient = HttpClients.createDefault();
+             CloseableHttpResponse response = httpClient.execute(httpPost)) {
 
-        client.close();
+            assertEquals(200, response.getCode());
+            String responseString = EntityUtils.toString(response.getEntity(), "UTF-8");
+            assertEquals("This is a test response", responseString);
+        }
     }
 
     @Test
     public void testImproperHttpMethod() throws Exception {
-        CloseableHttpClient client = HttpClients.createDefault();
-
         HttpGet httpGet = new HttpGet(url);
-        HttpResponse response = client.execute(httpGet);
-        int status = response.getStatusLine().getStatusCode();
 
-        assertEquals(405, status, "Get a wrong response status");
+        try (CloseableHttpClient httpClient = HttpClients.createDefault();
+             CloseableHttpResponse response = httpClient.execute(httpGet)) {
+            int status = response.getCode();
 
-        client.close();
+            assertEquals(405, status, "Get a wrong response status");
+        }
     }
 
     @Override
diff --git a/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/UndertowMuteExceptionTest.java b/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/UndertowMuteExceptionTest.java
index e244fa70026..3911365c13e 100644
--- a/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/UndertowMuteExceptionTest.java
+++ b/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/UndertowMuteExceptionTest.java
@@ -17,11 +17,11 @@
 package org.apache.camel.component.undertow;
 
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.util.EntityUtils;
+import org.apache.hc.client5.http.classic.methods.HttpGet;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.classic.HttpClients;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -31,36 +31,32 @@ public class UndertowMuteExceptionTest extends BaseUndertowTest {
 
     @Test
     public void muteExceptionTest() throws Exception {
-        CloseableHttpClient client = HttpClients.createDefault();
-
         HttpGet get = new HttpGet("http://localhost:" + getPort() + "/test/mute");
         get.addHeader("Accept", "application/text");
-        HttpResponse response = client.execute(get);
-
-        String responseString = EntityUtils.toString(response.getEntity(), "UTF-8");
-        assertNotNull(responseString);
-        assertEquals("", responseString);
-        assertEquals(500, response.getStatusLine().getStatusCode());
-
-        client.close();
+        try (CloseableHttpClient httpClient = HttpClients.createDefault();
+             CloseableHttpResponse response = httpClient.execute(get)) {
+
+            String responseString = EntityUtils.toString(response.getEntity(), "UTF-8");
+            assertNotNull(responseString);
+            assertEquals("", responseString);
+            assertEquals(500, response.getCode());
+        }
     }
 
     @Test
     public void muteExceptionWithTransferExceptionTest() throws Exception {
-        CloseableHttpClient client = HttpClients.createDefault();
-
         HttpGet get = new HttpGet("http://localhost:" + getPort() + "/test/muteWithTransfer");
         get.addHeader("Accept", "application/text");
 
-        HttpResponse response = client.execute(get);
-
-        String responseString = EntityUtils.toString(response.getEntity(), "UTF-8");
-        assertNotNull(responseString);
-        assertEquals("", responseString);
+        try (CloseableHttpClient httpClient = HttpClients.createDefault();
+             CloseableHttpResponse response = httpClient.execute(get)) {
 
-        assertEquals(500, response.getStatusLine().getStatusCode());
+            String responseString = EntityUtils.toString(response.getEntity(), "UTF-8");
+            assertNotNull(responseString);
+            assertEquals("", responseString);
 
-        client.close();
+            assertEquals(500, response.getCode());
+        }
     }
 
     @Override
diff --git a/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/UndertowSwitchingStatus204Test.java b/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/UndertowSwitchingStatus204Test.java
index 9d7617de4cf..65ff92b4cbb 100644
--- a/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/UndertowSwitchingStatus204Test.java
+++ b/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/UndertowSwitchingStatus204Test.java
@@ -19,12 +19,12 @@ package org.apache.camel.component.undertow;
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpUriRequest;
-import org.apache.http.impl.client.HttpClientBuilder;
-import org.apache.http.util.EntityUtils;
+import org.apache.hc.client5.http.classic.methods.HttpGet;
+import org.apache.hc.client5.http.classic.methods.HttpUriRequest;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.classic.HttpClients;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -35,12 +35,13 @@ public class UndertowSwitchingStatus204Test extends BaseUndertowTest {
 
     @Test
     public void testSwitchNoBodyTo204ViaHttpEmptyBody() throws Exception {
-        HttpUriRequest request = new HttpGet("http://localhost:" + getPort() + "/foo");
-        HttpClient httpClient = HttpClientBuilder.create().build();
-        HttpResponse httpResponse = httpClient.execute(request);
+        HttpGet request = new HttpGet("http://localhost:" + getPort() + "/foo");
+        try (CloseableHttpClient httpClient = HttpClients.createDefault();
+             CloseableHttpResponse httpResponse = httpClient.execute(request)) {
 
-        assertEquals(204, httpResponse.getStatusLine().getStatusCode());
-        assertNull(httpResponse.getEntity());
+            assertEquals(204, httpResponse.getCode());
+            assertNull(httpResponse.getEntity());
+        }
     }
 
     @Test
@@ -66,12 +67,13 @@ public class UndertowSwitchingStatus204Test extends BaseUndertowTest {
     @Test
     public void testNoSwitchingHasBodyViaHttpNoContent() throws Exception {
         HttpUriRequest request = new HttpGet("http://localhost:" + getPort() + "/bar");
-        HttpClient httpClient = HttpClientBuilder.create().build();
-        HttpResponse httpResponse = httpClient.execute(request);
+        try (CloseableHttpClient httpClient = HttpClients.createDefault();
+             CloseableHttpResponse httpResponse = httpClient.execute(request)) {
 
-        assertEquals(200, httpResponse.getStatusLine().getStatusCode());
-        assertNotNull(httpResponse.getEntity());
-        assertEquals("No Content", EntityUtils.toString(httpResponse.getEntity()));
+            assertEquals(200, httpResponse.getCode());
+            assertNotNull(httpResponse.getEntity());
+            assertEquals("No Content", EntityUtils.toString(httpResponse.getEntity()));
+        }
     }
 
     @Test
@@ -97,12 +99,13 @@ public class UndertowSwitchingStatus204Test extends BaseUndertowTest {
     @Test
     public void testNoSwitchingHasCodeViaHttpNoContent() throws Exception {
         HttpUriRequest request = new HttpGet("http://localhost:" + getPort() + "/foobar");
-        HttpClient httpClient = HttpClientBuilder.create().build();
-        HttpResponse httpResponse = httpClient.execute(request);
+        try (CloseableHttpClient httpClient = HttpClients.createDefault();
+             CloseableHttpResponse httpResponse = httpClient.execute(request)) {
 
-        assertEquals(200, httpResponse.getStatusLine().getStatusCode());
-        assertNotNull(httpResponse.getEntity());
-        assertEquals("", EntityUtils.toString(httpResponse.getEntity()));
+            assertEquals(200, httpResponse.getCode());
+            assertNotNull(httpResponse.getEntity());
+            assertEquals("", EntityUtils.toString(httpResponse.getEntity()));
+        }
     }
 
     @Test
diff --git a/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/UndertowTransferExceptionTest.java b/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/UndertowTransferExceptionTest.java
index 97dda423b86..4ce054564d0 100644
--- a/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/UndertowTransferExceptionTest.java
+++ b/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/UndertowTransferExceptionTest.java
@@ -20,10 +20,10 @@ import java.io.IOException;
 import java.io.ObjectInputStream;
 
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
+import org.apache.hc.client5.http.classic.methods.HttpGet;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.classic.HttpClients;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -33,19 +33,18 @@ public class UndertowTransferExceptionTest extends BaseUndertowTest {
 
     @Test
     public void getSerializedExceptionTest() throws IOException, ClassNotFoundException {
-        CloseableHttpClient client = HttpClients.createDefault();
         HttpGet get = new HttpGet("http://localhost:" + getPort() + "/test/transfer");
         get.addHeader("Accept", "application/x-java-serialized-object");
 
-        HttpResponse response = client.execute(get);
+        try (CloseableHttpClient httpClient = HttpClients.createDefault();
+             CloseableHttpResponse response = httpClient.execute(get)) {
 
-        ObjectInputStream in = new ObjectInputStream(response.getEntity().getContent());
-        IllegalArgumentException e = (IllegalArgumentException) in.readObject();
-        assertNotNull(e);
-        assertEquals(500, response.getStatusLine().getStatusCode());
-        assertEquals("Camel cannot do this", e.getMessage());
-
-        client.close();
+            ObjectInputStream in = new ObjectInputStream(response.getEntity().getContent());
+            IllegalArgumentException e = (IllegalArgumentException) in.readObject();
+            assertNotNull(e);
+            assertEquals(500, response.getCode());
+            assertEquals("Camel cannot do this", e.getMessage());
+        }
     }
 
     @Override


[camel] 10/15: CAMEL-18995: camel-wordpress - Upgrade to HttpComponents 5.x

Posted by nf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

nfilotto pushed a commit to branch CAMEL-18995/upgrade-httpcomponents-5
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 8c12bd6e62e1a8b83ddc175c58b89434f0542aa7
Author: Nicolas Filotto <nf...@talend.com>
AuthorDate: Fri Mar 17 12:33:01 2023 +0100

    CAMEL-18995: camel-wordpress - Upgrade to HttpComponents 5.x
---
 components/camel-wordpress/pom.xml                 |  6 ++--
 .../api/test/WordpressMockServerTestSupport.java   | 14 ++++-----
 .../test/WordpressServerHttpRequestHandler.java    | 34 ++++++++++------------
 3 files changed, 26 insertions(+), 28 deletions(-)

diff --git a/components/camel-wordpress/pom.xml b/components/camel-wordpress/pom.xml
index db67fa6164a..7af1f8bd3fb 100644
--- a/components/camel-wordpress/pom.xml
+++ b/components/camel-wordpress/pom.xml
@@ -55,9 +55,9 @@
             <scope>test</scope>
         </dependency>
         <dependency>
-            <groupId>org.apache.httpcomponents</groupId>
-            <artifactId>httpclient</artifactId>
-            <version>${httpclient4-version}</version>
+            <groupId>org.apache.httpcomponents.client5</groupId>
+            <artifactId>httpclient5</artifactId>
+            <version>${httpclient-version}</version>
             <scope>test</scope>
         </dependency>
 
diff --git a/components/camel-wordpress/src/test/java/org/apache/camel/component/wordpress/api/test/WordpressMockServerTestSupport.java b/components/camel-wordpress/src/test/java/org/apache/camel/component/wordpress/api/test/WordpressMockServerTestSupport.java
index 4f0020fea02..ea455da3a5c 100644
--- a/components/camel-wordpress/src/test/java/org/apache/camel/component/wordpress/api/test/WordpressMockServerTestSupport.java
+++ b/components/camel-wordpress/src/test/java/org/apache/camel/component/wordpress/api/test/WordpressMockServerTestSupport.java
@@ -22,8 +22,8 @@ import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.camel.component.wordpress.api.WordpressServiceProvider;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
 import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.BeforeAll;
 import org.slf4j.Logger;
@@ -84,10 +84,10 @@ public abstract class WordpressMockServerTestSupport {
 
         // @formatter:off
         return ServerBootstrap.bootstrap().setListenerPort(port)
-                .registerHandler("/wp/v2/posts", new WordpressServerHttpRequestHandler(postsListCreateRequestHandlers))
-                .registerHandler("/wp/v2/posts/*", new WordpressServerHttpRequestHandler(postsSingleUpdateRequestHandlers))
-                .registerHandler("/wp/v2/users", new WordpressServerHttpRequestHandler(usersListCreateRequestHandlers))
-                .registerHandler("/wp/v2/users/*", new WordpressServerHttpRequestHandler(usersSingleUpdateRequestHandlers))
+                .register("/wp/v2/posts", new WordpressServerHttpRequestHandler(postsListCreateRequestHandlers))
+                .register("/wp/v2/posts/*", new WordpressServerHttpRequestHandler(postsSingleUpdateRequestHandlers))
+                .register("/wp/v2/users", new WordpressServerHttpRequestHandler(usersListCreateRequestHandlers))
+                .register("/wp/v2/users/*", new WordpressServerHttpRequestHandler(usersSingleUpdateRequestHandlers))
                 .create();
         // @formatter:on
     }
@@ -105,6 +105,6 @@ public abstract class WordpressMockServerTestSupport {
     }
 
     public static String getServerBaseUrl() {
-        return "http://" + localServer.getInetAddress().getHostName() + ":" + localServer.getLocalPort();
+        return "http://localhost:" + localServer.getLocalPort();
     }
 }
diff --git a/components/camel-wordpress/src/test/java/org/apache/camel/component/wordpress/api/test/WordpressServerHttpRequestHandler.java b/components/camel-wordpress/src/test/java/org/apache/camel/component/wordpress/api/test/WordpressServerHttpRequestHandler.java
index f9d65551784..9cb834cd42c 100644
--- a/components/camel-wordpress/src/test/java/org/apache/camel/component/wordpress/api/test/WordpressServerHttpRequestHandler.java
+++ b/components/camel-wordpress/src/test/java/org/apache/camel/component/wordpress/api/test/WordpressServerHttpRequestHandler.java
@@ -17,21 +17,21 @@
 package org.apache.camel.component.wordpress.api.test;
 
 import java.io.IOException;
-import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 import java.util.Base64;
 import java.util.Collections;
 import java.util.Map;
 
 import org.apache.cxf.helpers.IOUtils;
-import org.apache.http.Header;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.client.methods.HttpRequestWrapper;
-import org.apache.http.entity.ContentType;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.protocol.HttpRequestHandler;
+import org.apache.hc.core5.http.ClassicHttpRequest;
+import org.apache.hc.core5.http.ClassicHttpResponse;
+import org.apache.hc.core5.http.ContentType;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.io.HttpRequestHandler;
+import org.apache.hc.core5.http.io.entity.StringEntity;
+import org.apache.hc.core5.http.message.HttpRequestWrapper;
+import org.apache.hc.core5.http.protocol.HttpContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -53,21 +53,19 @@ public class WordpressServerHttpRequestHandler implements HttpRequestHandler {
     }
 
     @Override
-    public void handle(HttpRequest request, HttpResponse response, HttpContext context) throws IOException {
+    public void handle(ClassicHttpRequest request, ClassicHttpResponse response, HttpContext context)
+            throws IOException {
         LOGGER.debug("received request {}", request);
-        final HttpRequestWrapper requestWrapper = HttpRequestWrapper.wrap(request);
+        final HttpRequestWrapper requestWrapper = new HttpRequestWrapper(request);
         // make sure that our writing operations have authentication header
         if (!authenticate(requestWrapper)) {
-            response.setStatusCode(HttpStatus.SC_FORBIDDEN);
+            response.setCode(HttpStatus.SC_FORBIDDEN);
             response.setEntity(new StringEntity("Forbidden", ContentType.TEXT_PLAIN));
             return;
         }
         final String responseBody = IOUtils
                 .toString(this.getClass().getResourceAsStream(mockResourceJsonResponse.get(requestWrapper.getMethod())));
-        if (responseBody == null) {
-            LOGGER.warn("Resource not found on {}. Response body null.", mockResourceJsonResponse);
-        }
-        response.setStatusCode(HttpStatus.SC_OK);
+        response.setCode(HttpStatus.SC_OK);
         response.setEntity(new StringEntity(responseBody, ContentType.APPLICATION_JSON));
     }
 
@@ -79,7 +77,7 @@ public class WordpressServerHttpRequestHandler implements HttpRequestHandler {
         for (Header authorizationHeader : request.getHeaders("Authorization")) {
             // Authorization: Basic base64credentials
             String base64Credentials = authorizationHeader.getValue().substring("Basic".length()).trim();
-            String credentials = new String(Base64.getDecoder().decode(base64Credentials), Charset.forName("UTF-8"));
+            String credentials = new String(Base64.getDecoder().decode(base64Credentials), StandardCharsets.UTF_8);
             // credentials = username:password
             final String[] values = credentials.split(":", 2);
             return USERNAME.equals(values[0]) && PASSWORD.equals(values[1]);


[camel] 05/15: CAMEL-18995: camel-geocoder - Upgrade to HttpComponents 5.x

Posted by nf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

nfilotto pushed a commit to branch CAMEL-18995/upgrade-httpcomponents-5
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 09354ae1fcc8b261b538d42fde0c1f3f5043e777
Author: Nicolas Filotto <nf...@talend.com>
AuthorDate: Fri Mar 17 12:27:57 2023 +0100

    CAMEL-18995: camel-geocoder - Upgrade to HttpComponents 5.x
---
 components/camel-geocoder/pom.xml                  |  6 ++---
 .../geocoder/GeoCoderNominatimProducer.java        | 29 +++++++++++-----------
 2 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/components/camel-geocoder/pom.xml b/components/camel-geocoder/pom.xml
index fff08e2d076..98bf0d2e343 100644
--- a/components/camel-geocoder/pom.xml
+++ b/components/camel-geocoder/pom.xml
@@ -56,9 +56,9 @@
         </dependency>
 
         <dependency>
-            <groupId>org.apache.httpcomponents</groupId>
-            <artifactId>httpclient</artifactId>
-            <version>${httpclient4-version}</version>
+            <groupId>org.apache.httpcomponents.client5</groupId>
+            <artifactId>httpclient5</artifactId>
+            <version>${httpclient-version}</version>
         </dependency>
 
         <!-- testing -->
diff --git a/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeoCoderNominatimProducer.java b/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeoCoderNominatimProducer.java
index bcbcd7353f8..7194b3f66bd 100644
--- a/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeoCoderNominatimProducer.java
+++ b/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeoCoderNominatimProducer.java
@@ -29,11 +29,10 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.apache.camel.support.DefaultProducer;
 import org.apache.camel.util.StringHelper;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.RequestBuilder;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.util.EntityUtils;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.HttpClients;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
+import org.apache.hc.core5.http.io.support.ClassicRequestBuilder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -43,13 +42,19 @@ import org.slf4j.LoggerFactory;
 public class GeoCoderNominatimProducer extends DefaultProducer {
     private static final Logger LOG = LoggerFactory.getLogger(GeoCoderNominatimProducer.class);
 
-    private GeoCoderEndpoint endpoint;
+    private final GeoCoderEndpoint endpoint;
+    private final CloseableHttpClient httpClient = HttpClients.createDefault();
 
     public GeoCoderNominatimProducer(GeoCoderEndpoint endpoint) {
         super(endpoint);
         this.endpoint = endpoint;
     }
 
+    @Override
+    protected void doStop() throws Exception {
+        httpClient.close();
+    }
+
     @Override
     public void process(Exchange exchange) throws Exception {
         // headers take precedence
@@ -83,7 +88,7 @@ public class GeoCoderNominatimProducer extends DefaultProducer {
 
     private String query(String dlat, String dlon) throws IOException {
 
-        Map<String, String> params = new HashMap<String, String>();
+        Map<String, String> params = new HashMap<>();
         params.put("format", "jsonv2");
         params.put("lat", dlat);
         params.put("lon", dlon);
@@ -92,7 +97,7 @@ public class GeoCoderNominatimProducer extends DefaultProducer {
     }
 
     private String query(String address) throws IOException {
-        Map<String, String> params = new HashMap<String, String>();
+        Map<String, String> params = new HashMap<>();
         params.put("format", "jsonv2");
         params.put("addressdetails", "1");
         params.put("q", address);
@@ -108,17 +113,13 @@ public class GeoCoderNominatimProducer extends DefaultProducer {
         }
         url += operation;
 
-        final RequestBuilder builder = RequestBuilder.get().setUri(url);
+        final ClassicRequestBuilder builder = ClassicRequestBuilder.get().setUri(url);
 
         for (Map.Entry<String, String> entry : params.entrySet()) {
             builder.addParameter(entry.getKey(), entry.getValue());
         }
 
-        try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
-            try (CloseableHttpResponse resp = httpClient.execute(builder.build())) {
-                return EntityUtils.toString(resp.getEntity());
-            }
-        }
+        return httpClient.execute(builder.build(), resp -> EntityUtils.toString(resp.getEntity()));
     }
 
     protected void extractResult(String place, Exchange exchange) {


[camel] 01/15: CAMEL-18995: camel-http - Upgrade to HttpComponents 5.x

Posted by nf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

nfilotto pushed a commit to branch CAMEL-18995/upgrade-httpcomponents-5
in repository https://gitbox.apache.org/repos/asf/camel.git

commit f03ca71e289b0eb2a327b1028affbd65ebc90ee9
Author: Nicolas Filotto <nf...@talend.com>
AuthorDate: Fri Mar 17 12:23:17 2023 +0100

    CAMEL-18995: camel-http - Upgrade to HttpComponents 5.x
---
 components/camel-http/pom.xml                      |  12 +-
 .../component/http/HttpComponentConfigurer.java    |  36 ++-
 ...verterLoader.java => HttpConvertersLoader.java} |  18 +-
 .../component/http/HttpEndpointConfigurer.java     |  28 +-
 .../component/http/HttpEndpointUriFactory.java     |   6 +-
 .../component/http/HttpEntityConverterLoader.java  |   6 +-
 ...Loader.java => HttpTimeoutConverterLoader.java} |  18 +-
 .../services/org/apache/camel/TypeConverterLoader  |   1 +
 .../org/apache/camel/component/http/http.json      |  27 +-
 .../org/apache/camel/component/http/https.json     |  27 +-
 .../camel-http/src/main/docs/http-component.adoc   |   4 +-
 .../BasicAuthenticationHttpClientConfigurer.java   |  12 +-
 .../component/http/CompositeHttpConfigurer.java    |  12 +-
 .../camel/component/http/HttpClientConfigurer.java |   2 +-
 .../apache/camel/component/http/HttpComponent.java | 223 +++++++++-----
 .../http/HttpComponentVerifierExtension.java       |  95 +++---
 .../apache/camel/component/http/HttpConstants.java |   4 +-
 ...leteWithBodyMethod.java => HttpConverters.java} |  38 ++-
 .../component/http/HttpCredentialsHelper.java      |  13 +-
 .../apache/camel/component/http/HttpEndpoint.java  | 180 ++++++-----
 .../camel/component/http/HttpEntityConverter.java  |  60 ++--
 .../apache/camel/component/http/HttpMethods.java   | 103 +++----
 .../camel/component/http/HttpPollingConsumer.java  |  99 ++++---
 .../apache/camel/component/http/HttpProducer.java  | 330 ++++++++++++---------
 .../org/apache/camel/component/http/HttpUtil.java  |   4 +-
 .../camel/component/http/NoopCookieStore.java      |   4 +-
 .../http/PreemptiveAuthExecChainHandler.java       |  62 ++++
 .../component/http/PreemptiveAuthInterceptor.java  |  51 ----
 .../component/http/ProxyHttpClientConfigurer.java  |  16 +-
 .../apache/camel/component/http/BaseHttpTest.java  |  12 +-
 .../apache/camel/component/http/BaseHttpsTest.java |   9 +-
 .../http/CamelComponentVerifierExtensionTest.java  |  34 +--
 .../component/http/CamelComponentVerifierTest.java |  34 +--
 .../camel/component/http/FollowRedirectTest.java   |  18 +-
 .../camel/component/http/HeaderFilteringTest.java  |   4 +-
 .../component/http/HttpAuthenticationTest.java     |  40 +--
 .../apache/camel/component/http/HttpBodyTest.java  |  18 +-
 ...java => HttpBodyWithOtherProtocolNameTest.java} |   4 +-
 .../component/http/HttpBridgeEndpointTest.java     |  12 +-
 .../http/HttpCamelHeadersNotCopiedTest.java        |   2 +-
 .../camel/component/http/HttpCamelHeadersTest.java |  34 +--
 .../camel/component/http/HttpCharsetTest.java      |  16 +-
 .../camel/component/http/HttpCompressionTest.java  |  80 ++---
 .../camel/component/http/HttpConcurrentTest.java   |  16 +-
 .../component/http/HttpCredentialsHelperTest.java  |  59 ++--
 .../component/http/HttpDefaultPortNumberTest.java  |  26 +-
 .../component/http/HttpDisableStreamCacheTest.java |  10 +-
 .../camel/component/http/HttpEndpointURLTest.java  |   5 +-
 .../http/HttpEndpointUriAssemblerTest.java         |  22 +-
 .../camel/component/http/HttpMethodsTest.java      |  32 +-
 .../component/http/HttpNoCamelHeaderTest.java      |  21 +-
 .../http/HttpNoConnectionRedeliveryTest.java       |  14 +-
 .../camel/component/http/HttpNoConnectionTest.java |  14 +-
 .../apache/camel/component/http/HttpPathTest.java  |  14 +-
 .../component/http/HttpPollingConsumerTest.java    |  14 +-
 .../http/HttpProducerBridgeEndpointTest.java       |  20 +-
 .../http/HttpProducerConnectionCloseTest.java      |  18 +-
 .../http/HttpProducerContentLengthTest.java        |  20 +-
 .../http/HttpProducerContentTypeTest.java          |  20 +-
 .../HttpProducerContentTypeWithSemiColonTest.java  |  20 +-
 .../http/HttpProducerCustomHeaderTest.java         |  22 +-
 .../HttpProducerExplicitConnectionCloseTest.java   |  19 +-
 .../component/http/HttpProducerLoadManualIT.java   |   8 +-
 .../component/http/HttpProducerRestartTest.java    |  22 +-
 .../http/HttpProducerSelectMethodTest.java         |  14 +-
 .../component/http/HttpProducerSessionTest.java    |   2 +-
 .../HttpProducerTwoHeadersWithSameKeyTest.java     |  28 +-
 .../HttpProducerTwoParametersWithSameKeyTest.java  |  21 +-
 .../component/http/HttpProducerUserAgentTest.java  |  20 +-
 .../component/http/HttpProxyAndBasicAuthTest.java  | 106 ++-----
 .../camel/component/http/HttpProxyServerTest.java  |  96 ++----
 .../component/http/HttpQueryParameterTest.java     |  10 +-
 .../apache/camel/component/http/HttpQueryTest.java |  14 +-
 .../camel/component/http/HttpRedirectTest.java     |  71 ++---
 .../component/http/HttpReferenceParameterTest.java |   6 +-
 .../camel/component/http/HttpSOTimeoutTest.java    |  27 +-
 .../http/HttpSendDynamicAwareBasicAuthTest.java    |  30 +-
 .../http/HttpSendDynamicAwareEmptyPathTest.java    |   8 +-
 .../http/HttpSendDynamicAwareHeadersTest.java      |   8 +-
 .../http/HttpSendDynamicAwarePathHeaderTest.java   |   8 +-
 .../http/HttpSendDynamicAwareRawParameterTest.java |   7 +-
 .../http/HttpSendDynamicAwareRawTest.java          |  10 +-
 .../component/http/HttpSendDynamicAwareTest.java   |  10 +-
 .../HttpSendDynamicAwareUriWithSpacesTest.java     |   8 +-
 .../HttpSendDynamicAwareUriWithoutSlashTest.java   |   8 +-
 .../component/http/HttpServerTestSupport.java      |  23 +-
 .../camel/component/http/HttpSetHeaderIdsTest.java |  12 +-
 .../component/http/HttpSquareBracketTest.java      |  10 +-
 .../http/HttpThrowExceptionOnFailureTest.java      |  12 +-
 .../camel/component/http/HttpToDSOTimeoutTest.java |  20 +-
 .../component/http/HttpWithHttpUriHeaderTest.java  |  10 +-
 .../component/http/HttpsAuthenticationTest.java    |  32 +-
 .../apache/camel/component/http/HttpsGetTest.java  |  12 +-
 .../HttpsProducerWithSystemPropertiesTest.java     |  24 +-
 .../http/HttpsSslContextParametersGetTest.java     |  10 +-
 ...psTwoComponentsSslContextParametersGetTest.java |  14 +-
 ...tpsTwoDifferentSslContextParametersGetTest.java |  12 +-
 .../http/ManagedHttpProducerPoolStatsTest.java     |  20 +-
 .../handler/AuthenticationValidationHandler.java   |  14 +-
 .../handler/BasicRawQueryValidationHandler.java    |   7 +-
 .../http/handler/BasicValidationHandler.java       |  49 ++-
 .../http/handler/DelayValidationHandler.java       |  10 +-
 .../http/handler/DrinkAuthValidationHandler.java   |  17 +-
 .../http/handler/DrinkQueryValidationHandler.java  |  10 +-
 .../http/handler/DrinkValidationHandler.java       |   4 +-
 .../http/handler/HeaderValidationHandler.java      |  18 +-
 ...oxyAndBasicAuthenticationValidationHandler.java |  14 +-
 .../ProxyAuthenticationValidationHandler.java      |  14 +-
 .../http/interceptor/BasicAuthTokenExtractor.java  |  56 ++++
 .../http/interceptor/RequestBasicAuth.java}        |  29 +-
 .../http/interceptor/RequestProxyBasicAuth.java    |  71 +++++
 .../ResponseBasicUnauthorized.java}                |  31 +-
 .../ResponseProxyBasicUnauthorized.java}           |  30 +-
 .../http/rest/RestCamelComponentVerifierTest.java  |  22 +-
 114 files changed, 1760 insertions(+), 1583 deletions(-)

diff --git a/components/camel-http/pom.xml b/components/camel-http/pom.xml
index adef0004b6f..3bcef72b2d0 100644
--- a/components/camel-http/pom.xml
+++ b/components/camel-http/pom.xml
@@ -56,9 +56,9 @@
         </dependency>
 
         <dependency>
-            <groupId>org.apache.httpcomponents</groupId>
-            <artifactId>httpclient</artifactId>
-            <version>${httpclient4-version}</version>
+            <groupId>org.apache.httpcomponents.client5</groupId>
+            <artifactId>httpclient5</artifactId>
+            <version>${httpclient-version}</version>
         </dependency>
 
         <!-- testing -->
@@ -88,9 +88,9 @@
             <scope>test</scope>
         </dependency>
         <dependency>
-            <groupId>org.apache.httpcomponents</groupId>
-            <artifactId>httpclient</artifactId>
-            <version>${httpclient4-version}</version>
+            <groupId>org.apache.httpcomponents.client5</groupId>
+            <artifactId>httpclient5</artifactId>
+            <version>${httpclient-version}</version>
             <classifier>tests</classifier>
             <scope>test</scope>
         </dependency>
diff --git a/components/camel-http/src/generated/java/org/apache/camel/component/http/HttpComponentConfigurer.java b/components/camel-http/src/generated/java/org/apache/camel/component/http/HttpComponentConfigurer.java
index 3caf3f0eed8..58d39840502 100644
--- a/components/camel-http/src/generated/java/org/apache/camel/component/http/HttpComponentConfigurer.java
+++ b/components/camel-http/src/generated/java/org/apache/camel/component/http/HttpComponentConfigurer.java
@@ -30,11 +30,11 @@ public class HttpComponentConfigurer extends PropertyConfigurerSupport implement
         case "autowiredenabled":
         case "autowiredEnabled": target.setAutowiredEnabled(property(camelContext, boolean.class, value)); return true;
         case "clientconnectionmanager":
-        case "clientConnectionManager": target.setClientConnectionManager(property(camelContext, org.apache.http.conn.HttpClientConnectionManager.class, value)); return true;
+        case "clientConnectionManager": target.setClientConnectionManager(property(camelContext, org.apache.hc.client5.http.io.HttpClientConnectionManager.class, value)); return true;
         case "connecttimeout":
-        case "connectTimeout": target.setConnectTimeout(property(camelContext, int.class, value)); return true;
+        case "connectTimeout": target.setConnectTimeout(property(camelContext, org.apache.hc.core5.util.Timeout.class, value)); return true;
         case "connectionrequesttimeout":
-        case "connectionRequestTimeout": target.setConnectionRequestTimeout(property(camelContext, int.class, value)); return true;
+        case "connectionRequestTimeout": target.setConnectionRequestTimeout(property(camelContext, org.apache.hc.core5.util.Timeout.class, value)); return true;
         case "connectionstatedisabled":
         case "connectionStateDisabled": target.setConnectionStateDisabled(property(camelContext, boolean.class, value)); return true;
         case "connectiontimetolive":
@@ -46,7 +46,7 @@ public class HttpComponentConfigurer extends PropertyConfigurerSupport implement
         case "cookiemanagementdisabled":
         case "cookieManagementDisabled": target.setCookieManagementDisabled(property(camelContext, boolean.class, value)); return true;
         case "cookiestore":
-        case "cookieStore": target.setCookieStore(property(camelContext, org.apache.http.client.CookieStore.class, value)); return true;
+        case "cookieStore": target.setCookieStore(property(camelContext, org.apache.hc.client5.http.cookie.CookieStore.class, value)); return true;
         case "copyheaders":
         case "copyHeaders": target.setCopyHeaders(property(camelContext, boolean.class, value)); return true;
         case "defaultuseragentdisabled":
@@ -62,7 +62,7 @@ public class HttpComponentConfigurer extends PropertyConfigurerSupport implement
         case "httpconfiguration":
         case "httpConfiguration": target.setHttpConfiguration(property(camelContext, org.apache.camel.http.common.HttpConfiguration.class, value)); return true;
         case "httpcontext":
-        case "httpContext": target.setHttpContext(property(camelContext, org.apache.http.protocol.HttpContext.class, value)); return true;
+        case "httpContext": target.setHttpContext(property(camelContext, org.apache.hc.core5.http.protocol.HttpContext.class, value)); return true;
         case "lazystartproducer":
         case "lazyStartProducer": target.setLazyStartProducer(property(camelContext, boolean.class, value)); return true;
         case "maxtotalconnections":
@@ -87,12 +87,16 @@ public class HttpComponentConfigurer extends PropertyConfigurerSupport implement
         case "redirectHandlingDisabled": target.setRedirectHandlingDisabled(property(camelContext, boolean.class, value)); return true;
         case "responsepayloadstreamingthreshold":
         case "responsePayloadStreamingThreshold": target.setResponsePayloadStreamingThreshold(property(camelContext, int.class, value)); return true;
+        case "responsetimeout":
+        case "responseTimeout": target.setResponseTimeout(property(camelContext, org.apache.hc.core5.util.Timeout.class, value)); return true;
         case "skiprequestheaders":
         case "skipRequestHeaders": target.setSkipRequestHeaders(property(camelContext, boolean.class, value)); return true;
         case "skipresponseheaders":
         case "skipResponseHeaders": target.setSkipResponseHeaders(property(camelContext, boolean.class, value)); return true;
+        case "sotimeout":
+        case "soTimeout": target.setSoTimeout(property(camelContext, org.apache.hc.core5.util.Timeout.class, value)); return true;
         case "sockettimeout":
-        case "socketTimeout": target.setSocketTimeout(property(camelContext, int.class, value)); return true;
+        case "socketTimeout": target.setSocketTimeout(property(camelContext, org.apache.hc.core5.util.Timeout.class, value)); return true;
         case "sslcontextparameters":
         case "sslContextParameters": target.setSslContextParameters(property(camelContext, org.apache.camel.support.jsse.SSLContextParameters.class, value)); return true;
         case "useglobalsslcontextparameters":
@@ -115,11 +119,11 @@ public class HttpComponentConfigurer extends PropertyConfigurerSupport implement
         case "autowiredenabled":
         case "autowiredEnabled": return boolean.class;
         case "clientconnectionmanager":
-        case "clientConnectionManager": return org.apache.http.conn.HttpClientConnectionManager.class;
+        case "clientConnectionManager": return org.apache.hc.client5.http.io.HttpClientConnectionManager.class;
         case "connecttimeout":
-        case "connectTimeout": return int.class;
+        case "connectTimeout": return org.apache.hc.core5.util.Timeout.class;
         case "connectionrequesttimeout":
-        case "connectionRequestTimeout": return int.class;
+        case "connectionRequestTimeout": return org.apache.hc.core5.util.Timeout.class;
         case "connectionstatedisabled":
         case "connectionStateDisabled": return boolean.class;
         case "connectiontimetolive":
@@ -131,7 +135,7 @@ public class HttpComponentConfigurer extends PropertyConfigurerSupport implement
         case "cookiemanagementdisabled":
         case "cookieManagementDisabled": return boolean.class;
         case "cookiestore":
-        case "cookieStore": return org.apache.http.client.CookieStore.class;
+        case "cookieStore": return org.apache.hc.client5.http.cookie.CookieStore.class;
         case "copyheaders":
         case "copyHeaders": return boolean.class;
         case "defaultuseragentdisabled":
@@ -147,7 +151,7 @@ public class HttpComponentConfigurer extends PropertyConfigurerSupport implement
         case "httpconfiguration":
         case "httpConfiguration": return org.apache.camel.http.common.HttpConfiguration.class;
         case "httpcontext":
-        case "httpContext": return org.apache.http.protocol.HttpContext.class;
+        case "httpContext": return org.apache.hc.core5.http.protocol.HttpContext.class;
         case "lazystartproducer":
         case "lazyStartProducer": return boolean.class;
         case "maxtotalconnections":
@@ -172,12 +176,16 @@ public class HttpComponentConfigurer extends PropertyConfigurerSupport implement
         case "redirectHandlingDisabled": return boolean.class;
         case "responsepayloadstreamingthreshold":
         case "responsePayloadStreamingThreshold": return int.class;
+        case "responsetimeout":
+        case "responseTimeout": return org.apache.hc.core5.util.Timeout.class;
         case "skiprequestheaders":
         case "skipRequestHeaders": return boolean.class;
         case "skipresponseheaders":
         case "skipResponseHeaders": return boolean.class;
+        case "sotimeout":
+        case "soTimeout": return org.apache.hc.core5.util.Timeout.class;
         case "sockettimeout":
-        case "socketTimeout": return int.class;
+        case "socketTimeout": return org.apache.hc.core5.util.Timeout.class;
         case "sslcontextparameters":
         case "sslContextParameters": return org.apache.camel.support.jsse.SSLContextParameters.class;
         case "useglobalsslcontextparameters":
@@ -258,10 +266,14 @@ public class HttpComponentConfigurer extends PropertyConfigurerSupport implement
         case "redirectHandlingDisabled": return target.isRedirectHandlingDisabled();
         case "responsepayloadstreamingthreshold":
         case "responsePayloadStreamingThreshold": return target.getResponsePayloadStreamingThreshold();
+        case "responsetimeout":
+        case "responseTimeout": return target.getResponseTimeout();
         case "skiprequestheaders":
         case "skipRequestHeaders": return target.isSkipRequestHeaders();
         case "skipresponseheaders":
         case "skipResponseHeaders": return target.isSkipResponseHeaders();
+        case "sotimeout":
+        case "soTimeout": return target.getSoTimeout();
         case "sockettimeout":
         case "socketTimeout": return target.getSocketTimeout();
         case "sslcontextparameters":
diff --git a/components/camel-http/src/generated/java/org/apache/camel/component/http/HttpEntityConverterLoader.java b/components/camel-http/src/generated/java/org/apache/camel/component/http/HttpConvertersLoader.java
similarity index 67%
copy from components/camel-http/src/generated/java/org/apache/camel/component/http/HttpEntityConverterLoader.java
copy to components/camel-http/src/generated/java/org/apache/camel/component/http/HttpConvertersLoader.java
index 2be78b1e51c..7ed444964ea 100644
--- a/components/camel-http/src/generated/java/org/apache/camel/component/http/HttpEntityConverterLoader.java
+++ b/components/camel-http/src/generated/java/org/apache/camel/component/http/HttpConvertersLoader.java
@@ -18,11 +18,11 @@ import org.apache.camel.util.DoubleMap;
  */
 @SuppressWarnings("unchecked")
 @DeferredContextBinding
-public final class HttpEntityConverterLoader implements TypeConverterLoader, CamelContextAware {
+public final class HttpConvertersLoader implements TypeConverterLoader, CamelContextAware {
 
     private CamelContext camelContext;
 
-    public HttpEntityConverterLoader() {
+    public HttpConvertersLoader() {
     }
 
     @Override
@@ -41,12 +41,14 @@ public final class HttpEntityConverterLoader implements TypeConverterLoader, Cam
     }
 
     private void registerConverters(TypeConverterRegistry registry) {
-        addTypeConverter(registry, org.apache.http.HttpEntity.class, byte[].class, false,
-            (type, exchange, value) -> org.apache.camel.component.http.HttpEntityConverter.toHttpEntity((byte[]) value, exchange));
-        addTypeConverter(registry, org.apache.http.HttpEntity.class, java.io.InputStream.class, false,
-            (type, exchange, value) -> org.apache.camel.component.http.HttpEntityConverter.toHttpEntity((java.io.InputStream) value, exchange));
-        addTypeConverter(registry, org.apache.http.HttpEntity.class, java.lang.String.class, false,
-            (type, exchange, value) -> org.apache.camel.component.http.HttpEntityConverter.toHttpEntity((java.lang.String) value, exchange));
+        addTypeConverter(registry, org.apache.hc.core5.util.TimeValue.class, java.lang.String.class, false,
+            (type, exchange, value) -> org.apache.camel.component.http.HttpConverters.toTimeValue((java.lang.String) value));
+        addTypeConverter(registry, org.apache.hc.core5.util.TimeValue.class, long.class, false,
+            (type, exchange, value) -> org.apache.camel.component.http.HttpConverters.toTimeValue((long) value));
+        addTypeConverter(registry, org.apache.hc.core5.util.Timeout.class, java.lang.String.class, false,
+            (type, exchange, value) -> org.apache.camel.component.http.HttpConverters.toTimeout((java.lang.String) value));
+        addTypeConverter(registry, org.apache.hc.core5.util.Timeout.class, long.class, false,
+            (type, exchange, value) -> org.apache.camel.component.http.HttpConverters.toTimeout((long) value));
     }
 
     private static void addTypeConverter(TypeConverterRegistry registry, Class<?> toType, Class<?> fromType, boolean allowNull, SimpleTypeConverter.ConversionMethod method) { 
diff --git a/components/camel-http/src/generated/java/org/apache/camel/component/http/HttpEndpointConfigurer.java b/components/camel-http/src/generated/java/org/apache/camel/component/http/HttpEndpointConfigurer.java
index 9c41e61ab7d..801fc56b1cf 100644
--- a/components/camel-http/src/generated/java/org/apache/camel/component/http/HttpEndpointConfigurer.java
+++ b/components/camel-http/src/generated/java/org/apache/camel/component/http/HttpEndpointConfigurer.java
@@ -40,9 +40,9 @@ public class HttpEndpointConfigurer extends PropertyConfigurerSupport implements
         case "clearexpiredcookies":
         case "clearExpiredCookies": target.setClearExpiredCookies(property(camelContext, boolean.class, value)); return true;
         case "clientbuilder":
-        case "clientBuilder": target.setClientBuilder(property(camelContext, org.apache.http.impl.client.HttpClientBuilder.class, value)); return true;
+        case "clientBuilder": target.setClientBuilder(property(camelContext, org.apache.hc.client5.http.impl.classic.HttpClientBuilder.class, value)); return true;
         case "clientconnectionmanager":
-        case "clientConnectionManager": target.setClientConnectionManager(property(camelContext, org.apache.http.conn.HttpClientConnectionManager.class, value)); return true;
+        case "clientConnectionManager": target.setClientConnectionManager(property(camelContext, org.apache.hc.client5.http.io.HttpClientConnectionManager.class, value)); return true;
         case "connectionclose":
         case "connectionClose": target.setConnectionClose(property(camelContext, boolean.class, value)); return true;
         case "connectionsperroute":
@@ -50,7 +50,7 @@ public class HttpEndpointConfigurer extends PropertyConfigurerSupport implements
         case "cookiehandler":
         case "cookieHandler": target.setCookieHandler(property(camelContext, org.apache.camel.http.base.cookie.CookieHandler.class, value)); return true;
         case "cookiestore":
-        case "cookieStore": target.setCookieStore(property(camelContext, org.apache.http.client.CookieStore.class, value)); return true;
+        case "cookieStore": target.setCookieStore(property(camelContext, org.apache.hc.client5.http.cookie.CookieStore.class, value)); return true;
         case "copyheaders":
         case "copyHeaders": target.setCopyHeaders(property(camelContext, boolean.class, value)); return true;
         case "customhostheader":
@@ -66,13 +66,15 @@ public class HttpEndpointConfigurer extends PropertyConfigurerSupport implements
         case "headerfilterstrategy":
         case "headerFilterStrategy": target.setHeaderFilterStrategy(property(camelContext, org.apache.camel.spi.HeaderFilterStrategy.class, value)); return true;
         case "httpclient":
-        case "httpClient": target.setHttpClient(property(camelContext, org.apache.http.client.HttpClient.class, value)); return true;
+        case "httpClient": target.setHttpClient(property(camelContext, org.apache.hc.client5.http.classic.HttpClient.class, value)); return true;
         case "httpclientconfigurer":
         case "httpClientConfigurer": target.setHttpClientConfigurer(property(camelContext, org.apache.camel.component.http.HttpClientConfigurer.class, value)); return true;
         case "httpclientoptions":
         case "httpClientOptions": target.setHttpClientOptions(property(camelContext, java.util.Map.class, value)); return true;
+        case "httpconnectionoptions":
+        case "httpConnectionOptions": target.setHttpConnectionOptions(property(camelContext, java.util.Map.class, value)); return true;
         case "httpcontext":
-        case "httpContext": target.setHttpContext(property(camelContext, org.apache.http.protocol.HttpContext.class, value)); return true;
+        case "httpContext": target.setHttpContext(property(camelContext, org.apache.hc.core5.http.protocol.HttpContext.class, value)); return true;
         case "httpmethod":
         case "httpMethod": target.setHttpMethod(property(camelContext, org.apache.camel.http.common.HttpMethods.class, value)); return true;
         case "ignoreresponsebody":
@@ -145,9 +147,9 @@ public class HttpEndpointConfigurer extends PropertyConfigurerSupport implements
         case "clearexpiredcookies":
         case "clearExpiredCookies": return boolean.class;
         case "clientbuilder":
-        case "clientBuilder": return org.apache.http.impl.client.HttpClientBuilder.class;
+        case "clientBuilder": return org.apache.hc.client5.http.impl.classic.HttpClientBuilder.class;
         case "clientconnectionmanager":
-        case "clientConnectionManager": return org.apache.http.conn.HttpClientConnectionManager.class;
+        case "clientConnectionManager": return org.apache.hc.client5.http.io.HttpClientConnectionManager.class;
         case "connectionclose":
         case "connectionClose": return boolean.class;
         case "connectionsperroute":
@@ -155,7 +157,7 @@ public class HttpEndpointConfigurer extends PropertyConfigurerSupport implements
         case "cookiehandler":
         case "cookieHandler": return org.apache.camel.http.base.cookie.CookieHandler.class;
         case "cookiestore":
-        case "cookieStore": return org.apache.http.client.CookieStore.class;
+        case "cookieStore": return org.apache.hc.client5.http.cookie.CookieStore.class;
         case "copyheaders":
         case "copyHeaders": return boolean.class;
         case "customhostheader":
@@ -171,13 +173,15 @@ public class HttpEndpointConfigurer extends PropertyConfigurerSupport implements
         case "headerfilterstrategy":
         case "headerFilterStrategy": return org.apache.camel.spi.HeaderFilterStrategy.class;
         case "httpclient":
-        case "httpClient": return org.apache.http.client.HttpClient.class;
+        case "httpClient": return org.apache.hc.client5.http.classic.HttpClient.class;
         case "httpclientconfigurer":
         case "httpClientConfigurer": return org.apache.camel.component.http.HttpClientConfigurer.class;
         case "httpclientoptions":
         case "httpClientOptions": return java.util.Map.class;
+        case "httpconnectionoptions":
+        case "httpConnectionOptions": return java.util.Map.class;
         case "httpcontext":
-        case "httpContext": return org.apache.http.protocol.HttpContext.class;
+        case "httpContext": return org.apache.hc.core5.http.protocol.HttpContext.class;
         case "httpmethod":
         case "httpMethod": return org.apache.camel.http.common.HttpMethods.class;
         case "ignoreresponsebody":
@@ -282,6 +286,8 @@ public class HttpEndpointConfigurer extends PropertyConfigurerSupport implements
         case "httpClientConfigurer": return target.getHttpClientConfigurer();
         case "httpclientoptions":
         case "httpClientOptions": return target.getHttpClientOptions();
+        case "httpconnectionoptions":
+        case "httpConnectionOptions": return target.getHttpConnectionOptions();
         case "httpcontext":
         case "httpContext": return target.getHttpContext();
         case "httpmethod":
@@ -339,6 +345,8 @@ public class HttpEndpointConfigurer extends PropertyConfigurerSupport implements
         switch (ignoreCase ? name.toLowerCase() : name) {
         case "httpclientoptions":
         case "httpClientOptions": return java.lang.Object.class;
+        case "httpconnectionoptions":
+        case "httpConnectionOptions": return java.lang.Object.class;
         default: return null;
         }
     }
diff --git a/components/camel-http/src/generated/java/org/apache/camel/component/http/HttpEndpointUriFactory.java b/components/camel-http/src/generated/java/org/apache/camel/component/http/HttpEndpointUriFactory.java
index 7e91843ef16..ee87c1e8562 100644
--- a/components/camel-http/src/generated/java/org/apache/camel/component/http/HttpEndpointUriFactory.java
+++ b/components/camel-http/src/generated/java/org/apache/camel/component/http/HttpEndpointUriFactory.java
@@ -22,7 +22,7 @@ public class HttpEndpointUriFactory extends org.apache.camel.support.component.E
     private static final Set<String> SECRET_PROPERTY_NAMES;
     private static final Set<String> MULTI_VALUE_PREFIXES;
     static {
-        Set<String> props = new HashSet<>(50);
+        Set<String> props = new HashSet<>(51);
         props.add("authDomain");
         props.add("authHost");
         props.add("authMethod");
@@ -48,6 +48,7 @@ public class HttpEndpointUriFactory extends org.apache.camel.support.component.E
         props.add("httpClient");
         props.add("httpClientConfigurer");
         props.add("httpClientOptions");
+        props.add("httpConnectionOptions");
         props.add("httpContext");
         props.add("httpMethod");
         props.add("httpUri");
@@ -80,8 +81,9 @@ public class HttpEndpointUriFactory extends org.apache.camel.support.component.E
         secretProps.add("proxyAuthPassword");
         secretProps.add("proxyAuthUsername");
         SECRET_PROPERTY_NAMES = Collections.unmodifiableSet(secretProps);
-        Set<String> prefixes = new HashSet<>(1);
+        Set<String> prefixes = new HashSet<>(2);
         prefixes.add("httpClient.");
+        prefixes.add("httpConnection.");
         MULTI_VALUE_PREFIXES = Collections.unmodifiableSet(prefixes);
     }
 
diff --git a/components/camel-http/src/generated/java/org/apache/camel/component/http/HttpEntityConverterLoader.java b/components/camel-http/src/generated/java/org/apache/camel/component/http/HttpEntityConverterLoader.java
index 2be78b1e51c..8027427883b 100644
--- a/components/camel-http/src/generated/java/org/apache/camel/component/http/HttpEntityConverterLoader.java
+++ b/components/camel-http/src/generated/java/org/apache/camel/component/http/HttpEntityConverterLoader.java
@@ -41,11 +41,11 @@ public final class HttpEntityConverterLoader implements TypeConverterLoader, Cam
     }
 
     private void registerConverters(TypeConverterRegistry registry) {
-        addTypeConverter(registry, org.apache.http.HttpEntity.class, byte[].class, false,
+        addTypeConverter(registry, org.apache.hc.core5.http.HttpEntity.class, byte[].class, false,
             (type, exchange, value) -> org.apache.camel.component.http.HttpEntityConverter.toHttpEntity((byte[]) value, exchange));
-        addTypeConverter(registry, org.apache.http.HttpEntity.class, java.io.InputStream.class, false,
+        addTypeConverter(registry, org.apache.hc.core5.http.HttpEntity.class, java.io.InputStream.class, false,
             (type, exchange, value) -> org.apache.camel.component.http.HttpEntityConverter.toHttpEntity((java.io.InputStream) value, exchange));
-        addTypeConverter(registry, org.apache.http.HttpEntity.class, java.lang.String.class, false,
+        addTypeConverter(registry, org.apache.hc.core5.http.HttpEntity.class, java.lang.String.class, false,
             (type, exchange, value) -> org.apache.camel.component.http.HttpEntityConverter.toHttpEntity((java.lang.String) value, exchange));
     }
 
diff --git a/components/camel-http/src/generated/java/org/apache/camel/component/http/HttpEntityConverterLoader.java b/components/camel-http/src/generated/java/org/apache/camel/component/http/HttpTimeoutConverterLoader.java
similarity index 56%
copy from components/camel-http/src/generated/java/org/apache/camel/component/http/HttpEntityConverterLoader.java
copy to components/camel-http/src/generated/java/org/apache/camel/component/http/HttpTimeoutConverterLoader.java
index 2be78b1e51c..2cad4863d98 100644
--- a/components/camel-http/src/generated/java/org/apache/camel/component/http/HttpEntityConverterLoader.java
+++ b/components/camel-http/src/generated/java/org/apache/camel/component/http/HttpTimeoutConverterLoader.java
@@ -4,25 +4,21 @@ package org.apache.camel.component.http;
 import org.apache.camel.CamelContext;
 import org.apache.camel.CamelContextAware;
 import org.apache.camel.DeferredContextBinding;
-import org.apache.camel.Exchange;
-import org.apache.camel.TypeConversionException;
 import org.apache.camel.TypeConverterLoaderException;
 import org.apache.camel.spi.TypeConverterLoader;
 import org.apache.camel.spi.TypeConverterRegistry;
 import org.apache.camel.support.SimpleTypeConverter;
-import org.apache.camel.support.TypeConverterSupport;
-import org.apache.camel.util.DoubleMap;
 
 /**
  * Generated by camel build tools - do NOT edit this file!
  */
 @SuppressWarnings("unchecked")
 @DeferredContextBinding
-public final class HttpEntityConverterLoader implements TypeConverterLoader, CamelContextAware {
+public final class HttpTimeoutConverterLoader implements TypeConverterLoader, CamelContextAware {
 
     private CamelContext camelContext;
 
-    public HttpEntityConverterLoader() {
+    public HttpTimeoutConverterLoader() {
     }
 
     @Override
@@ -41,12 +37,10 @@ public final class HttpEntityConverterLoader implements TypeConverterLoader, Cam
     }
 
     private void registerConverters(TypeConverterRegistry registry) {
-        addTypeConverter(registry, org.apache.http.HttpEntity.class, byte[].class, false,
-            (type, exchange, value) -> org.apache.camel.component.http.HttpEntityConverter.toHttpEntity((byte[]) value, exchange));
-        addTypeConverter(registry, org.apache.http.HttpEntity.class, java.io.InputStream.class, false,
-            (type, exchange, value) -> org.apache.camel.component.http.HttpEntityConverter.toHttpEntity((java.io.InputStream) value, exchange));
-        addTypeConverter(registry, org.apache.http.HttpEntity.class, java.lang.String.class, false,
-            (type, exchange, value) -> org.apache.camel.component.http.HttpEntityConverter.toHttpEntity((java.lang.String) value, exchange));
+        addTypeConverter(registry, org.apache.hc.core5.util.Timeout.class, java.lang.String.class, false,
+            (type, exchange, value) -> HttpConverters.toTimeout((java.lang.String) value));
+        addTypeConverter(registry, org.apache.hc.core5.util.Timeout.class, long.class, false,
+            (type, exchange, value) -> HttpConverters.toTimeout((long) value));
     }
 
     private static void addTypeConverter(TypeConverterRegistry registry, Class<?> toType, Class<?> fromType, boolean allowNull, SimpleTypeConverter.ConversionMethod method) { 
diff --git a/components/camel-http/src/generated/resources/META-INF/services/org/apache/camel/TypeConverterLoader b/components/camel-http/src/generated/resources/META-INF/services/org/apache/camel/TypeConverterLoader
index 3641c41d69d..42287231588 100644
--- a/components/camel-http/src/generated/resources/META-INF/services/org/apache/camel/TypeConverterLoader
+++ b/components/camel-http/src/generated/resources/META-INF/services/org/apache/camel/TypeConverterLoader
@@ -1,2 +1,3 @@
 # Generated by camel build tools - do NOT edit this file!
+org.apache.camel.component.http.HttpConvertersLoader
 org.apache.camel.component.http.HttpEntityConverterLoader
diff --git a/components/camel-http/src/generated/resources/org/apache/camel/component/http/http.json b/components/camel-http/src/generated/resources/org/apache/camel/component/http/http.json
index 08d93e198b7..2cf9827c77e 100644
--- a/components/camel-http/src/generated/resources/org/apache/camel/component/http/http.json
+++ b/components/camel-http/src/generated/resources/org/apache/camel/component/http/http.json
@@ -3,7 +3,7 @@
     "kind": "component",
     "name": "http",
     "title": "HTTP",
-    "description": "Send requests to external HTTP servers using Apache HTTP Client 4.x.",
+    "description": "Send requests to external HTTP servers using Apache HTTP Client 5.x.",
     "deprecated": false,
     "deprecationNote": "",
     "firstVersion": "2.3.0",
@@ -27,7 +27,7 @@
   "componentProperties": {
     "followRedirects": { "kind": "property", "displayName": "Follow Redirects", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to the HTTP request should follow redirects. By default the HTTP request does not follow redirects" },
     "lazyStartProducer": { "kind": "property", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during star [...]
-    "cookieStore": { "kind": "property", "displayName": "Cookie Store", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "object", "javaType": "org.apache.http.client.CookieStore", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom org.apache.http.client.CookieStore. By default the org.apache.http.impl.client.BasicCookieStore is used which is an in-memory only cookie store. Notice if bridgeEndpoint=true then t [...]
+    "cookieStore": { "kind": "property", "displayName": "Cookie Store", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "object", "javaType": "org.apache.hc.client5.http.cookie.CookieStore", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom org.apache.hc.client5.http.cookie.CookieStore. By default the org.apache.hc.client5.http.cookie.BasicCookieStore is used which is an in-memory only cookie store. Notice i [...]
     "copyHeaders": { "kind": "property", "displayName": "Copy Headers", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "If this option is true then IN exchange headers will be copied to OUT exchange headers according to copy strategy. Setting this to false, allows to only include the headers from the HTTP response (not  [...]
     "responsePayloadStreamingThreshold": { "kind": "property", "displayName": "Response Payload Streaming Threshold", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 8192, "description": "This threshold in bytes controls whether the response payload should be stored in memory as a byte array or be streaming based. Set this to -1 to always use st [...]
     "skipRequestHeaders": { "kind": "property", "displayName": "Skip Request Headers", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to skip mapping all the Camel headers as HTTP request headers. If there are no data from Camel headers needed to be included in the HTTP request then this can avoid parsing over [...]
@@ -36,7 +36,7 @@
     "authCachingDisabled": { "kind": "property", "displayName": "Auth Caching Disabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Disables authentication scheme caching" },
     "automaticRetriesDisabled": { "kind": "property", "displayName": "Automatic Retries Disabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Disables automatic request recovery and re-execution" },
     "autowiredEnabled": { "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which t [...]
-    "clientConnectionManager": { "kind": "property", "displayName": "Client Connection Manager", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.http.conn.HttpClientConnectionManager", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom and shared HttpClientConnectionManager to manage connections. If this has been configured then this is always used for all endpoints created by this component." },
+    "clientConnectionManager": { "kind": "property", "displayName": "Client Connection Manager", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.hc.client5.http.io.HttpClientConnectionManager", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom and shared HttpClientConnectionManager to manage connections. If this has been configured then this is always used for all endpoints created by this comp [...]
     "connectionsPerRoute": { "kind": "property", "displayName": "Connections Per Route", "group": "advanced", "label": "advanced", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 20, "description": "The maximum number of connections per route." },
     "connectionStateDisabled": { "kind": "property", "displayName": "Connection State Disabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Disables connection state tracking" },
     "connectionTimeToLive": { "kind": "property", "displayName": "Connection Time To Live", "group": "advanced", "label": "advanced", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "autowired": false, "secret": false, "description": "The time for connection to live, the time unit is millisecond, the default value is always keep alive." },
@@ -46,7 +46,7 @@
     "httpBinding": { "kind": "property", "displayName": "Http Binding", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.http.common.HttpBinding", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom HttpBinding to control the mapping between Camel message and HttpClient." },
     "httpClientConfigurer": { "kind": "property", "displayName": "Http Client Configurer", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.component.http.HttpClientConfigurer", "deprecated": false, "autowired": false, "secret": false, "description": "To use the custom HttpClientConfigurer to perform configuration of the HttpClient that will be used." },
     "httpConfiguration": { "kind": "property", "displayName": "Http Configuration", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.http.common.HttpConfiguration", "deprecated": false, "autowired": false, "secret": false, "description": "To use the shared HttpConfiguration as base configuration." },
-    "httpContext": { "kind": "property", "displayName": "Http Context", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.http.protocol.HttpContext", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom org.apache.http.protocol.HttpContext when executing requests." },
+    "httpContext": { "kind": "property", "displayName": "Http Context", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.hc.core5.http.protocol.HttpContext", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom org.apache.hc.core5.http.protocol.HttpContext when executing requests." },
     "maxTotalConnections": { "kind": "property", "displayName": "Max Total Connections", "group": "advanced", "label": "advanced", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 200, "description": "The maximum number of connections." },
     "redirectHandlingDisabled": { "kind": "property", "displayName": "Redirect Handling Disabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Disables automatic redirect handling" },
     "headerFilterStrategy": { "kind": "property", "displayName": "Header Filter Strategy", "group": "filter", "label": "filter", "required": false, "type": "object", "javaType": "org.apache.camel.spi.HeaderFilterStrategy", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom org.apache.camel.spi.HeaderFilterStrategy to filter header to and from Camel message." },
@@ -61,9 +61,11 @@
     "sslContextParameters": { "kind": "property", "displayName": "Ssl Context Parameters", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "org.apache.camel.support.jsse.SSLContextParameters", "deprecated": false, "autowired": false, "secret": false, "description": "To configure security using SSLContextParameters. Important: Only one instance of org.apache.camel.support.jsse.SSLContextParameters is supported per HttpComponent. If you need to us [...]
     "useGlobalSslContextParameters": { "kind": "property", "displayName": "Use Global Ssl Context Parameters", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Enable usage of global SSL context parameters." },
     "x509HostnameVerifier": { "kind": "property", "displayName": "X509 Hostname Verifier", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "javax.net.ssl.HostnameVerifier", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom X509HostnameVerifier such as DefaultHostnameVerifier or NoopHostnameVerifier." },
-    "connectionRequestTimeout": { "kind": "property", "displayName": "Connection Request Timeout", "group": "timeout", "label": "timeout", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "defaultValue": -1, "description": "The timeout in milliseconds used when requesting a connection from the connection manager. A timeout value of zero is interpreted as an infinite timeout. A timeout value of zero is interpreted as an inf [...]
-    "connectTimeout": { "kind": "property", "displayName": "Connect Timeout", "group": "timeout", "label": "timeout", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "defaultValue": -1, "description": "Determines the timeout in milliseconds until a connection is established. A timeout value of zero is interpreted as an infinite timeout. A timeout value of zero is interpreted as an infinite timeout. A negative value is int [...]
-    "socketTimeout": { "kind": "property", "displayName": "Socket Timeout", "group": "timeout", "label": "timeout", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "defaultValue": -1, "description": "Defines the socket timeout in milliseconds, which is the timeout for waiting for data or, put differently, a maximum period inactivity between two consecutive data packets). A timeout value of zero is interpreted as an infini [...]
+    "connectionRequestTimeout": { "kind": "property", "displayName": "Connection Request Timeout", "group": "timeout", "label": "timeout", "required": false, "type": "object", "javaType": "org.apache.hc.core5.util.Timeout", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "3 minutes", "description": "Returns the connection lease request timeout used when requesting a connection from the connection manager. A timeout value of zero is interpreted as a disabled time [...]
+    "connectTimeout": { "kind": "property", "displayName": "Connect Timeout", "group": "timeout", "label": "timeout", "required": false, "type": "object", "javaType": "org.apache.hc.core5.util.Timeout", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "3 minutes", "description": "Determines the timeout until a new connection is fully established. A timeout value of zero is interpreted as an infinite timeout." },
+    "responseTimeout": { "kind": "property", "displayName": "Response Timeout", "group": "timeout", "label": "timeout", "required": false, "type": "object", "javaType": "org.apache.hc.core5.util.Timeout", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "0", "description": "Determines the timeout until arrival of a response from the opposite endpoint. A timeout value of zero is interpreted as an infinite timeout. Please note that response timeout may be unsupport [...]
+    "socketTimeout": { "kind": "property", "displayName": "Socket Timeout", "group": "timeout", "label": "timeout", "required": false, "type": "object", "javaType": "org.apache.hc.core5.util.Timeout", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "null (undefined)", "description": "Determines the default socket timeout value for I\/O operations." },
+    "soTimeout": { "kind": "property", "displayName": "So Timeout", "group": "timeout", "label": "timeout", "required": false, "type": "object", "javaType": "org.apache.hc.core5.util.Timeout", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "3 minutes", "description": "Determines the default socket timeout value for blocking I\/O operations." }
   },
   "headers": {
     "Content-Encoding": { "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The HTTP content encoding. Is set on both the IN and OUT message to provide a content encoding, such as gzip.", "constantName": "org.apache.camel.component.http.HttpConstants#CONTENT_ENCODING" },
@@ -92,7 +94,7 @@
     "throwExceptionOnFailure": { "kind": "parameter", "displayName": "Throw Exception On Failure", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Option to disable throwing the HttpOperationFailedException in case of failed responses from the remote server. This allows you to get all responses regardless of the HTTP status code." },
     "clearExpiredCookies": { "kind": "parameter", "displayName": "Clear Expired Cookies", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether to clear expired cookies before sending the HTTP request. This ensures the cookies store does not keep growing by adding new cookies which is newer removed when they are expir [...]
     "cookieHandler": { "kind": "parameter", "displayName": "Cookie Handler", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "object", "javaType": "org.apache.camel.http.base.cookie.CookieHandler", "deprecated": false, "autowired": false, "secret": false, "description": "Configure a cookie handler to maintain a HTTP session" },
-    "cookieStore": { "kind": "parameter", "displayName": "Cookie Store", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "object", "javaType": "org.apache.http.client.CookieStore", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom CookieStore. By default the BasicCookieStore is used which is an in-memory only cookie store. Notice if bridgeEndpoint=true then the cookie store is forced to be a noop cookie stor [...]
+    "cookieStore": { "kind": "parameter", "displayName": "Cookie Store", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "object", "javaType": "org.apache.hc.client5.http.cookie.CookieStore", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom CookieStore. By default the BasicCookieStore is used which is an in-memory only cookie store. Notice if bridgeEndpoint=true then the cookie store is forced to be a noop  [...]
     "copyHeaders": { "kind": "parameter", "displayName": "Copy Headers", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "If this option is true then IN exchange headers will be copied to OUT exchange headers according to copy strategy. Setting this to false, allows to only include the headers from the HTTP response (not [...]
     "customHostHeader": { "kind": "parameter", "displayName": "Custom Host Header", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "To use custom host header for producer. When not set in query will be ignored. When set will override host header derived from url." },
     "deleteWithBody": { "kind": "parameter", "displayName": "Delete With Body", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the HTTP DELETE should include the message body or not. By default HTTP DELETE do not include any HTTP body. However in some rare cases users may need to be able to include the message [...]
@@ -104,13 +106,14 @@
     "skipRequestHeaders": { "kind": "parameter", "displayName": "Skip Request Headers", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to skip mapping all the Camel headers as HTTP request headers. If there are no data from Camel headers needed to be included in the HTTP request then this can avoid parsing ove [...]
     "skipResponseHeaders": { "kind": "parameter", "displayName": "Skip Response Headers", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to skip mapping all the HTTP response headers to Camel headers. If there are no data needed from HTTP headers then this can avoid parsing overhead with many object allocation [...]
     "userAgent": { "kind": "parameter", "displayName": "User Agent", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "To set a custom HTTP User-Agent request header" },
-    "clientBuilder": { "kind": "parameter", "displayName": "Client Builder", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.http.impl.client.HttpClientBuilder", "deprecated": false, "autowired": false, "secret": false, "description": "Provide access to the http client request parameters used on new RequestConfig instances used by producers or consumers of this endpoint." },
-    "clientConnectionManager": { "kind": "parameter", "displayName": "Client Connection Manager", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.http.conn.HttpClientConnectionManager", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom HttpClientConnectionManager to manage connections" },
+    "clientBuilder": { "kind": "parameter", "displayName": "Client Builder", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.hc.client5.http.impl.classic.HttpClientBuilder", "deprecated": false, "autowired": false, "secret": false, "description": "Provide access to the http client request parameters used on new RequestConfig instances used by producers or consumers of this endpoint." },
+    "clientConnectionManager": { "kind": "parameter", "displayName": "Client Connection Manager", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.hc.client5.http.io.HttpClientConnectionManager", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom HttpClientConnectionManager to manage connections" },
     "connectionsPerRoute": { "kind": "parameter", "displayName": "Connections Per Route", "group": "advanced", "label": "advanced", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 20, "description": "The maximum number of connections per route." },
-    "httpClient": { "kind": "parameter", "displayName": "Http Client", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.http.client.HttpClient", "deprecated": false, "autowired": false, "secret": false, "description": "Sets a custom HttpClient to be used by the producer" },
+    "httpClient": { "kind": "parameter", "displayName": "Http Client", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.hc.client5.http.classic.HttpClient", "deprecated": false, "autowired": false, "secret": false, "description": "Sets a custom HttpClient to be used by the producer" },
     "httpClientConfigurer": { "kind": "parameter", "displayName": "Http Client Configurer", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.component.http.HttpClientConfigurer", "deprecated": false, "autowired": false, "secret": false, "description": "Register a custom configuration strategy for new HttpClient instances created by producers or consumers such as to configure authentication mechanisms etc." },
     "httpClientOptions": { "kind": "parameter", "displayName": "Http Client Options", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "java.util.Map<java.lang.String, java.lang.Object>", "prefix": "httpClient.", "multiValue": true, "deprecated": false, "autowired": false, "secret": false, "description": "To configure the HttpClient using the key\/values from the Map." },
-    "httpContext": { "kind": "parameter", "displayName": "Http Context", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.http.protocol.HttpContext", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom HttpContext instance" },
+    "httpConnectionOptions": { "kind": "parameter", "displayName": "Http Connection Options", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "java.util.Map<java.lang.String, java.lang.Object>", "prefix": "httpConnection.", "multiValue": true, "deprecated": false, "autowired": false, "secret": false, "description": "To configure the connection and the socket using the key\/values from the Map." },
+    "httpContext": { "kind": "parameter", "displayName": "Http Context", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.hc.core5.http.protocol.HttpContext", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom HttpContext instance" },
     "maxTotalConnections": { "kind": "parameter", "displayName": "Max Total Connections", "group": "advanced", "label": "advanced", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 200, "description": "The maximum number of connections." },
     "useSystemProperties": { "kind": "parameter", "displayName": "Use System Properties", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "To use System Properties as fallback for configuration" },
     "proxyAuthDomain": { "kind": "parameter", "displayName": "Proxy Auth Domain", "group": "proxy", "label": "producer,proxy", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Proxy authentication domain to use with NTML" },
diff --git a/components/camel-http/src/generated/resources/org/apache/camel/component/http/https.json b/components/camel-http/src/generated/resources/org/apache/camel/component/http/https.json
index 6974e979e64..36e3597ad93 100644
--- a/components/camel-http/src/generated/resources/org/apache/camel/component/http/https.json
+++ b/components/camel-http/src/generated/resources/org/apache/camel/component/http/https.json
@@ -3,7 +3,7 @@
     "kind": "component",
     "name": "https",
     "title": "HTTPS (Secure)",
-    "description": "Send requests to external HTTP servers using Apache HTTP Client 4.x.",
+    "description": "Send requests to external HTTP servers using Apache HTTP Client 5.x.",
     "deprecated": false,
     "deprecationNote": "",
     "firstVersion": "2.3.0",
@@ -27,7 +27,7 @@
   "componentProperties": {
     "followRedirects": { "kind": "property", "displayName": "Follow Redirects", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to the HTTP request should follow redirects. By default the HTTP request does not follow redirects" },
     "lazyStartProducer": { "kind": "property", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during star [...]
-    "cookieStore": { "kind": "property", "displayName": "Cookie Store", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "object", "javaType": "org.apache.http.client.CookieStore", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom org.apache.http.client.CookieStore. By default the org.apache.http.impl.client.BasicCookieStore is used which is an in-memory only cookie store. Notice if bridgeEndpoint=true then t [...]
+    "cookieStore": { "kind": "property", "displayName": "Cookie Store", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "object", "javaType": "org.apache.hc.client5.http.cookie.CookieStore", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom org.apache.hc.client5.http.cookie.CookieStore. By default the org.apache.hc.client5.http.cookie.BasicCookieStore is used which is an in-memory only cookie store. Notice i [...]
     "copyHeaders": { "kind": "property", "displayName": "Copy Headers", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "If this option is true then IN exchange headers will be copied to OUT exchange headers according to copy strategy. Setting this to false, allows to only include the headers from the HTTP response (not  [...]
     "responsePayloadStreamingThreshold": { "kind": "property", "displayName": "Response Payload Streaming Threshold", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 8192, "description": "This threshold in bytes controls whether the response payload should be stored in memory as a byte array or be streaming based. Set this to -1 to always use st [...]
     "skipRequestHeaders": { "kind": "property", "displayName": "Skip Request Headers", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to skip mapping all the Camel headers as HTTP request headers. If there are no data from Camel headers needed to be included in the HTTP request then this can avoid parsing over [...]
@@ -36,7 +36,7 @@
     "authCachingDisabled": { "kind": "property", "displayName": "Auth Caching Disabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Disables authentication scheme caching" },
     "automaticRetriesDisabled": { "kind": "property", "displayName": "Automatic Retries Disabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Disables automatic request recovery and re-execution" },
     "autowiredEnabled": { "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which t [...]
-    "clientConnectionManager": { "kind": "property", "displayName": "Client Connection Manager", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.http.conn.HttpClientConnectionManager", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom and shared HttpClientConnectionManager to manage connections. If this has been configured then this is always used for all endpoints created by this component." },
+    "clientConnectionManager": { "kind": "property", "displayName": "Client Connection Manager", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.hc.client5.http.io.HttpClientConnectionManager", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom and shared HttpClientConnectionManager to manage connections. If this has been configured then this is always used for all endpoints created by this comp [...]
     "connectionsPerRoute": { "kind": "property", "displayName": "Connections Per Route", "group": "advanced", "label": "advanced", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 20, "description": "The maximum number of connections per route." },
     "connectionStateDisabled": { "kind": "property", "displayName": "Connection State Disabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Disables connection state tracking" },
     "connectionTimeToLive": { "kind": "property", "displayName": "Connection Time To Live", "group": "advanced", "label": "advanced", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "autowired": false, "secret": false, "description": "The time for connection to live, the time unit is millisecond, the default value is always keep alive." },
@@ -46,7 +46,7 @@
     "httpBinding": { "kind": "property", "displayName": "Http Binding", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.http.common.HttpBinding", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom HttpBinding to control the mapping between Camel message and HttpClient." },
     "httpClientConfigurer": { "kind": "property", "displayName": "Http Client Configurer", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.component.http.HttpClientConfigurer", "deprecated": false, "autowired": false, "secret": false, "description": "To use the custom HttpClientConfigurer to perform configuration of the HttpClient that will be used." },
     "httpConfiguration": { "kind": "property", "displayName": "Http Configuration", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.http.common.HttpConfiguration", "deprecated": false, "autowired": false, "secret": false, "description": "To use the shared HttpConfiguration as base configuration." },
-    "httpContext": { "kind": "property", "displayName": "Http Context", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.http.protocol.HttpContext", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom org.apache.http.protocol.HttpContext when executing requests." },
+    "httpContext": { "kind": "property", "displayName": "Http Context", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.hc.core5.http.protocol.HttpContext", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom org.apache.hc.core5.http.protocol.HttpContext when executing requests." },
     "maxTotalConnections": { "kind": "property", "displayName": "Max Total Connections", "group": "advanced", "label": "advanced", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 200, "description": "The maximum number of connections." },
     "redirectHandlingDisabled": { "kind": "property", "displayName": "Redirect Handling Disabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Disables automatic redirect handling" },
     "headerFilterStrategy": { "kind": "property", "displayName": "Header Filter Strategy", "group": "filter", "label": "filter", "required": false, "type": "object", "javaType": "org.apache.camel.spi.HeaderFilterStrategy", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom org.apache.camel.spi.HeaderFilterStrategy to filter header to and from Camel message." },
@@ -61,9 +61,11 @@
     "sslContextParameters": { "kind": "property", "displayName": "Ssl Context Parameters", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "org.apache.camel.support.jsse.SSLContextParameters", "deprecated": false, "autowired": false, "secret": false, "description": "To configure security using SSLContextParameters. Important: Only one instance of org.apache.camel.support.jsse.SSLContextParameters is supported per HttpComponent. If you need to us [...]
     "useGlobalSslContextParameters": { "kind": "property", "displayName": "Use Global Ssl Context Parameters", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Enable usage of global SSL context parameters." },
     "x509HostnameVerifier": { "kind": "property", "displayName": "X509 Hostname Verifier", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "javax.net.ssl.HostnameVerifier", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom X509HostnameVerifier such as DefaultHostnameVerifier or NoopHostnameVerifier." },
-    "connectionRequestTimeout": { "kind": "property", "displayName": "Connection Request Timeout", "group": "timeout", "label": "timeout", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "defaultValue": -1, "description": "The timeout in milliseconds used when requesting a connection from the connection manager. A timeout value of zero is interpreted as an infinite timeout. A timeout value of zero is interpreted as an inf [...]
-    "connectTimeout": { "kind": "property", "displayName": "Connect Timeout", "group": "timeout", "label": "timeout", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "defaultValue": -1, "description": "Determines the timeout in milliseconds until a connection is established. A timeout value of zero is interpreted as an infinite timeout. A timeout value of zero is interpreted as an infinite timeout. A negative value is int [...]
-    "socketTimeout": { "kind": "property", "displayName": "Socket Timeout", "group": "timeout", "label": "timeout", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "defaultValue": -1, "description": "Defines the socket timeout in milliseconds, which is the timeout for waiting for data or, put differently, a maximum period inactivity between two consecutive data packets). A timeout value of zero is interpreted as an infini [...]
+    "connectionRequestTimeout": { "kind": "property", "displayName": "Connection Request Timeout", "group": "timeout", "label": "timeout", "required": false, "type": "object", "javaType": "org.apache.hc.core5.util.Timeout", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "3 minutes", "description": "Returns the connection lease request timeout used when requesting a connection from the connection manager. A timeout value of zero is interpreted as a disabled time [...]
+    "connectTimeout": { "kind": "property", "displayName": "Connect Timeout", "group": "timeout", "label": "timeout", "required": false, "type": "object", "javaType": "org.apache.hc.core5.util.Timeout", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "3 minutes", "description": "Determines the timeout until a new connection is fully established. A timeout value of zero is interpreted as an infinite timeout." },
+    "responseTimeout": { "kind": "property", "displayName": "Response Timeout", "group": "timeout", "label": "timeout", "required": false, "type": "object", "javaType": "org.apache.hc.core5.util.Timeout", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "0", "description": "Determines the timeout until arrival of a response from the opposite endpoint. A timeout value of zero is interpreted as an infinite timeout. Please note that response timeout may be unsupport [...]
+    "socketTimeout": { "kind": "property", "displayName": "Socket Timeout", "group": "timeout", "label": "timeout", "required": false, "type": "object", "javaType": "org.apache.hc.core5.util.Timeout", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "null (undefined)", "description": "Determines the default socket timeout value for I\/O operations." },
+    "soTimeout": { "kind": "property", "displayName": "So Timeout", "group": "timeout", "label": "timeout", "required": false, "type": "object", "javaType": "org.apache.hc.core5.util.Timeout", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "3 minutes", "description": "Determines the default socket timeout value for blocking I\/O operations." }
   },
   "headers": {
     "Content-Encoding": { "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The HTTP content encoding. Is set on both the IN and OUT message to provide a content encoding, such as gzip.", "constantName": "org.apache.camel.component.http.HttpConstants#CONTENT_ENCODING" },
@@ -92,7 +94,7 @@
     "throwExceptionOnFailure": { "kind": "parameter", "displayName": "Throw Exception On Failure", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Option to disable throwing the HttpOperationFailedException in case of failed responses from the remote server. This allows you to get all responses regardless of the HTTP status code." },
     "clearExpiredCookies": { "kind": "parameter", "displayName": "Clear Expired Cookies", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether to clear expired cookies before sending the HTTP request. This ensures the cookies store does not keep growing by adding new cookies which is newer removed when they are expir [...]
     "cookieHandler": { "kind": "parameter", "displayName": "Cookie Handler", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "object", "javaType": "org.apache.camel.http.base.cookie.CookieHandler", "deprecated": false, "autowired": false, "secret": false, "description": "Configure a cookie handler to maintain a HTTP session" },
-    "cookieStore": { "kind": "parameter", "displayName": "Cookie Store", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "object", "javaType": "org.apache.http.client.CookieStore", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom CookieStore. By default the BasicCookieStore is used which is an in-memory only cookie store. Notice if bridgeEndpoint=true then the cookie store is forced to be a noop cookie stor [...]
+    "cookieStore": { "kind": "parameter", "displayName": "Cookie Store", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "object", "javaType": "org.apache.hc.client5.http.cookie.CookieStore", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom CookieStore. By default the BasicCookieStore is used which is an in-memory only cookie store. Notice if bridgeEndpoint=true then the cookie store is forced to be a noop  [...]
     "copyHeaders": { "kind": "parameter", "displayName": "Copy Headers", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "If this option is true then IN exchange headers will be copied to OUT exchange headers according to copy strategy. Setting this to false, allows to only include the headers from the HTTP response (not [...]
     "customHostHeader": { "kind": "parameter", "displayName": "Custom Host Header", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "To use custom host header for producer. When not set in query will be ignored. When set will override host header derived from url." },
     "deleteWithBody": { "kind": "parameter", "displayName": "Delete With Body", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the HTTP DELETE should include the message body or not. By default HTTP DELETE do not include any HTTP body. However in some rare cases users may need to be able to include the message [...]
@@ -104,13 +106,14 @@
     "skipRequestHeaders": { "kind": "parameter", "displayName": "Skip Request Headers", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to skip mapping all the Camel headers as HTTP request headers. If there are no data from Camel headers needed to be included in the HTTP request then this can avoid parsing ove [...]
     "skipResponseHeaders": { "kind": "parameter", "displayName": "Skip Response Headers", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to skip mapping all the HTTP response headers to Camel headers. If there are no data needed from HTTP headers then this can avoid parsing overhead with many object allocation [...]
     "userAgent": { "kind": "parameter", "displayName": "User Agent", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "To set a custom HTTP User-Agent request header" },
-    "clientBuilder": { "kind": "parameter", "displayName": "Client Builder", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.http.impl.client.HttpClientBuilder", "deprecated": false, "autowired": false, "secret": false, "description": "Provide access to the http client request parameters used on new RequestConfig instances used by producers or consumers of this endpoint." },
-    "clientConnectionManager": { "kind": "parameter", "displayName": "Client Connection Manager", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.http.conn.HttpClientConnectionManager", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom HttpClientConnectionManager to manage connections" },
+    "clientBuilder": { "kind": "parameter", "displayName": "Client Builder", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.hc.client5.http.impl.classic.HttpClientBuilder", "deprecated": false, "autowired": false, "secret": false, "description": "Provide access to the http client request parameters used on new RequestConfig instances used by producers or consumers of this endpoint." },
+    "clientConnectionManager": { "kind": "parameter", "displayName": "Client Connection Manager", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.hc.client5.http.io.HttpClientConnectionManager", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom HttpClientConnectionManager to manage connections" },
     "connectionsPerRoute": { "kind": "parameter", "displayName": "Connections Per Route", "group": "advanced", "label": "advanced", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 20, "description": "The maximum number of connections per route." },
-    "httpClient": { "kind": "parameter", "displayName": "Http Client", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.http.client.HttpClient", "deprecated": false, "autowired": false, "secret": false, "description": "Sets a custom HttpClient to be used by the producer" },
+    "httpClient": { "kind": "parameter", "displayName": "Http Client", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.hc.client5.http.classic.HttpClient", "deprecated": false, "autowired": false, "secret": false, "description": "Sets a custom HttpClient to be used by the producer" },
     "httpClientConfigurer": { "kind": "parameter", "displayName": "Http Client Configurer", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.component.http.HttpClientConfigurer", "deprecated": false, "autowired": false, "secret": false, "description": "Register a custom configuration strategy for new HttpClient instances created by producers or consumers such as to configure authentication mechanisms etc." },
     "httpClientOptions": { "kind": "parameter", "displayName": "Http Client Options", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "java.util.Map<java.lang.String, java.lang.Object>", "prefix": "httpClient.", "multiValue": true, "deprecated": false, "autowired": false, "secret": false, "description": "To configure the HttpClient using the key\/values from the Map." },
-    "httpContext": { "kind": "parameter", "displayName": "Http Context", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.http.protocol.HttpContext", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom HttpContext instance" },
+    "httpConnectionOptions": { "kind": "parameter", "displayName": "Http Connection Options", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "java.util.Map<java.lang.String, java.lang.Object>", "prefix": "httpConnection.", "multiValue": true, "deprecated": false, "autowired": false, "secret": false, "description": "To configure the connection and the socket using the key\/values from the Map." },
+    "httpContext": { "kind": "parameter", "displayName": "Http Context", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.hc.core5.http.protocol.HttpContext", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom HttpContext instance" },
     "maxTotalConnections": { "kind": "parameter", "displayName": "Max Total Connections", "group": "advanced", "label": "advanced", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 200, "description": "The maximum number of connections." },
     "useSystemProperties": { "kind": "parameter", "displayName": "Use System Properties", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "To use System Properties as fallback for configuration" },
     "proxyAuthDomain": { "kind": "parameter", "displayName": "Proxy Auth Domain", "group": "proxy", "label": "producer,proxy", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Proxy authentication domain to use with NTML" },
diff --git a/components/camel-http/src/main/docs/http-component.adoc b/components/camel-http/src/main/docs/http-component.adoc
index 9167c54551b..64d9794e2d1 100644
--- a/components/camel-http/src/main/docs/http-component.adoc
+++ b/components/camel-http/src/main/docs/http-component.adoc
@@ -2,7 +2,7 @@
 :doctitle: HTTP
 :shortname: http
 :artifactid: camel-http
-:description: Send requests to external HTTP servers using Apache HTTP Client 4.x.
+:description: Send requests to external HTTP servers using Apache HTTP Client 5.x.
 :since: 2.3
 :supportlevel: Stable
 :component-header: Only producer is supported
@@ -66,7 +66,7 @@ HTTP response headers as well to the OUT message headers.
 == Using System Properties
 
 When setting useSystemProperties to true, the HTTP Client will look for
-the following System Properties and it will use it:
+the following System Properties, and it will use it:
 
 * ssl.TrustManagerFactory.algorithm
 * http://javax.net/[javax.net].ssl.trustStoreType
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/BasicAuthenticationHttpClientConfigurer.java b/components/camel-http/src/main/java/org/apache/camel/component/http/BasicAuthenticationHttpClientConfigurer.java
index ce57f2cb039..8ca73426032 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/BasicAuthenticationHttpClientConfigurer.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/BasicAuthenticationHttpClientConfigurer.java
@@ -16,14 +16,14 @@
  */
 package org.apache.camel.component.http;
 
-import org.apache.http.auth.Credentials;
-import org.apache.http.auth.NTCredentials;
-import org.apache.http.auth.UsernamePasswordCredentials;
-import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.hc.client5.http.auth.Credentials;
+import org.apache.hc.client5.http.auth.NTCredentials;
+import org.apache.hc.client5.http.auth.UsernamePasswordCredentials;
+import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
 
 public class BasicAuthenticationHttpClientConfigurer implements HttpClientConfigurer {
     private final String username;
-    private final String password;
+    private final char[] password;
     private final String domain;
     private final String host;
     private final HttpCredentialsHelper credentialsHelper;
@@ -31,7 +31,7 @@ public class BasicAuthenticationHttpClientConfigurer implements HttpClientConfig
     public BasicAuthenticationHttpClientConfigurer(String user, String pwd, String domain, String host,
                                                    HttpCredentialsHelper credentialsHelper) {
         this.username = user;
-        this.password = pwd;
+        this.password = pwd == null ? new char[0] : pwd.toCharArray();
         this.domain = domain;
         this.host = host;
         this.credentialsHelper = credentialsHelper;
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/CompositeHttpConfigurer.java b/components/camel-http/src/main/java/org/apache/camel/component/http/CompositeHttpConfigurer.java
index 04e3ddd5c4b..052ba009249 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/CompositeHttpConfigurer.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/CompositeHttpConfigurer.java
@@ -19,7 +19,7 @@ package org.apache.camel.component.http;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
 
 public class CompositeHttpConfigurer implements HttpClientConfigurer {
 
@@ -31,10 +31,6 @@ public class CompositeHttpConfigurer implements HttpClientConfigurer {
         }
     }
 
-    public void removeConfigurer(HttpClientConfigurer configurer) {
-        configurers.remove(configurer);
-    }
-
     @Override
     public void configureHttpClient(HttpClientBuilder clientBuilder) {
         for (HttpClientConfigurer configurer : configurers) {
@@ -44,9 +40,9 @@ public class CompositeHttpConfigurer implements HttpClientConfigurer {
 
     public static CompositeHttpConfigurer combineConfigurers(
             HttpClientConfigurer oldConfigurer, HttpClientConfigurer newConfigurer) {
-        if (oldConfigurer instanceof CompositeHttpConfigurer) {
-            ((CompositeHttpConfigurer) oldConfigurer).addConfigurer(newConfigurer);
-            return (CompositeHttpConfigurer) oldConfigurer;
+        if (oldConfigurer instanceof CompositeHttpConfigurer compositeHttpConfigurer) {
+            compositeHttpConfigurer.addConfigurer(newConfigurer);
+            return compositeHttpConfigurer;
         } else {
             CompositeHttpConfigurer answer = new CompositeHttpConfigurer();
             answer.addConfigurer(newConfigurer);
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpClientConfigurer.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpClientConfigurer.java
index f2f01ca887b..5443c749c49 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpClientConfigurer.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpClientConfigurer.java
@@ -16,7 +16,7 @@
  */
 package org.apache.camel.component.http;
 
-import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
 
 /**
  * A pluggable strategy for configuring the HttpClient used by this component
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 0c34356105a..322831c8566 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
@@ -22,7 +22,6 @@ import java.security.GeneralSecurityException;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Optional;
-import java.util.concurrent.TimeUnit;
 
 import javax.net.ssl.HostnameVerifier;
 
@@ -54,20 +53,25 @@ import org.apache.camel.util.PropertiesHelper;
 import org.apache.camel.util.StringHelper;
 import org.apache.camel.util.URISupport;
 import org.apache.camel.util.UnsafeUriCharactersEncoder;
-import org.apache.http.client.CookieStore;
-import org.apache.http.client.config.RequestConfig;
-import org.apache.http.config.Registry;
-import org.apache.http.config.RegistryBuilder;
-import org.apache.http.conn.HttpClientConnectionManager;
-import org.apache.http.conn.socket.ConnectionSocketFactory;
-import org.apache.http.conn.socket.PlainConnectionSocketFactory;
-import org.apache.http.conn.ssl.DefaultHostnameVerifier;
-import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
-import org.apache.http.impl.client.HttpClientBuilder;
-import org.apache.http.impl.client.LaxRedirectStrategy;
-import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.ssl.SSLContexts;
+import org.apache.hc.client5.http.config.ConnectionConfig;
+import org.apache.hc.client5.http.config.RequestConfig;
+import org.apache.hc.client5.http.cookie.CookieStore;
+import org.apache.hc.client5.http.impl.DefaultRedirectStrategy;
+import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
+import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager;
+import org.apache.hc.client5.http.io.HttpClientConnectionManager;
+import org.apache.hc.client5.http.socket.ConnectionSocketFactory;
+import org.apache.hc.client5.http.socket.PlainConnectionSocketFactory;
+import org.apache.hc.client5.http.ssl.DefaultHostnameVerifier;
+import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory;
+import org.apache.hc.core5.http.config.Registry;
+import org.apache.hc.core5.http.config.RegistryBuilder;
+import org.apache.hc.core5.http.io.SocketConfig;
+import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.pool.PoolConcurrencyPolicy;
+import org.apache.hc.core5.ssl.SSLContexts;
+import org.apache.hc.core5.util.TimeValue;
+import org.apache.hc.core5.util.Timeout;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -86,7 +90,8 @@ public class HttpComponent extends HttpCommonComponent implements RestProducerFa
     @Metadata(label = "advanced", description = "To use a custom and shared HttpClientConnectionManager to manage connections."
                                                 + " If this has been configured then this is always used for all endpoints created by this component.")
     protected HttpClientConnectionManager clientConnectionManager;
-    @Metadata(label = "advanced", description = "To use a custom org.apache.http.protocol.HttpContext when executing requests.")
+    @Metadata(label = "advanced",
+              description = "To use a custom org.apache.hc.core5.http.protocol.HttpContext when executing requests.")
     protected HttpContext httpContext;
     @Metadata(label = "security", description = "To configure security using SSLContextParameters."
                                                 + " Important: Only one instance of org.apache.camel.support.jsse.SSLContextParameters is supported per HttpComponent."
@@ -95,31 +100,39 @@ public class HttpComponent extends HttpCommonComponent implements RestProducerFa
     @Metadata(label = "security",
               description = "To use a custom X509HostnameVerifier such as DefaultHostnameVerifier or NoopHostnameVerifier.")
     protected HostnameVerifier x509HostnameVerifier = new DefaultHostnameVerifier();
-    @Metadata(label = "producer,advanced", description = "To use a custom org.apache.http.client.CookieStore."
-                                                         + " By default the org.apache.http.impl.client.BasicCookieStore is used which is an in-memory only cookie store."
+    @Metadata(label = "producer,advanced", description = "To use a custom org.apache.hc.client5.http.cookie.CookieStore."
+                                                         + " By default the org.apache.hc.client5.http.cookie.BasicCookieStore is used which is an in-memory only cookie store."
                                                          + " Notice if bridgeEndpoint=true then the cookie store is forced to be a noop cookie store as cookie"
                                                          + " shouldn't be stored as we are just bridging (eg acting as a proxy).")
     protected CookieStore cookieStore;
 
     // timeout
-    @Metadata(label = "timeout", defaultValue = "-1",
-              description = "The timeout in milliseconds used when requesting a connection"
-                            + " from the connection manager. A timeout value of zero is interpreted as an infinite timeout."
-                            + " A timeout value of zero is interpreted as an infinite timeout."
-                            + " A negative value is interpreted as undefined (system default).")
-    protected int connectionRequestTimeout = -1;
-    @Metadata(label = "timeout", defaultValue = "-1",
-              description = "Determines the timeout in milliseconds until a connection is established."
-                            + " A timeout value of zero is interpreted as an infinite timeout."
-                            + " A timeout value of zero is interpreted as an infinite timeout."
-                            + " A negative value is interpreted as undefined (system default).")
-    protected int connectTimeout = -1;
-    @Metadata(label = "timeout", defaultValue = "-1", description = "Defines the socket timeout in milliseconds,"
-                                                                    + " which is the timeout for waiting for data  or, put differently,"
-                                                                    + " a maximum period inactivity between two consecutive data packets)."
-                                                                    + " A timeout value of zero is interpreted as an infinite timeout."
-                                                                    + " A negative value is interpreted as undefined (system default).")
-    protected int socketTimeout = -1;
+    @Metadata(label = "timeout", defaultValue = "3 minutes",
+              description = "Returns the connection lease request timeout used when requesting"
+                            + " a connection from the connection manager."
+                            + " A timeout value of zero is interpreted as a disabled timeout.",
+              javaType = "org.apache.hc.core5.util.Timeout")
+    protected Timeout connectionRequestTimeout = Timeout.ofMinutes(3);
+    @Metadata(label = "timeout", defaultValue = "3 minutes",
+              description = "Determines the timeout until a new connection is fully established."
+                            + " A timeout value of zero is interpreted as an infinite timeout.",
+              javaType = "org.apache.hc.core5.util.Timeout")
+    protected Timeout connectTimeout = Timeout.ofMinutes(3);
+    @Metadata(label = "timeout", defaultValue = "null (undefined)",
+              description = "Determines the default socket timeout value for I/O operations.",
+              javaType = "org.apache.hc.core5.util.Timeout")
+    protected Timeout socketTimeout;
+    @Metadata(label = "timeout", defaultValue = "3 minutes",
+              description = "Determines the default socket timeout value for blocking I/O operations.",
+              javaType = "org.apache.hc.core5.util.Timeout")
+    protected Timeout soTimeout = Timeout.ofMinutes(3);
+    @Metadata(label = "timeout", defaultValue = "0",
+              description = "Determines the timeout until arrival of a response from the opposite"
+                            + " endpoint. A timeout value of zero is interpreted as an infinite timeout."
+                            + " Please note that response timeout may be unsupported by HTTP transports "
+                            + "with message multiplexing.",
+              javaType = "org.apache.hc.core5.util.Timeout")
+    protected Timeout responseTimeout = Timeout.ofMilliseconds(0);
 
     // proxy
     @Metadata(label = "producer,proxy", enums = "http,https", description = "Proxy authentication protocol scheme")
@@ -293,21 +306,28 @@ public class HttpComponent extends HttpCommonComponent implements RestProducerFa
         final Map<String, Object> httpClientOptions = new HashMap<>();
 
         // timeout values can be configured on both component and endpoint level, where endpoint take priority
-        int valConnectionRequestTimeout
-                = getAndRemoveParameter(parameters, "connectionRequestTimeout", int.class, connectionRequestTimeout);
-        if (valConnectionRequestTimeout != -1) {
+        Timeout valConnectionRequestTimeout
+                = getAndRemoveParameter(parameters, "connectionRequestTimeout", Timeout.class, connectionRequestTimeout);
+        if (!Timeout.ofMinutes(3).equals(valConnectionRequestTimeout)) {
             httpClientOptions.put("connectionRequestTimeout", valConnectionRequestTimeout);
         }
-        int valConnectTimeout = getAndRemoveParameter(parameters, "connectTimeout", int.class, connectTimeout);
-        if (valConnectTimeout != -1) {
-            httpClientOptions.put("connectTimeout", valConnectTimeout);
+        Timeout valResponseTimeout = getAndRemoveParameter(parameters, "responseTimeout", Timeout.class, responseTimeout);
+        if (!Timeout.ofMilliseconds(0).equals(valResponseTimeout)) {
+            httpClientOptions.put("responseTimeout", valResponseTimeout);
         }
-        int valSocketTimeout = getAndRemoveParameter(parameters, "socketTimeout", int.class, socketTimeout);
-        if (valSocketTimeout != -1) {
-            httpClientOptions.put("socketTimeout", valSocketTimeout);
+        final Map<String, Object> httpConnectionOptions = new HashMap<>();
+        Timeout valConnectTimeout = getAndRemoveParameter(parameters, "connectTimeout", Timeout.class, connectTimeout);
+        if (!Timeout.ofMinutes(3).equals(valConnectTimeout)) {
+            httpConnectionOptions.put("connectTimeout", valConnectTimeout);
+        }
+        Timeout valSocketTimeout = getAndRemoveParameter(parameters, "socketTimeout", Timeout.class, socketTimeout);
+        if (valSocketTimeout != null) {
+            httpConnectionOptions.put("socketTimeout", valSocketTimeout);
+        }
+        Timeout valSoTimeout = getAndRemoveParameter(parameters, "soTimeout", Timeout.class, soTimeout);
+        if (!Timeout.ofMinutes(3).equals(valSoTimeout)) {
+            httpConnectionOptions.put("soTimeout", valSoTimeout);
         }
-
-        final HttpClientBuilder clientBuilder = createHttpClientBuilder(uri, parameters, httpClientOptions);
 
         HttpBinding httpBinding = resolveAndRemoveReferenceParameter(parameters, "httpBinding", HttpBinding.class);
         HttpContext httpContext = resolveAndRemoveReferenceParameter(parameters, "httpContext", HttpContext.class);
@@ -371,9 +391,13 @@ public class HttpComponent extends HttpCommonComponent implements RestProducerFa
         String endpointUriString = endpointUri.toString();
 
         LOG.debug("Creating endpoint uri {}", endpointUriString);
-        final HttpClientConnectionManager localConnectionManager = createConnectionManager(parameters, sslContextParameters);
+        final HttpClientConnectionManager localConnectionManager
+                = createConnectionManager(parameters, sslContextParameters, httpConnectionOptions);
+        final HttpClientBuilder clientBuilder = createHttpClientBuilder(uri, parameters, httpClientOptions);
         HttpEndpoint endpoint = new HttpEndpoint(endpointUriString, this, clientBuilder, localConnectionManager, configurer);
+        endpoint.setResponseTimeout(valResponseTimeout);
         endpoint.setSocketTimeout(valSocketTimeout);
+        endpoint.setSoTimeout(valSoTimeout);
         endpoint.setConnectTimeout(valConnectTimeout);
         endpoint.setConnectionRequestTimeout(valConnectionRequestTimeout);
         endpoint.setCopyHeaders(copyHeaders);
@@ -427,13 +451,13 @@ public class HttpComponent extends HttpCommonComponent implements RestProducerFa
             endpoint.setCookieStore(getCookieStore());
         }
         endpoint.setHttpClientOptions(httpClientOptions);
-
+        endpoint.setHttpConnectionOptions(httpConnectionOptions);
         return endpoint;
     }
 
     protected HttpClientConnectionManager createConnectionManager(
             final Map<String, Object> parameters,
-            final SSLContextParameters sslContextParameters)
+            final SSLContextParameters sslContextParameters, Map<String, Object> httpConnectionOptions)
             throws GeneralSecurityException, IOException {
         if (clientConnectionManager != null) {
             return clientConnectionManager;
@@ -452,7 +476,15 @@ public class HttpComponent extends HttpCommonComponent implements RestProducerFa
         final Registry<ConnectionSocketFactory> connectionRegistry
                 = createConnectionRegistry(hostnameVerifier, sslContextParameters, useSystemProperties);
 
-        return createConnectionManager(connectionRegistry, maxTotalConnections, connectionsPerRoute);
+        // allow the builder pattern
+        httpConnectionOptions.putAll(PropertiesHelper.extractProperties(parameters, "httpConnection."));
+        SocketConfig.Builder socketConfigBuilder = SocketConfig.custom();
+        PropertyBindingSupport.bindProperties(getCamelContext(), socketConfigBuilder, httpConnectionOptions);
+        ConnectionConfig.Builder connectionConfigBuilder = ConnectionConfig.custom();
+        PropertyBindingSupport.bindProperties(getCamelContext(), connectionConfigBuilder, httpConnectionOptions);
+
+        return createConnectionManager(connectionRegistry, maxTotalConnections, connectionsPerRoute,
+                socketConfigBuilder.build(), connectionConfigBuilder.build());
     }
 
     protected HttpClientBuilder createHttpClientBuilder(
@@ -496,7 +528,7 @@ public class HttpComponent extends HttpCommonComponent implements RestProducerFa
             clientBuilder.disableDefaultUserAgent();
         }
         if (fr) {
-            clientBuilder.setRedirectStrategy(new LaxRedirectStrategy());
+            clientBuilder.setRedirectStrategy(DefaultRedirectStrategy.INSTANCE);
         }
 
         return clientBuilder;
@@ -507,7 +539,7 @@ public class HttpComponent extends HttpCommonComponent implements RestProducerFa
             boolean useSystemProperties)
             throws GeneralSecurityException, IOException {
         // create the default connection registry to use
-        RegistryBuilder<ConnectionSocketFactory> builder = RegistryBuilder.<ConnectionSocketFactory> create();
+        RegistryBuilder<ConnectionSocketFactory> builder = RegistryBuilder.create();
         builder.register("http", PlainConnectionSocketFactory.getSocketFactory());
         if (sslContextParams != null) {
             builder.register("https",
@@ -520,15 +552,12 @@ public class HttpComponent extends HttpCommonComponent implements RestProducerFa
         return builder.build();
     }
 
-    protected HttpClientConnectionManager createConnectionManager(Registry<ConnectionSocketFactory> registry) {
-        return createConnectionManager(registry, 0, 0);
-    }
-
     protected HttpClientConnectionManager createConnectionManager(
-            Registry<ConnectionSocketFactory> registry, int maxTotalConnections, int connectionsPerRoute) {
+            Registry<ConnectionSocketFactory> registry, int maxTotalConnections, int connectionsPerRoute,
+            SocketConfig defaultSocketConfig, ConnectionConfig defaultConnectionConfig) {
         // setup the connection live time
         PoolingHttpClientConnectionManager answer = new PoolingHttpClientConnectionManager(
-                registry, null, null, null, getConnectionTimeToLive(), TimeUnit.MILLISECONDS);
+                registry, PoolConcurrencyPolicy.STRICT, TimeValue.ofMilliseconds(getConnectionTimeToLive()), null);
         int localMaxTotalConnections = maxTotalConnections;
         if (localMaxTotalConnections == 0) {
             localMaxTotalConnections = getMaxTotalConnections();
@@ -536,6 +565,8 @@ public class HttpComponent extends HttpCommonComponent implements RestProducerFa
         if (localMaxTotalConnections > 0) {
             answer.setMaxTotal(localMaxTotalConnections);
         }
+        answer.setDefaultSocketConfig(defaultSocketConfig);
+        answer.setDefaultConnectionConfig(defaultConnectionConfig);
         int localConnectionsPerRoute = connectionsPerRoute;
         if (localConnectionsPerRoute == 0) {
             localConnectionsPerRoute = getConnectionsPerRoute();
@@ -553,6 +584,7 @@ public class HttpComponent extends HttpCommonComponent implements RestProducerFa
         return false;
     }
 
+    @SuppressWarnings("unchecked")
     @Override
     public Producer createProducer(
             CamelContext camelContext, String host,
@@ -594,7 +626,7 @@ public class HttpComponent extends HttpCommonComponent implements RestProducerFa
             url = url + "?" + query;
         }
 
-        parameters = parameters != null ? new HashMap<>(parameters) : new HashMap<String, Object>();
+        parameters = parameters != null ? new HashMap<>(parameters) : new HashMap<>();
 
         // there are cases where we might end up here without component being created beforehand
         // we need to abide by the component properties specified in the parameters when creating
@@ -729,60 +761,87 @@ public class HttpComponent extends HttpCommonComponent implements RestProducerFa
         this.cookieStore = cookieStore;
     }
 
-    public int getConnectionRequestTimeout() {
+    public Timeout getConnectionRequestTimeout() {
         return connectionRequestTimeout;
     }
 
     /**
-     * The timeout in milliseconds used when requesting a connection from the connection manager.
+     * Returns the connection lease request timeout used when requesting a connection from the connection manager.
      * <p>
-     * A timeout value of zero is interpreted as an infinite timeout. A negative value is interpreted as undefined
-     * (system default).
+     * A timeout value of zero is interpreted as a disabled timeout.
      * </p>
      * <p>
-     * Default: -1
+     * Default: 3 minutes
      * </p>
      */
-    public void setConnectionRequestTimeout(int connectionRequestTimeout) {
+    public void setConnectionRequestTimeout(Timeout connectionRequestTimeout) {
         this.connectionRequestTimeout = connectionRequestTimeout;
     }
 
-    public int getConnectTimeout() {
+    public Timeout getConnectTimeout() {
         return connectTimeout;
     }
 
     /**
-     * Determines the timeout in milliseconds until a connection is established. A timeout value of zero is interpreted
-     * as an infinite timeout.
+     * Determines the timeout until a new connection is fully established. This may also include transport security
+     * negotiation exchanges such as {@code SSL} or {@code TLS} protocol negotiation).
      * <p>
-     * A timeout value of zero is interpreted as an infinite timeout. A negative value is interpreted as undefined
-     * (system default).
+     * A timeout value of zero is interpreted as an infinite timeout.
      * </p>
      * <p>
-     * Default: -1
+     * Default: 3 minutes
      * </p>
      */
-    public void setConnectTimeout(int connectTimeout) {
+    public void setConnectTimeout(Timeout connectTimeout) {
         this.connectTimeout = connectTimeout;
     }
 
-    public int getSocketTimeout() {
+    public Timeout getSocketTimeout() {
         return socketTimeout;
     }
 
     /**
-     * Defines the socket timeout (SO_TIMEOUT) in milliseconds, which is the timeout for waiting for data or, put
-     * differently, a maximum period inactivity between two consecutive data packets).
+     * Determines the default socket timeout value for I/O operations.
      * <p>
-     * A timeout value of zero is interpreted as an infinite timeout. A negative value is interpreted as undefined
-     * (system default).
+     * Default: {@code null} (undefined)
      * </p>
+     */
+    public void setSocketTimeout(Timeout socketTimeout) {
+        this.socketTimeout = socketTimeout;
+    }
+
+    public Timeout getSoTimeout() {
+        return soTimeout;
+    }
+
+    /**
+     * Determines the default socket timeout value for blocking I/O operations.
      * <p>
-     * Default: -1
+     * Default: 3 minutes
      * </p>
      */
-    public void setSocketTimeout(int socketTimeout) {
-        this.socketTimeout = socketTimeout;
+    public void setSoTimeout(Timeout soTimeout) {
+        this.soTimeout = soTimeout;
+    }
+
+    public Timeout getResponseTimeout() {
+        return responseTimeout;
+    }
+
+    /**
+     * Determines the timeout until arrival of a response from the opposite endpoint.
+     * <p>
+     * A timeout value of zero is interpreted as an infinite timeout.
+     * </p>
+     * <p>
+     * Please note that response timeout may be unsupported by HTTP transports with message multiplexing.
+     * </p>
+     * <p>
+     * Default: {@code 0}
+     * </p>
+     */
+    public void setResponseTimeout(Timeout responseTimeout) {
+        this.responseTimeout = responseTimeout;
     }
 
     public String getProxyAuthScheme() {
@@ -963,7 +1022,7 @@ public class HttpComponent extends HttpCommonComponent implements RestProducerFa
         // shutdown connection manager
         if (clientConnectionManager != null) {
             LOG.info("Shutting down ClientConnectionManager: {}", clientConnectionManager);
-            clientConnectionManager.shutdown();
+            clientConnectionManager.close();
             clientConnectionManager = null;
         }
 
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponentVerifierExtension.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponentVerifierExtension.java
index c72b4697baa..b9d2d30210a 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponentVerifierExtension.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponentVerifierExtension.java
@@ -28,12 +28,10 @@ import org.apache.camel.component.extension.verifier.ResultErrorBuilder;
 import org.apache.camel.http.base.HttpHelper;
 import org.apache.camel.util.FileUtil;
 import org.apache.camel.util.ObjectHelper;
-import org.apache.http.client.config.RequestConfig;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpUriRequest;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.hc.client5.http.classic.methods.HttpGet;
+import org.apache.hc.client5.http.config.RequestConfig;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
 
 final class HttpComponentVerifierExtension extends DefaultComponentVerifierExtension {
 
@@ -99,47 +97,48 @@ final class HttpComponentVerifierExtension extends DefaultComponentVerifierExten
                             .build());
         }
 
-        try {
-            CloseableHttpClient httpclient = createHttpClient(verifyParams);
-            HttpUriRequest request = new HttpGet(httpUri);
-
-            try (CloseableHttpResponse response = httpclient.execute(request)) {
-                int code = response.getStatusLine().getStatusCode();
-                String okCodes = getOption(verifyParams, "okStatusCodeRange", String.class).orElse("200-299");
-
-                if (!HttpHelper.isStatusCodeOk(code, okCodes)) {
-                    if (code == 401) {
-                        // Unauthorized, add authUsername and authPassword to the list
-                        // of parameters in error
-                        builder.error(
-                                ResultErrorBuilder.withHttpCode(code)
-                                        .description(response.getStatusLine().getReasonPhrase())
-                                        .parameterKey("authUsername")
-                                        .parameterKey("authPassword")
-                                        .build());
-                    } else if (code >= 300 && code < 400) {
-                        // redirect
-                        builder.error(
-                                ResultErrorBuilder.withHttpCode(code)
-                                        .description(response.getStatusLine().getReasonPhrase())
-                                        .parameterKey("httpUri")
-                                        .detail(VerificationError.HttpAttribute.HTTP_REDIRECT,
-                                                () -> HttpUtil.responseHeaderValue(response, "location"))
-                                        .build());
-                    } else if (code >= 400) {
-                        // generic http error
-                        builder.error(
-                                ResultErrorBuilder.withHttpCode(code)
-                                        .description(response.getStatusLine().getReasonPhrase())
-                                        .build());
-                    }
-                }
-            } catch (UnknownHostException e) {
-                builder.error(
-                        ResultErrorBuilder.withException(e)
-                                .parameterKey("httpUri")
-                                .build());
-            }
+        try (CloseableHttpClient httpclient = createHttpClient(verifyParams)) {
+            httpclient.execute(
+                    new HttpGet(httpUri),
+                    response -> {
+                        int code = response.getCode();
+                        String okCodes = getOption(verifyParams, "okStatusCodeRange", String.class).orElse("200-299");
+
+                        if (!HttpHelper.isStatusCodeOk(code, okCodes)) {
+                            if (code == 401) {
+                                // Unauthorized, add authUsername and authPassword to the list
+                                // of parameters in error
+                                builder.error(
+                                        ResultErrorBuilder.withHttpCode(code)
+                                                .description(response.getReasonPhrase())
+                                                .parameterKey("authUsername")
+                                                .parameterKey("authPassword")
+                                                .build());
+                            } else if (code >= 300 && code < 400) {
+                                // redirect
+                                builder.error(
+                                        ResultErrorBuilder.withHttpCode(code)
+                                                .description(response.getReasonPhrase())
+                                                .parameterKey("httpUri")
+                                                .detail(VerificationError.HttpAttribute.HTTP_REDIRECT,
+                                                        () -> HttpUtil.responseHeaderValue(response, "location"))
+                                                .build());
+                            } else if (code >= 400) {
+                                // generic http error
+                                builder.error(
+                                        ResultErrorBuilder.withHttpCode(code)
+                                                .description(response.getReasonPhrase())
+                                                .build());
+                            }
+                        }
+                        return null;
+                    });
+
+        } catch (UnknownHostException e) {
+            builder.error(
+                    ResultErrorBuilder.withException(e)
+                            .parameterKey("httpUri")
+                            .build());
         } catch (Exception e) {
             builder.error(ResultErrorBuilder.withException(e).build());
         }
@@ -201,7 +200,7 @@ final class HttpComponentVerifierExtension extends DefaultComponentVerifierExten
             Optional<String> proxyAuthDomain = getOption(parameters, "proxyAuthDomain", String.class);
             Optional<String> proxyAuthNtHost = getOption(parameters, "proxyAuthNtHost", String.class);
 
-            if (!proxyAuthScheme.isPresent()) {
+            if (proxyAuthScheme.isEmpty()) {
                 proxyAuthScheme = Optional.of(HttpHelper.isSecureConnection(uri.get()) ? "https" : "http");
             }
 
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpConstants.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpConstants.java
index fe0a9fdfe8e..9bfe6d433dc 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpConstants.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpConstants.java
@@ -18,11 +18,13 @@ package org.apache.camel.component.http;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.spi.Metadata;
-import org.apache.http.HttpHeaders;
+import org.apache.hc.core5.http.ContentType;
+import org.apache.hc.core5.http.HttpHeaders;
 
 public final class HttpConstants {
 
     public static final String CONTENT_TYPE_JAVA_SERIALIZED_OBJECT = "application/x-java-serialized-object";
+    public static final ContentType JAVA_SERIALIZED_OBJECT = ContentType.create(CONTENT_TYPE_JAVA_SERIALIZED_OBJECT);
     public static final String CONTENT_TYPE_WWW_FORM_URLENCODED = "application/x-www-form-urlencoded";
 
     @Metadata(description = "The HTTP content encoding. Is set on both the IN and OUT message to\n" +
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpDeleteWithBodyMethod.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpConverters.java
similarity index 50%
rename from components/camel-http/src/main/java/org/apache/camel/component/http/HttpDeleteWithBodyMethod.java
rename to components/camel-http/src/main/java/org/apache/camel/component/http/HttpConverters.java
index 5c30f353bf8..a26106e3799 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpDeleteWithBodyMethod.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpConverters.java
@@ -16,27 +16,37 @@
  */
 package org.apache.camel.component.http;
 
-import java.net.URI;
+import org.apache.camel.Converter;
+import org.apache.hc.core5.util.TimeValue;
+import org.apache.hc.core5.util.Timeout;
 
-import org.apache.http.HttpEntity;
-import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
+/**
+ * Some converter methods to build different types used to configure the component.
+ */
+@Converter(generateLoader = true)
+public final class HttpConverters {
 
-public class HttpDeleteWithBodyMethod extends HttpEntityEnclosingRequestBase {
+    private HttpConverters() {
+        // Helper class
+    }
 
-    public static final String METHOD_NAME = "DELETE";
+    @Converter
+    public static Timeout toTimeout(long millis) {
+        return Timeout.ofMilliseconds(millis);
+    }
 
-    public HttpDeleteWithBodyMethod(String uri, HttpEntity entity) {
-        setURI(URI.create(uri));
-        setEntity(entity);
+    @Converter
+    public static Timeout toTimeout(String millis) {
+        return Timeout.ofMilliseconds(Long.parseLong(millis));
     }
 
-    public HttpDeleteWithBodyMethod(URI uri, HttpEntity entity) {
-        setURI(uri);
-        setEntity(entity);
+    @Converter
+    public static TimeValue toTimeValue(long millis) {
+        return TimeValue.ofMilliseconds(millis);
     }
 
-    @Override
-    public String getMethod() {
-        return METHOD_NAME;
+    @Converter
+    public static TimeValue toTimeValue(String millis) {
+        return TimeValue.ofMilliseconds(Long.parseLong(millis));
     }
 }
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpCredentialsHelper.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpCredentialsHelper.java
index 23270b78ca1..f51163f93b5 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpCredentialsHelper.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpCredentialsHelper.java
@@ -18,14 +18,15 @@ package org.apache.camel.component.http;
 
 import java.util.Objects;
 
-import org.apache.http.auth.AuthScope;
-import org.apache.http.auth.Credentials;
-import org.apache.http.client.CredentialsProvider;
-import org.apache.http.impl.client.BasicCredentialsProvider;
+import org.apache.hc.client5.http.auth.AuthScope;
+import org.apache.hc.client5.http.auth.Credentials;
+import org.apache.hc.client5.http.auth.CredentialsProvider;
+import org.apache.hc.client5.http.auth.CredentialsStore;
+import org.apache.hc.client5.http.impl.auth.BasicCredentialsProvider;
 
 final class HttpCredentialsHelper {
 
-    private final CredentialsProvider credentialsProvider;
+    private final CredentialsStore credentialsProvider;
 
     HttpCredentialsHelper() {
         this.credentialsProvider = new BasicCredentialsProvider();
@@ -35,7 +36,7 @@ final class HttpCredentialsHelper {
             String host, Integer port, Credentials credentials) {
         this.credentialsProvider.setCredentials(new AuthScope(
                 host,
-                Objects.requireNonNullElse(port, AuthScope.ANY_PORT)), credentials);
+                Objects.requireNonNullElse(port, -1)), credentials);
         return credentialsProvider;
     }
 
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java
index 5fa70271c7d..bdf448ae8b2 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java
@@ -39,23 +39,23 @@ import org.apache.camel.spi.UriParam;
 import org.apache.camel.support.jsse.SSLContextParameters;
 import org.apache.camel.util.IOHelper;
 import org.apache.camel.util.ObjectHelper;
-import org.apache.http.HttpHost;
-import org.apache.http.client.CookieStore;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.config.RequestConfig;
-import org.apache.http.conn.HttpClientConnectionManager;
-import org.apache.http.conn.ssl.DefaultHostnameVerifier;
-import org.apache.http.impl.client.BasicCookieStore;
-import org.apache.http.impl.client.HttpClientBuilder;
-import org.apache.http.impl.client.LaxRedirectStrategy;
-import org.apache.http.pool.ConnPoolControl;
-import org.apache.http.pool.PoolStats;
-import org.apache.http.protocol.HttpContext;
+import org.apache.hc.client5.http.classic.HttpClient;
+import org.apache.hc.client5.http.config.RequestConfig;
+import org.apache.hc.client5.http.cookie.BasicCookieStore;
+import org.apache.hc.client5.http.cookie.CookieStore;
+import org.apache.hc.client5.http.impl.DefaultRedirectStrategy;
+import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
+import org.apache.hc.client5.http.io.HttpClientConnectionManager;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.pool.ConnPoolControl;
+import org.apache.hc.core5.pool.PoolStats;
+import org.apache.hc.core5.util.Timeout;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * Send requests to external HTTP servers using Apache HTTP Client 4.x.
+ * Send requests to external HTTP servers using Apache HTTP Client 5.x.
  */
 @UriEndpoint(firstVersion = "2.3.0", scheme = "http,https", title = "HTTP,HTTPS", syntax = "http://httpUri",
              producerOnly = true, category = { Category.HTTP }, lenientProperties = true, headersClass = HttpConstants.class)
@@ -78,6 +78,9 @@ public class HttpEndpoint extends HttpCommonEndpoint {
     @UriParam(label = "advanced", prefix = "httpClient.", multiValue = true,
               description = "To configure the HttpClient using the key/values from the Map.")
     private Map<String, Object> httpClientOptions;
+    @UriParam(label = "advanced", prefix = "httpConnection.", multiValue = true,
+              description = "To configure the connection and the socket using the key/values from the Map.")
+    private Map<String, Object> httpConnectionOptions;
     @UriParam(label = "advanced", description = "To use a custom HttpClientConnectionManager to manage connections")
     private HttpClientConnectionManager clientConnectionManager;
     @UriParam(label = "advanced",
@@ -90,27 +93,33 @@ public class HttpEndpoint extends HttpCommonEndpoint {
     private boolean useSystemProperties;
 
     // timeout
-    @Metadata(label = "timeout", defaultValue = "-1",
-              description = "The timeout in milliseconds used when requesting a connection"
-                            + " from the connection manager. A timeout value of zero is interpreted as an infinite timeout."
-                            + " A timeout value of zero is interpreted as an infinite timeout."
-                            + " A negative value is interpreted as undefined (system default).",
-              javaType = "java.time.Duration")
-    private long connectionRequestTimeout = -1;
-    @Metadata(label = "timeout", defaultValue = "-1",
-              description = "Determines the timeout in milliseconds until a connection is established."
-                            + " A timeout value of zero is interpreted as an infinite timeout."
-                            + " A timeout value of zero is interpreted as an infinite timeout."
-                            + " A negative value is interpreted as undefined (system default).",
-              javaType = "java.time.Duration")
-    private long connectTimeout = -1;
-    @Metadata(label = "timeout", defaultValue = "-1", description = "Defines the socket timeout in milliseconds,"
-                                                                    + " which is the timeout for waiting for data  or, put differently,"
-                                                                    + " a maximum period inactivity between two consecutive data packets)."
-                                                                    + " A timeout value of zero is interpreted as an infinite timeout."
-                                                                    + " A negative value is interpreted as undefined (system default).",
-              javaType = "java.time.Duration")
-    private long socketTimeout = -1;
+    @Metadata(label = "timeout", defaultValue = "3 minutes",
+              description = "Returns the connection lease request timeout used when requesting"
+                            + " a connection from the connection manager."
+                            + " A timeout value of zero is interpreted as a disabled timeout.",
+              javaType = "org.apache.hc.core5.util.Timeout")
+    private Timeout connectionRequestTimeout = Timeout.ofMinutes(3);
+    @Metadata(label = "timeout", defaultValue = "3 minutes",
+              description = "Determines the timeout until a new connection is fully established."
+                            + " A timeout value of zero is interpreted as an infinite timeout.",
+              javaType = "org.apache.hc.core5.util.Timeout")
+    private Timeout connectTimeout = Timeout.ofMinutes(3);
+    @Metadata(label = "timeout", defaultValue = "null (undefined)",
+              description = "Determines the default socket timeout value for I/O operations.",
+              javaType = "org.apache.hc.core5.util.Timeout")
+    private Timeout socketTimeout;
+    @Metadata(label = "timeout", defaultValue = "3 minutes",
+              description = "Determines the default socket timeout value for blocking I/O operations.",
+              javaType = "org.apache.hc.core5.util.Timeout")
+    private Timeout soTimeout = Timeout.ofMinutes(3);
+    @Metadata(label = "timeout", defaultValue = "0",
+              description = "Determines the timeout until arrival of a response from the opposite"
+                            + " endpoint. A timeout value of zero is interpreted as an infinite timeout."
+                            + " Please note that response timeout may be unsupported by HTTP transports "
+                            + "with message multiplexing.",
+              javaType = "org.apache.hc.core5.util.Timeout")
+    private Timeout responseTimeout = Timeout.ofMilliseconds(0);
+
     @UriParam(label = "producer,advanced", description = "To use a custom CookieStore."
                                                          + " By default the BasicCookieStore is used which is an in-memory only cookie store."
                                                          + " Notice if bridgeEndpoint=true then the cookie store is forced to be a noop cookie store as cookie shouldn't be stored as we are just bridging (eg acting as a proxy)."
@@ -167,13 +176,13 @@ public class HttpEndpoint extends HttpCommonEndpoint {
     }
 
     public HttpEndpoint(String endPointURI, HttpComponent component, URI httpURI,
-                        HttpClientConnectionManager clientConnectionManager) throws URISyntaxException {
+                        HttpClientConnectionManager clientConnectionManager) {
         this(endPointURI, component, httpURI, HttpClientBuilder.create(), clientConnectionManager, null);
     }
 
     public HttpEndpoint(String endPointURI, HttpComponent component, HttpClientBuilder clientBuilder,
                         HttpClientConnectionManager clientConnectionManager,
-                        HttpClientConfigurer clientConfigurer) throws URISyntaxException {
+                        HttpClientConfigurer clientConfigurer) {
         this(endPointURI, component, null, clientBuilder, clientConnectionManager, clientConfigurer);
     }
 
@@ -248,7 +257,7 @@ public class HttpEndpoint extends HttpCommonEndpoint {
                 LOG.debug(
                         "CamelContext properties http.proxyHost, http.proxyPort, and http.proxyScheme detected. Using http proxy host: {} port: {} scheme: {}",
                         host, port, scheme);
-                HttpHost proxy = new HttpHost(host, port, scheme);
+                HttpHost proxy = new HttpHost(scheme, host, port);
                 clientBuilder.setProxy(proxy);
             }
         } else {
@@ -256,8 +265,8 @@ public class HttpEndpoint extends HttpCommonEndpoint {
         }
 
         if (isAuthenticationPreemptive()) {
-            // setup the PreemptiveAuthInterceptor here
-            clientBuilder.addInterceptorFirst(new PreemptiveAuthInterceptor());
+            // setup the preemptive authentication here
+            clientBuilder.addExecInterceptorFirst("preemptive-auth", new PreemptiveAuthExecChainHandler());
         }
         String userAgent = getUserAgent();
         if (userAgent != null) {
@@ -275,7 +284,7 @@ public class HttpEndpoint extends HttpCommonEndpoint {
         }
 
         if (isFollowRedirects()) {
-            clientBuilder.setRedirectStrategy(new LaxRedirectStrategy());
+            clientBuilder.setRedirectStrategy(DefaultRedirectStrategy.INSTANCE);
         }
 
         LOG.debug("Setup the HttpClientBuilder {}", clientBuilder);
@@ -291,10 +300,10 @@ public class HttpEndpoint extends HttpCommonEndpoint {
     protected void doStop() throws Exception {
         if (getComponent() != null && getComponent().getClientConnectionManager() != clientConnectionManager) {
             // need to shutdown the ConnectionManager
-            clientConnectionManager.shutdown();
+            clientConnectionManager.close();
         }
-        if (httpClient instanceof Closeable) {
-            IOHelper.close((Closeable) httpClient);
+        if (httpClient instanceof Closeable closeable) {
+            IOHelper.close(closeable);
         }
     }
 
@@ -431,6 +440,17 @@ public class HttpEndpoint extends HttpCommonEndpoint {
         this.httpClientOptions = httpClientOptions;
     }
 
+    public Map<String, Object> getHttpConnectionOptions() {
+        return httpConnectionOptions;
+    }
+
+    /**
+     * To configure the connection and the socket using the key/values from the Map.
+     */
+    public void setHttpConnectionOptions(Map<String, Object> httpConnectionOptions) {
+        this.httpConnectionOptions = httpConnectionOptions;
+    }
+
     public boolean isUseSystemProperties() {
         return useSystemProperties;
     }
@@ -469,8 +489,8 @@ public class HttpEndpoint extends HttpCommonEndpoint {
     }
 
     /**
-     * To use a custom X509HostnameVerifier such as {@link DefaultHostnameVerifier} or
-     * {@link org.apache.http.conn.ssl.NoopHostnameVerifier}.
+     * To use a custom X509HostnameVerifier such as {@link org.apache.hc.client5.http.ssl.DefaultHostnameVerifier} or
+     * {@link org.apache.hc.client5.http.ssl.NoopHostnameVerifier}.
      */
     public void setX509HostnameVerifier(HostnameVerifier x509HostnameVerifier) {
         this.x509HostnameVerifier = x509HostnameVerifier;
@@ -489,61 +509,87 @@ public class HttpEndpoint extends HttpCommonEndpoint {
         this.sslContextParameters = sslContextParameters;
     }
 
-    public long getConnectionRequestTimeout() {
+    public Timeout getConnectionRequestTimeout() {
         return connectionRequestTimeout;
     }
 
     /**
-     * The timeout in milliseconds used when requesting a connection from the connection manager. A timeout value of
-     * zero is interpreted as an infinite timeout.
+     * Returns the connection lease request timeout used when requesting a connection from the connection manager.
      * <p>
-     * A timeout value of zero is interpreted as an infinite timeout. A negative value is interpreted as undefined
-     * (system default).
+     * A timeout value of zero is interpreted as a disabled timeout.
      * </p>
      * <p>
-     * Default: {@code -1}
+     * Default: 3 minutes
      * </p>
      */
-    public void setConnectionRequestTimeout(long connectionRequestTimeout) {
+    public void setConnectionRequestTimeout(Timeout connectionRequestTimeout) {
         this.connectionRequestTimeout = connectionRequestTimeout;
     }
 
-    public long getConnectTimeout() {
+    public Timeout getConnectTimeout() {
         return connectTimeout;
     }
 
     /**
-     * Determines the timeout in milliseconds until a connection is established. A timeout value of zero is interpreted
-     * as an infinite timeout.
+     * Determines the timeout until a new connection is fully established. This may also include transport security
+     * negotiation exchanges such as {@code SSL} or {@code TLS} protocol negotiation).
      * <p>
-     * A timeout value of zero is interpreted as an infinite timeout. A negative value is interpreted as undefined
-     * (system default).
+     * A timeout value of zero is interpreted as an infinite timeout.
      * </p>
      * <p>
-     * Default: {@code -1}
+     * Default: 3 minutes
      * </p>
      */
-    public void setConnectTimeout(long connectTimeout) {
+    public void setConnectTimeout(Timeout connectTimeout) {
         this.connectTimeout = connectTimeout;
     }
 
-    public long getSocketTimeout() {
+    public Timeout getSocketTimeout() {
         return socketTimeout;
     }
 
     /**
-     * Defines the socket timeout ({@code SO_TIMEOUT}) in milliseconds, which is the timeout for waiting for data or,
-     * put differently, a maximum period inactivity between two consecutive data packets).
+     * Determines the default socket timeout value for I/O operations.
+     * <p>
+     * Default: {@code null} (undefined)
+     * </p>
+     */
+    public void setSocketTimeout(Timeout socketTimeout) {
+        this.socketTimeout = socketTimeout;
+    }
+
+    public Timeout getSoTimeout() {
+        return soTimeout;
+    }
+
+    /**
+     * Determines the default socket timeout value for blocking I/O operations.
+     * <p>
+     * Default: 3 minutes
+     * </p>
+     */
+    public void setSoTimeout(Timeout soTimeout) {
+        this.soTimeout = soTimeout;
+    }
+
+    public Timeout getResponseTimeout() {
+        return responseTimeout;
+    }
+
+    /**
+     * Determines the timeout until arrival of a response from the opposite endpoint.
      * <p>
-     * A timeout value of zero is interpreted as an infinite timeout. A negative value is interpreted as undefined
-     * (system default).
+     * A timeout value of zero is interpreted as an infinite timeout.
      * </p>
      * <p>
-     * Default: {@code -1}
+     * Please note that response timeout may be unsupported by HTTP transports with message multiplexing.
+     * </p>
+     * <p>
+     * Default: {@code 0}
      * </p>
      */
-    public void setSocketTimeout(long socketTimeout) {
-        this.socketTimeout = socketTimeout;
+    public void setResponseTimeout(Timeout responseTimeout) {
+        this.responseTimeout = responseTimeout;
     }
 
     /**
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEntityConverter.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEntityConverter.java
index 651c68037c1..b709dc9c928 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEntityConverter.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEntityConverter.java
@@ -24,10 +24,11 @@ import org.apache.camel.Converter;
 import org.apache.camel.Exchange;
 import org.apache.camel.support.ExchangeHelper;
 import org.apache.camel.support.GZIPHelper;
-import org.apache.http.HttpEntity;
-import org.apache.http.entity.AbstractHttpEntity;
-import org.apache.http.entity.ByteArrayEntity;
-import org.apache.http.entity.InputStreamEntity;
+import org.apache.hc.core5.http.ContentType;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.io.entity.AbstractHttpEntity;
+import org.apache.hc.core5.http.io.entity.ByteArrayEntity;
+import org.apache.hc.core5.http.io.entity.InputStreamEntity;
 
 /**
  * Some converter methods to make it easier to convert the body to RequestEntity types.
@@ -60,26 +61,27 @@ public final class HttpEntityConverter {
     }
 
     private static HttpEntity asHttpEntity(InputStream in, Exchange exchange) throws IOException {
+        String contentEncoding = null;
+        ContentType contentType = null;
+        if (exchange != null) {
+            contentEncoding = exchange.getIn().getHeader(HttpConstants.CONTENT_ENCODING, String.class);
+            String contentTypeAsString = ExchangeHelper.getContentType(exchange);
+            if (contentTypeAsString != null) {
+                contentType = ContentType.parse(contentTypeAsString);
+            }
+        }
+
         InputStreamEntity entity;
         if (exchange != null && !exchange.getProperty(Exchange.SKIP_GZIP_ENCODING, Boolean.FALSE, Boolean.class)) {
-            String contentEncoding = exchange.getIn().getHeader(HttpConstants.CONTENT_ENCODING, String.class);
             InputStream stream = GZIPHelper.compressGzip(contentEncoding, in);
+            int available = stream.available();
             entity = new InputStreamEntity(
-                    stream, stream instanceof ByteArrayInputStream
-                            ? stream.available() != 0 ? stream.available() : -1 : -1);
+                    stream, stream instanceof ByteArrayInputStream ? available != 0 ? available : -1 : -1, contentType,
+                    contentEncoding);
         } else {
-            entity = new InputStreamEntity(in, -1);
-        }
-        if (exchange != null) {
-            String contentEncoding = exchange.getIn().getHeader(HttpConstants.CONTENT_ENCODING, String.class);
-            if (contentEncoding != null) {
-                entity.setContentEncoding(contentEncoding);
-            }
-            String contentType = ExchangeHelper.getContentType(exchange);
-            if (contentType != null) {
-                entity.setContentType(contentType);
-            }
+            entity = new InputStreamEntity(in, -1, contentType, contentEncoding);
         }
+
         return entity;
     }
 
@@ -87,33 +89,31 @@ public final class HttpEntityConverter {
         AbstractHttpEntity entity;
 
         String contentEncoding = null;
+        ContentType contentType = null;
         if (exchange != null) {
             contentEncoding = exchange.getIn().getHeader(HttpConstants.CONTENT_ENCODING, String.class);
+            String contentTypeAsString = ExchangeHelper.getContentType(exchange);
+            if (contentTypeAsString != null) {
+                contentType = ContentType.parse(contentTypeAsString);
+            }
         }
 
         if (exchange != null && !exchange.getProperty(Exchange.SKIP_GZIP_ENCODING, Boolean.FALSE, Boolean.class)) {
             boolean gzip = GZIPHelper.isGzip(contentEncoding);
             if (gzip) {
                 InputStream stream = GZIPHelper.compressGzip(contentEncoding, data);
+                int available = stream.available();
                 entity = new InputStreamEntity(
                         stream, stream instanceof ByteArrayInputStream
-                                ? stream.available() != 0 ? stream.available() : -1 : -1);
+                                ? available != 0 ? available : -1 : -1,
+                        contentType, contentEncoding);
             } else {
                 // use a byte array entity as-is
-                entity = new ByteArrayEntity(data);
+                entity = new ByteArrayEntity(data, contentType, contentEncoding);
             }
         } else {
             // create the Repeatable HttpEntity
-            entity = new ByteArrayEntity(data);
-        }
-        if (exchange != null) {
-            if (contentEncoding != null) {
-                entity.setContentEncoding(contentEncoding);
-            }
-            String contentType = ExchangeHelper.getContentType(exchange);
-            if (contentType != null) {
-                entity.setContentType(contentType);
-            }
+            entity = new ByteArrayEntity(data, contentType, contentEncoding);
         }
         return entity;
     }
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpMethods.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpMethods.java
index 22fff8a464f..b2f847d0136 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpMethods.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpMethods.java
@@ -21,78 +21,57 @@ import java.net.URI;
 import org.apache.camel.Exchange;
 import org.apache.camel.Expression;
 import org.apache.camel.builder.ExpressionBuilder;
-import org.apache.http.client.methods.HttpDelete;
-import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpHead;
-import org.apache.http.client.methods.HttpOptions;
-import org.apache.http.client.methods.HttpPatch;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.client.methods.HttpPut;
-import org.apache.http.client.methods.HttpRequestBase;
-import org.apache.http.client.methods.HttpTrace;
+import org.apache.hc.client5.http.classic.methods.HttpDelete;
+import org.apache.hc.client5.http.classic.methods.HttpGet;
+import org.apache.hc.client5.http.classic.methods.HttpHead;
+import org.apache.hc.client5.http.classic.methods.HttpOptions;
+import org.apache.hc.client5.http.classic.methods.HttpPatch;
+import org.apache.hc.client5.http.classic.methods.HttpPost;
+import org.apache.hc.client5.http.classic.methods.HttpPut;
+import org.apache.hc.client5.http.classic.methods.HttpTrace;
+import org.apache.hc.client5.http.classic.methods.HttpUriRequest;
 
 public enum HttpMethods implements Expression {
 
-    GET(HttpGet.class),
-    PATCH(HttpPatch.class),
-    POST(HttpPost.class),
-    PUT(HttpPut.class),
-    DELETE(HttpDelete.class),
-    HEAD(HttpHead.class),
-    OPTIONS(HttpOptions.class),
-    TRACE(HttpTrace.class);
+    GET(false),
+    PATCH(true),
+    POST(true),
+    PUT(true),
+    DELETE(false),
+    HEAD(false),
+    OPTIONS(false),
+    TRACE(false);
 
     final boolean entity;
 
-    HttpMethods(Class<? extends HttpRequestBase> clazz) {
-        entity = HttpEntityEnclosingRequestBase.class.isAssignableFrom(clazz);
+    HttpMethods(boolean entity) {
+        this.entity = entity;
     }
 
-    public HttpRequestBase createMethod(final String url) {
-        switch (this) {
-            case GET:
-                return new HttpGet(url);
-            case PATCH:
-                return new HttpPatch(url);
-            case POST:
-                return new HttpPost(url);
-            case PUT:
-                return new HttpPut(url);
-            case DELETE:
-                return new HttpDelete(url);
-            case HEAD:
-                return new HttpHead(url);
-            case OPTIONS:
-                return new HttpOptions(url);
-            case TRACE:
-                return new HttpTrace(url);
-            default:
-                throw new RuntimeException("no such method " + this);
-        }
+    public HttpUriRequest createMethod(final String url) {
+        return switch (this) {
+            case GET -> new HttpGet(url);
+            case PATCH -> new HttpPatch(url);
+            case POST -> new HttpPost(url);
+            case PUT -> new HttpPut(url);
+            case DELETE -> new HttpDelete(url);
+            case HEAD -> new HttpHead(url);
+            case OPTIONS -> new HttpOptions(url);
+            case TRACE -> new HttpTrace(url);
+        };
     }
 
-    public HttpRequestBase createMethod(final URI uri) {
-        switch (this) {
-            case GET:
-                return new HttpGet(uri);
-            case PATCH:
-                return new HttpPatch(uri);
-            case POST:
-                return new HttpPost(uri);
-            case PUT:
-                return new HttpPut(uri);
-            case DELETE:
-                return new HttpDelete(uri);
-            case HEAD:
-                return new HttpHead(uri);
-            case OPTIONS:
-                return new HttpOptions(uri);
-            case TRACE:
-                return new HttpTrace(uri);
-            default:
-                throw new RuntimeException("no such method " + this);
-        }
+    public HttpUriRequest createMethod(final URI uri) {
+        return switch (this) {
+            case GET -> new HttpGet(uri);
+            case PATCH -> new HttpPatch(uri);
+            case POST -> new HttpPost(uri);
+            case PUT -> new HttpPut(uri);
+            case DELETE -> new HttpDelete(uri);
+            case HEAD -> new HttpHead(uri);
+            case OPTIONS -> new HttpOptions(uri);
+            case TRACE -> new HttpTrace(uri);
+        };
     }
 
     public final boolean isEntityEnclosing() {
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpPollingConsumer.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpPollingConsumer.java
index 805bca01a24..1c3e92caffb 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpPollingConsumer.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpPollingConsumer.java
@@ -17,6 +17,7 @@
 package org.apache.camel.component.http;
 
 import java.io.IOException;
+import java.util.concurrent.TimeUnit;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
@@ -24,17 +25,16 @@ import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.http.common.HttpHelper;
 import org.apache.camel.spi.HeaderFilterStrategy;
 import org.apache.camel.support.PollingConsumerSupport;
-import org.apache.http.Header;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.config.RequestConfig;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpRequestBase;
-import org.apache.http.client.protocol.HttpClientContext;
-import org.apache.http.impl.auth.BasicScheme;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.util.EntityUtils;
+import org.apache.hc.client5.http.classic.HttpClient;
+import org.apache.hc.client5.http.classic.methods.HttpGet;
+import org.apache.hc.client5.http.classic.methods.HttpUriRequest;
+import org.apache.hc.client5.http.config.RequestConfig;
+import org.apache.hc.client5.http.protocol.HttpClientContext;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.io.HttpClientResponseHandler;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
+import org.apache.hc.core5.http.protocol.HttpContext;
 
 /**
  * A polling HTTP consumer which by default performs a GET
@@ -42,7 +42,7 @@ import org.apache.http.util.EntityUtils;
 public class HttpPollingConsumer extends PollingConsumerSupport {
     private final HttpEndpoint endpoint;
     private HttpClient httpClient;
-    private HttpContext httpContext;
+    private final HttpContext httpContext;
 
     public HttpPollingConsumer(HttpEndpoint endpoint) {
         super(endpoint);
@@ -73,45 +73,49 @@ public class HttpPollingConsumer extends PollingConsumerSupport {
 
     protected Exchange doReceive(int timeout) {
         Exchange exchange = endpoint.createExchange();
-        HttpRequestBase method = createMethod(exchange);
+        HttpUriRequest method = createMethod(exchange);
         HttpClientContext httpClientContext = new HttpClientContext();
 
         // set optional timeout in millis
         if (timeout > 0) {
-            RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(timeout).build();
+            RequestConfig requestConfig = RequestConfig.custom().setResponseTimeout(timeout, TimeUnit.MILLISECONDS).build();
             httpClientContext.setRequestConfig(requestConfig);
         }
 
         HttpEntity responseEntity = null;
         try {
             // execute request
-            HttpResponse response = executeMethod(method, httpClientContext);
-            int responseCode = response.getStatusLine().getStatusCode();
-            responseEntity = response.getEntity();
-            Object body = HttpHelper.cacheResponseBodyFromInputStream(responseEntity.getContent(), exchange);
-
-            // lets store the result in the output message.
-            Message message = exchange.getMessage();
-            message.setBody(body);
-
-            // lets set the headers
-            Header[] headers = response.getAllHeaders();
-            HeaderFilterStrategy strategy = endpoint.getHeaderFilterStrategy();
-            for (Header header : headers) {
-                String name = header.getName();
-                // mapping the content-type
-                if (name.equalsIgnoreCase("content-type")) {
-                    name = Exchange.CONTENT_TYPE;
-                }
-                String value = header.getValue();
-                if (strategy != null && !strategy.applyFilterToExternalHeaders(name, value, exchange)) {
-                    message.setHeader(name, value);
-                }
-            }
-            message.setHeader(HttpConstants.HTTP_RESPONSE_CODE, responseCode);
-            if (response.getStatusLine() != null) {
-                message.setHeader(HttpConstants.HTTP_RESPONSE_TEXT, response.getStatusLine().getReasonPhrase());
-            }
+            responseEntity = executeMethod(
+                    method, httpClientContext,
+                    response -> {
+                        int responseCode = response.getCode();
+                        HttpEntity entity = response.getEntity();
+                        Object body = HttpHelper.cacheResponseBodyFromInputStream(entity.getContent(), exchange);
+
+                        // lets store the result in the output message.
+                        Message message = exchange.getMessage();
+                        message.setBody(body);
+
+                        // lets set the headers
+                        Header[] headers = response.getHeaders();
+                        HeaderFilterStrategy strategy = endpoint.getHeaderFilterStrategy();
+                        for (Header header : headers) {
+                            String name = header.getName();
+                            // mapping the content-type
+                            if (name.equalsIgnoreCase("content-type")) {
+                                name = Exchange.CONTENT_TYPE;
+                            }
+                            String value = header.getValue();
+                            if (strategy != null && !strategy.applyFilterToExternalHeaders(name, value, exchange)) {
+                                message.setHeader(name, value);
+                            }
+                        }
+                        message.setHeader(HttpConstants.HTTP_RESPONSE_CODE, responseCode);
+                        if (response.getReasonPhrase() != null) {
+                            message.setHeader(HttpConstants.HTTP_RESPONSE_TEXT, response.getReasonPhrase());
+                        }
+                        return entity;
+                    });
 
             return exchange;
         } catch (IOException e) {
@@ -134,16 +138,13 @@ public class HttpPollingConsumer extends PollingConsumerSupport {
      * @return             the response
      * @throws IOException can be thrown
      */
-    protected HttpResponse executeMethod(HttpRequestBase httpRequest, HttpClientContext httpClientContext) throws IOException {
-
-        if (getEndpoint().isAuthenticationPreemptive()) {
-            BasicScheme basicAuth = new BasicScheme();
-            httpClientContext.setAttribute("preemptive-auth", basicAuth);
-        }
+    protected <T> T executeMethod(
+            HttpUriRequest httpRequest, HttpClientContext httpClientContext, HttpClientResponseHandler<T> handler)
+            throws IOException {
         if (httpContext != null) {
             httpClientContext = new HttpClientContext(httpContext);
         }
-        return httpClient.execute(httpRequest, httpClientContext);
+        return httpClient.execute(httpRequest, httpClientContext, handler);
     }
 
     // Properties
@@ -160,7 +161,7 @@ public class HttpPollingConsumer extends PollingConsumerSupport {
     // Implementation methods
     //-------------------------------------------------------------------------
 
-    protected HttpRequestBase createMethod(Exchange exchange) {
+    protected HttpUriRequest createMethod(Exchange exchange) {
         String uri = HttpHelper.createURL(exchange, endpoint);
         return new HttpGet(uri);
     }
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
index cad827fc62d..0c9eb99ab75 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
@@ -25,6 +25,7 @@ import java.io.UnsupportedEncodingException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.nio.charset.Charset;
+import java.time.Instant;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Date;
@@ -38,11 +39,13 @@ import org.apache.camel.CamelExchangeException;
 import org.apache.camel.Exchange;
 import org.apache.camel.ExchangePropertyKey;
 import org.apache.camel.Message;
+import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.TypeConverter;
 import org.apache.camel.component.file.GenericFile;
 import org.apache.camel.component.http.helper.HttpMethodHelper;
 import org.apache.camel.converter.stream.CachedOutputStream;
 import org.apache.camel.http.base.HttpOperationFailedException;
+import org.apache.camel.http.base.cookie.CookieHandler;
 import org.apache.camel.http.common.HttpHelper;
 import org.apache.camel.http.common.HttpProtocolHeaderFilterStrategy;
 import org.apache.camel.spi.HeaderFilterStrategy;
@@ -56,27 +59,26 @@ import org.apache.camel.util.IOHelper;
 import org.apache.camel.util.StringHelper;
 import org.apache.camel.util.URISupport;
 import org.apache.camel.util.UnsafeUriCharactersEncoder;
-import org.apache.http.Header;
-import org.apache.http.HeaderIterator;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpVersion;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
-import org.apache.http.client.methods.HttpRequestBase;
-import org.apache.http.client.methods.HttpUriRequest;
-import org.apache.http.client.utils.URIUtils;
-import org.apache.http.entity.ByteArrayEntity;
-import org.apache.http.entity.ContentType;
-import org.apache.http.entity.FileEntity;
-import org.apache.http.entity.InputStreamEntity;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.auth.BasicScheme;
-import org.apache.http.protocol.BasicHttpContext;
-import org.apache.http.protocol.HTTP;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.util.EntityUtils;
+import org.apache.hc.client5.http.classic.HttpClient;
+import org.apache.hc.client5.http.classic.methods.HttpUriRequest;
+import org.apache.hc.client5.http.protocol.HttpClientContext;
+import org.apache.hc.client5.http.utils.URIUtils;
+import org.apache.hc.core5.http.ClassicHttpResponse;
+import org.apache.hc.core5.http.ContentType;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HeaderElements;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.io.HttpClientResponseHandler;
+import org.apache.hc.core5.http.io.entity.ByteArrayEntity;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
+import org.apache.hc.core5.http.io.entity.FileEntity;
+import org.apache.hc.core5.http.io.entity.InputStreamEntity;
+import org.apache.hc.core5.http.io.entity.StringEntity;
+import org.apache.hc.core5.http.protocol.BasicHttpContext;
+import org.apache.hc.core5.http.protocol.HttpContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -143,7 +145,7 @@ public class HttpProducer extends DefaultProducer {
         boolean cookies = !getEndpoint().getComponent().isCookieManagementDisabled();
         if (cookies && getEndpoint().isClearExpiredCookies() && !getEndpoint().isBridgeEndpoint()) {
             // create the cookies before the invocation
-            getEndpoint().getCookieStore().clearExpired(new Date());
+            getEndpoint().getCookieStore().clearExpired(Instant.now());
         }
 
         // if we bridge endpoint then we need to skip matching headers with the HTTP_QUERY to avoid sending
@@ -158,7 +160,7 @@ public class HttpProducer extends DefaultProducer {
             }
         }
 
-        HttpRequestBase httpRequest = createMethod(exchange);
+        HttpUriRequest httpRequest = createMethod(exchange);
         HttpHost httpHost = createHost(httpRequest);
 
         Message in = exchange.getIn();
@@ -166,7 +168,7 @@ public class HttpProducer extends DefaultProducer {
         if (httpProtocolVersion != null) {
             // set the HTTP protocol version
             int[] version = HttpHelper.parserHttpVersion(httpProtocolVersion);
-            httpRequest.setProtocolVersion(new HttpVersion(version[0], version[1]));
+            httpRequest.setVersion(new HttpVersion(version[0], version[1]));
         }
 
         HeaderFilterStrategy strategy = getEndpoint().getHeaderFilterStrategy();
@@ -236,7 +238,7 @@ public class HttpProducer extends DefaultProducer {
 
         if (getEndpoint().getCookieHandler() != null) {
             Map<String, List<String>> cookieHeaders
-                    = getEndpoint().getCookieHandler().loadCookies(exchange, httpRequest.getURI());
+                    = getEndpoint().getCookieHandler().loadCookies(exchange, httpRequest.getUri());
             for (Map.Entry<String, List<String>> entry : cookieHeaders.entrySet()) {
                 String key = entry.getKey();
                 if (!entry.getValue().isEmpty()) {
@@ -260,61 +262,90 @@ public class HttpProducer extends DefaultProducer {
         }
 
         if (getEndpoint().isConnectionClose()) {
-            httpRequest.addHeader("Connection", HTTP.CONN_CLOSE);
+            httpRequest.addHeader("Connection", HeaderElements.CLOSE);
         }
 
         // lets store the result in the output message.
-        HttpResponse httpResponse = null;
         try {
-            if (LOG.isDebugEnabled()) {
-                LOG.debug("Executing http {} method: {}", httpRequest.getMethod(), httpRequest.getURI());
-            }
-            httpResponse = executeMethod(httpHost, httpRequest);
-            int responseCode = httpResponse.getStatusLine().getStatusCode();
-            if (LOG.isDebugEnabled()) {
-                LOG.debug("Http responseCode: {}", responseCode);
-            }
-
-            if (!throwException) {
-                // if we do not use failed exception then populate response for all response codes
-                populateResponse(exchange, httpRequest, httpResponse, strategy, responseCode);
-            } else {
-                boolean ok;
-                if (minOkRange > 0) {
-                    ok = responseCode >= minOkRange && responseCode <= maxOkRange;
-                } else {
-                    ok = HttpHelper.isStatusCodeOk(responseCode, getEndpoint().getOkStatusCodeRange());
-                }
-                if (ok) {
-                    // only populate response for OK response
-                    populateResponse(exchange, httpRequest, httpResponse, strategy, responseCode);
-                } else {
-                    // operation failed so populate exception to throw
-                    throw populateHttpOperationFailedException(exchange, httpRequest, httpResponse, responseCode);
-                }
-            }
-        } finally {
-            final HttpResponse response = httpResponse;
-            if (httpResponse != null && getEndpoint().isDisableStreamCache()) {
-                // close the stream at the end of the exchange to ensure it gets eventually closed later
-                exchange.getExchangeExtension().addOnCompletion(new SynchronizationAdapter() {
-                    @Override
-                    public void onDone(Exchange exchange) {
+            executeMethod(
+                    httpHost, httpRequest,
+                    httpResponse -> {
                         try {
-                            EntityUtils.consume(response.getEntity());
+                            if (LOG.isDebugEnabled()) {
+                                LOG.debug("Executing http {} method: {}", httpRequest.getMethod(), httpRequest.getUri());
+                            }
+                            int responseCode = httpResponse.getCode();
+                            if (LOG.isDebugEnabled()) {
+                                LOG.debug("Http responseCode: {}", responseCode);
+                            }
+
+                            if (!throwException) {
+                                // if we do not use failed exception then populate response for all response codes
+                                HttpProducer.this.populateResponse(exchange, httpRequest, httpResponse, strategy, responseCode);
+                            } else {
+                                boolean ok;
+                                if (minOkRange > 0) {
+                                    ok = responseCode >= minOkRange && responseCode <= maxOkRange;
+                                } else {
+                                    ok = HttpHelper.isStatusCodeOk(responseCode,
+                                            HttpProducer.this.getEndpoint().getOkStatusCodeRange());
+                                }
+                                if (ok) {
+                                    // only populate response for OK response
+                                    HttpProducer.this.populateResponse(exchange, httpRequest, httpResponse, strategy,
+                                            responseCode);
+                                } else {
+                                    // operation failed so populate exception to throw
+                                    throw HttpProducer.this.populateHttpOperationFailedException(exchange, httpRequest,
+                                            httpResponse, responseCode);
+                                }
+                            }
+                        } catch (IOException | HttpException | RuntimeCamelException e) {
+                            throw e;
                         } catch (Exception e) {
-                            // ignore
+                            throw new RuntimeCamelException(e);
+                        } finally {
+                            if (httpResponse != null && HttpProducer.this.getEndpoint().isDisableStreamCache()) {
+                                // close the stream at the end of the exchange to ensure it gets eventually closed later
+                                exchange.getExchangeExtension().addOnCompletion(new SynchronizationAdapter() {
+                                    @Override
+                                    public void onDone(Exchange exchange1) {
+                                        try {
+                                            EntityUtils.consume(httpResponse.getEntity());
+                                        } catch (Exception e) {
+                                            // ignore
+                                        } finally {
+                                            try {
+                                                EntityUtils.consume(httpRequest.getEntity());
+                                            } catch (Exception e) {
+                                                // ignore
+                                            }
+                                        }
+                                    }
+                                });
+                            } else if (httpResponse != null) {
+                                // close the stream now
+                                try {
+                                    EntityUtils.consume(httpResponse.getEntity());
+                                } catch (Exception e) {
+                                    // ignore
+                                } finally {
+                                    try {
+                                        EntityUtils.consume(httpRequest.getEntity());
+                                    } catch (Exception e) {
+                                        // ignore
+                                    }
+                                }
+                            }
                         }
-                    }
-                });
-            } else if (httpResponse != null) {
-                // close the stream now
-                try {
-                    EntityUtils.consume(response.getEntity());
-                } catch (Exception e) {
-                    // ignore
-                }
+                        return null;
+                    });
+        } catch (RuntimeCamelException e) {
+            if (e.getCause() instanceof Exception ex) {
+                // Rethrow the embedded exception to simulate the same behavior as with version 4
+                throw ex;
             }
+            throw e;
         }
     }
 
@@ -324,7 +355,7 @@ public class HttpProducer extends DefaultProducer {
     }
 
     protected void populateResponse(
-            Exchange exchange, HttpRequestBase httpRequest, HttpResponse httpResponse,
+            Exchange exchange, HttpUriRequest httpRequest, ClassicHttpResponse httpResponse,
             HeaderFilterStrategy strategy, int responseCode)
             throws IOException, ClassNotFoundException {
         // We just make the out message is not create when extractResponseBody throws exception
@@ -337,8 +368,8 @@ public class HttpProducer extends DefaultProducer {
         } else {
             answer.setHeader(HttpConstants.HTTP_RESPONSE_CODE, responseCode);
         }
-        if (httpResponse.getStatusLine() != null) {
-            answer.setHeader(HttpConstants.HTTP_RESPONSE_TEXT, httpResponse.getStatusLine().getReasonPhrase());
+        if (httpResponse.getReasonPhrase() != null) {
+            answer.setHeader(HttpConstants.HTTP_RESPONSE_TEXT, httpResponse.getReasonPhrase());
         }
         answer.setBody(response);
 
@@ -346,15 +377,16 @@ public class HttpProducer extends DefaultProducer {
 
             // propagate HTTP response headers
             Map<String, List<String>> cookieHeaders = null;
-            if (getEndpoint().getCookieHandler() != null) {
+            CookieHandler cookieHandler = getEndpoint().getCookieHandler();
+            if (cookieHandler != null) {
                 cookieHeaders = new HashMap<>();
             }
 
             // optimize to walk headers with an iterator which does not create a new array as getAllHeaders does
             boolean found = false;
-            HeaderIterator it = httpResponse.headerIterator();
+            Iterator<Header> it = httpResponse.headerIterator();
             while (it.hasNext()) {
-                Header header = it.nextHeader();
+                Header header = it.next();
                 String name = header.getName();
                 String value = header.getValue();
                 if (cookieHeaders != null) {
@@ -372,8 +404,12 @@ public class HttpProducer extends DefaultProducer {
                 }
             }
             // handle cookies
-            if (getEndpoint().getCookieHandler() != null) {
-                getEndpoint().getCookieHandler().storeCookies(exchange, httpRequest.getURI(), cookieHeaders);
+            if (cookieHandler != null) {
+                try {
+                    cookieHandler.storeCookies(exchange, httpRequest.getUri(), cookieHeaders);
+                } catch (URISyntaxException e) {
+                    throw new RuntimeCamelException(e);
+                }
             }
         }
 
@@ -386,26 +422,30 @@ public class HttpProducer extends DefaultProducer {
     }
 
     protected Exception populateHttpOperationFailedException(
-            Exchange exchange, HttpRequestBase httpRequest, HttpResponse httpResponse, int responseCode)
+            Exchange exchange, HttpUriRequest httpRequest, ClassicHttpResponse httpResponse, int responseCode)
             throws IOException, ClassNotFoundException {
         Exception answer;
 
-        String uri = httpRequest.getURI().toString();
-        String statusText = httpResponse.getStatusLine() != null ? httpResponse.getStatusLine().getReasonPhrase() : null;
-        Map<String, String> headers = extractResponseHeaders(httpResponse.getAllHeaders());
+        String statusText = httpResponse.getReasonPhrase() != null ? httpResponse.getReasonPhrase() : null;
+        Map<String, String> headers = extractResponseHeaders(httpResponse.getHeaders());
         // handle cookies
-        if (getEndpoint().getCookieHandler() != null) {
+        CookieHandler cookieHandler = getEndpoint().getCookieHandler();
+        if (cookieHandler != null) {
             Map<String, List<String>> m = new HashMap<>();
             for (Entry<String, String> e : headers.entrySet()) {
                 m.put(e.getKey(), Collections.singletonList(e.getValue()));
             }
-            getEndpoint().getCookieHandler().storeCookies(exchange, httpRequest.getURI(), m);
+            try {
+                cookieHandler.storeCookies(exchange, httpRequest.getUri(), m);
+            } catch (URISyntaxException e) {
+                throw new RuntimeCamelException(e);
+            }
         }
 
         Object responseBody = extractResponseBody(httpResponse, exchange, getEndpoint().isIgnoreResponseBody());
-        if (transferException && responseBody instanceof Exception) {
+        if (transferException && responseBody instanceof Exception ex) {
             // if the response was a serialized exception then use that
-            return (Exception) responseBody;
+            return ex;
         }
 
         // make a defensive copy of the response body in the exception so its detached from the cache
@@ -415,10 +455,16 @@ public class HttpProducer extends DefaultProducer {
         }
 
         Header locationHeader = httpResponse.getFirstHeader("location");
-        if (locationHeader != null && responseCode >= 300 && responseCode < 400) {
-            answer = new HttpOperationFailedException(uri, responseCode, statusText, locationHeader.getValue(), headers, copy);
-        } else {
-            answer = new HttpOperationFailedException(uri, responseCode, statusText, null, headers, copy);
+        try {
+            String uri = httpRequest.getUri().toString();
+            if (locationHeader != null && responseCode >= 300 && responseCode < 400) {
+                answer = new HttpOperationFailedException(
+                        uri, responseCode, statusText, locationHeader.getValue(), headers, copy);
+            } else {
+                answer = new HttpOperationFailedException(uri, responseCode, statusText, null, headers, copy);
+            }
+        } catch (URISyntaxException e) {
+            throw new RuntimeCamelException(e);
         }
 
         return answer;
@@ -429,30 +475,28 @@ public class HttpProducer extends DefaultProducer {
      *
      * @param  httpHost    the http host to call
      * @param  httpRequest the http request to execute
+     * @param  handler     the response handler
      * @return             the response
      * @throws IOException can be thrown
      */
-    protected HttpResponse executeMethod(HttpHost httpHost, HttpUriRequest httpRequest) throws IOException {
-        HttpContext localContext = new BasicHttpContext();
-        if (getEndpoint().isAuthenticationPreemptive()) {
-            BasicScheme basicAuth = new BasicScheme();
-            localContext.setAttribute("preemptive-auth", basicAuth);
-        }
+    protected <T> T executeMethod(HttpHost httpHost, HttpUriRequest httpRequest, HttpClientResponseHandler<T> handler)
+            throws IOException {
+        HttpContext localContext = HttpClientContext.create();
         if (httpContext != null) {
             localContext = new BasicHttpContext(httpContext);
         }
-        return httpClient.execute(httpHost, httpRequest, localContext);
+        return httpClient.execute(httpHost, httpRequest, localContext, handler);
     }
 
     /**
      * Extracts the response headers
      *
      * @param  responseHeaders the headers
-     * @return                 the extracted headers or <tt>null</tt> if no headers existed
+     * @return                 the extracted headers or an empty map if no headers existed
      */
     protected static Map<String, String> extractResponseHeaders(Header[] responseHeaders) {
         if (responseHeaders == null || responseHeaders.length == 0) {
-            return null;
+            return Map.of();
         }
 
         Map<String, String> answer = new HashMap<>();
@@ -467,7 +511,7 @@ public class HttpProducer extends DefaultProducer {
      * Extracts the response from the method as a InputStream.
      */
     protected Object extractResponseBody(
-            HttpResponse httpResponse, Exchange exchange, boolean ignoreResponseBody)
+            ClassicHttpResponse httpResponse, Exchange exchange, boolean ignoreResponseBody)
             throws IOException, ClassNotFoundException {
         HttpEntity entity = httpResponse.getEntity();
         if (entity == null) {
@@ -562,11 +606,15 @@ public class HttpProducer extends DefaultProducer {
     /**
      * Creates the HttpHost to use to call the remote server
      */
-    protected HttpHost createHost(HttpRequestBase httpRequest) {
-        if (httpRequest.getURI() == defaultUri) {
-            return defaultHttpHost;
-        } else {
-            return URIUtils.extractHost(httpRequest.getURI());
+    protected HttpHost createHost(HttpUriRequest httpRequest) {
+        try {
+            URI uri = httpRequest.getUri();
+            if (uri.equals(defaultUri)) {
+                return defaultHttpHost;
+            }
+            return HttpHost.create(uri);
+        } catch (URISyntaxException e) {
+            throw new RuntimeCamelException(e);
         }
     }
 
@@ -578,7 +626,7 @@ public class HttpProducer extends DefaultProducer {
      * @throws URISyntaxException is thrown if the URI is invalid
      * @throws Exception          is thrown if error creating RequestEntity
      */
-    protected HttpRequestBase createMethod(Exchange exchange) throws Exception {
+    protected HttpUriRequest createMethod(Exchange exchange) throws Exception {
         if (defaultUri == null || defaultUrl == null) {
             throw new IllegalArgumentException("Producer must be started");
         }
@@ -614,15 +662,12 @@ public class HttpProducer extends DefaultProducer {
 
         // create http holder objects for the request
         HttpMethods methodToUse = HttpMethodHelper.createMethod(exchange, getEndpoint());
-        HttpRequestBase method = methodToUse.createMethod(uri);
+        HttpUriRequest method = methodToUse.createMethod(uri);
 
         // special for HTTP DELETE/GET if the message body should be included
-        if (getEndpoint().isDeleteWithBody() && "DELETE".equals(method.getMethod())) {
-            HttpEntity requestEntity = createRequestEntity(exchange);
-            method = new HttpDeleteWithBodyMethod(uri, requestEntity);
-        } else if (getEndpoint().isGetWithBody() && "GET".equals(method.getMethod())) {
-            HttpEntity requestEntity = createRequestEntity(exchange);
-            method = new HttpGetWithBodyMethod(uri, requestEntity);
+        if (getEndpoint().isDeleteWithBody() && "DELETE".equals(method.getMethod())
+                || getEndpoint().isGetWithBody() && "GET".equals(method.getMethod())) {
+            method.setEntity(createRequestEntity(exchange));
         }
 
         LOG.trace("Using URL: {} with method: {}", url, method);
@@ -630,14 +675,14 @@ public class HttpProducer extends DefaultProducer {
         if (methodToUse.isEntityEnclosing()) {
             // only create entity for http payload if the HTTP method carries payload (such as POST)
             HttpEntity requestEntity = createRequestEntity(exchange);
-            ((HttpEntityEnclosingRequestBase) method).setEntity(requestEntity);
+            method.setEntity(requestEntity);
             if (requestEntity != null && requestEntity.getContentType() == null) {
                 LOG.debug("No Content-Type provided for URL: {} with exchange: {}", url, exchange);
             }
         }
 
         // there must be a host on the method
-        if (method.getURI().getScheme() == null || method.getURI().getHost() == null) {
+        if (uri.getScheme() == null || uri.getHost() == null) {
             throw new IllegalArgumentException(
                     "Invalid url: " + url + ". If you are forwarding/bridging http endpoints, then enable the bridgeEndpoint option on the endpoint: "
                                                + getEndpoint());
@@ -661,15 +706,15 @@ public class HttpProducer extends DefaultProducer {
         try {
             if (body == null) {
                 return null;
-            } else if (body instanceof HttpEntity) {
-                answer = (HttpEntity) body;
+            } else if (body instanceof HttpEntity entity) {
+                answer = entity;
                 // special optimized for using these 3 type converters for common message payload types
-            } else if (body instanceof byte[]) {
-                answer = HttpEntityConverter.toHttpEntity((byte[]) body, exchange);
-            } else if (body instanceof InputStream) {
-                answer = HttpEntityConverter.toHttpEntity((InputStream) body, exchange);
-            } else if (body instanceof String) {
-                answer = HttpEntityConverter.toHttpEntity((String) body, exchange);
+            } else if (body instanceof byte[] bytes) {
+                answer = HttpEntityConverter.toHttpEntity(bytes, exchange);
+            } else if (body instanceof InputStream is) {
+                answer = HttpEntityConverter.toHttpEntity(is, exchange);
+            } else if (body instanceof String content) {
+                answer = HttpEntityConverter.toHttpEntity(content, exchange);
             }
         } catch (Exception e) {
             throw new CamelExchangeException("Error creating RequestEntity from message body", exchange, e);
@@ -698,30 +743,24 @@ public class HttpProducer extends DefaultProducer {
                             && HttpConstants.CONTENT_TYPE_JAVA_SERIALIZED_OBJECT.equals(contentTypeString)) {
                         if (!getEndpoint().getComponent().isAllowJavaSerializedObject()) {
                             throw new CamelExchangeException(
-                                    "Content-type " + org.apache.camel.http.common.HttpConstants.CONTENT_TYPE_JAVA_SERIALIZED_OBJECT
+                                    "Content-type " + HttpConstants.CONTENT_TYPE_JAVA_SERIALIZED_OBJECT
                                                              + " is not allowed",
                                     exchange);
                         }
                         // serialized java object
                         Serializable obj = in.getMandatoryBody(Serializable.class);
                         // write object to output stream
-                        ByteArrayOutputStream bos = new ByteArrayOutputStream();
-                        HttpHelper.writeObjectToStream(bos, obj);
-                        ByteArrayEntity entity = new ByteArrayEntity(bos.toByteArray());
-                        entity.setContentType(HttpConstants.CONTENT_TYPE_JAVA_SERIALIZED_OBJECT);
-                        IOHelper.close(bos);
-                        answer = entity;
+                        try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) {
+                            HttpHelper.writeObjectToStream(bos, obj);
+                            answer = new ByteArrayEntity(bos.toByteArray(), HttpConstants.JAVA_SERIALIZED_OBJECT);
+                        }
                     } else if (data instanceof File || data instanceof GenericFile) {
                         // file based (could potentially also be a FTP file etc)
                         File file = in.getBody(File.class);
                         if (file != null) {
-                            if (contentType != null) {
-                                answer = new FileEntity(file, contentType);
-                            } else {
-                                answer = new FileEntity(file);
-                            }
+                            answer = new FileEntity(file, contentType);
                         }
-                    } else if (data instanceof String) {
+                    } else if (data instanceof String content) {
                         // be a bit careful with String as any type can most likely be converted to String
                         // so we only do an instanceof check and accept String if the body is really a String
                         // do not fallback to use the default charset as it can influence the request
@@ -734,8 +773,14 @@ public class HttpProducer extends DefaultProducer {
                                 charset = cs.name();
                             }
                         }
-                        StringEntity entity = new StringEntity((String) data, charset);
-                        entity.setContentType(contentType != null ? contentType.toString() : null);
+                        final StringEntity entity;
+                        if (contentType != null) {
+                            entity = new StringEntity(content, contentType);
+                        } else if (charset != null) {
+                            entity = new StringEntity(content, null, charset, false);
+                        } else {
+                            entity = new StringEntity(content, null, null, false);
+                        }
                         answer = entity;
                     }
 
@@ -744,11 +789,8 @@ public class HttpProducer extends DefaultProducer {
                         // force the body as an input stream since this is the fallback
                         InputStream is = in.getMandatoryBody(InputStream.class);
 
-                        InputStreamEntity entity = new InputStreamEntity(is, -1);
+                        InputStreamEntity entity = new InputStreamEntity(is, -1, contentType);
 
-                        if (contentType != null) {
-                            entity.setContentType(contentType.toString());
-                        }
                         answer = entity;
                     }
                 }
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpUtil.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpUtil.java
index 9922e9eb2f9..212f7642429 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpUtil.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpUtil.java
@@ -18,8 +18,8 @@ package org.apache.camel.component.http;
 
 import java.util.Optional;
 
-import org.apache.http.Header;
-import org.apache.http.HttpResponse;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpResponse;
 
 public final class HttpUtil {
     private HttpUtil() {
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/NoopCookieStore.java b/components/camel-http/src/main/java/org/apache/camel/component/http/NoopCookieStore.java
index 759a557cf28..d9480ac3fbe 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/NoopCookieStore.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/NoopCookieStore.java
@@ -20,8 +20,8 @@ import java.util.Collections;
 import java.util.Date;
 import java.util.List;
 
-import org.apache.http.client.CookieStore;
-import org.apache.http.cookie.Cookie;
+import org.apache.hc.client5.http.cookie.Cookie;
+import org.apache.hc.client5.http.cookie.CookieStore;
 
 /**
  * A noop {@link CookieStore} used when bridging endpoints.
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/PreemptiveAuthExecChainHandler.java b/components/camel-http/src/main/java/org/apache/camel/component/http/PreemptiveAuthExecChainHandler.java
new file mode 100644
index 00000000000..cbfe6126c94
--- /dev/null
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/PreemptiveAuthExecChainHandler.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.http;
+
+import java.io.IOException;
+
+import org.apache.hc.client5.http.auth.AuthCache;
+import org.apache.hc.client5.http.auth.AuthScope;
+import org.apache.hc.client5.http.auth.Credentials;
+import org.apache.hc.client5.http.auth.CredentialsProvider;
+import org.apache.hc.client5.http.classic.ExecChain;
+import org.apache.hc.client5.http.classic.ExecChainHandler;
+import org.apache.hc.client5.http.impl.auth.BasicAuthCache;
+import org.apache.hc.client5.http.impl.auth.BasicScheme;
+import org.apache.hc.client5.http.protocol.HttpClientContext;
+import org.apache.hc.core5.http.ClassicHttpRequest;
+import org.apache.hc.core5.http.ClassicHttpResponse;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpHost;
+
+public class PreemptiveAuthExecChainHandler implements ExecChainHandler {
+
+    @Override
+    public ClassicHttpResponse execute(
+            ClassicHttpRequest request,
+            ExecChain.Scope scope,
+            ExecChain chain)
+            throws IOException, HttpException {
+
+        HttpClientContext context = scope.clientContext;
+        AuthCache authCache = context.getAuthCache();
+        // If no auth scheme available yet, try to initialize it preemptively
+        if (authCache == null) {
+            CredentialsProvider credentialsProvider = context.getCredentialsProvider();
+            HttpHost httpHost = scope.route.getTargetHost();
+            Credentials credentials = credentialsProvider.getCredentials(new AuthScope(httpHost), context);
+            if (credentials == null) {
+                throw new HttpException("No credentials for preemptive authentication");
+            }
+            BasicScheme authScheme = new BasicScheme();
+            authScheme.initPreemptive(credentials);
+            authCache = new BasicAuthCache();
+            authCache.put(httpHost, authScheme);
+            context.setAuthCache(authCache);
+        }
+        return chain.proceed(request, scope);
+    }
+}
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/PreemptiveAuthInterceptor.java b/components/camel-http/src/main/java/org/apache/camel/component/http/PreemptiveAuthInterceptor.java
deleted file mode 100644
index 4e5174987ed..00000000000
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/PreemptiveAuthInterceptor.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.http;
-
-import java.io.IOException;
-
-import org.apache.http.HttpException;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpRequestInterceptor;
-import org.apache.http.auth.AuthScheme;
-import org.apache.http.auth.AuthScope;
-import org.apache.http.auth.AuthState;
-import org.apache.http.auth.Credentials;
-import org.apache.http.client.CredentialsProvider;
-import org.apache.http.client.protocol.HttpClientContext;
-import org.apache.http.protocol.HttpContext;
-
-public class PreemptiveAuthInterceptor implements HttpRequestInterceptor {
-
-    @Override
-    public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException {
-        AuthState authState = (AuthState) context.getAttribute(HttpClientContext.TARGET_AUTH_STATE);
-        // If no auth scheme avaialble yet, try to initialize it preemptively
-        if (authState.getAuthScheme() == null) {
-            AuthScheme authScheme = (AuthScheme) context.getAttribute("preemptive-auth");
-            CredentialsProvider credsProvider = (CredentialsProvider) context.getAttribute(HttpClientContext.CREDS_PROVIDER);
-            if (authScheme != null) {
-                Credentials creds = credsProvider.getCredentials(AuthScope.ANY);
-                if (creds == null) {
-                    throw new HttpException("No credentials for preemptive authentication");
-                }
-                authState.update(authScheme, creds);
-            }
-        }
-
-    }
-}
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/ProxyHttpClientConfigurer.java b/components/camel-http/src/main/java/org/apache/camel/component/http/ProxyHttpClientConfigurer.java
index 8bf0c1bfad2..3b480d734a4 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/ProxyHttpClientConfigurer.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/ProxyHttpClientConfigurer.java
@@ -16,11 +16,11 @@
  */
 package org.apache.camel.component.http;
 
-import org.apache.http.HttpHost;
-import org.apache.http.auth.Credentials;
-import org.apache.http.auth.NTCredentials;
-import org.apache.http.auth.UsernamePasswordCredentials;
-import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.hc.client5.http.auth.Credentials;
+import org.apache.hc.client5.http.auth.NTCredentials;
+import org.apache.hc.client5.http.auth.UsernamePasswordCredentials;
+import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
+import org.apache.hc.core5.http.HttpHost;
 
 /**
  * Strategy for configuring the HttpClient with a proxy
@@ -31,7 +31,7 @@ public class ProxyHttpClientConfigurer implements HttpClientConfigurer {
     private final Integer port;
     private final String scheme;
     private final String username;
-    private final String password;
+    private final char[] password;
     private final String domain;
     private final String ntHost;
     private final HttpCredentialsHelper credentialsHelper;
@@ -46,7 +46,7 @@ public class ProxyHttpClientConfigurer implements HttpClientConfigurer {
         this.port = port;
         this.scheme = scheme;
         this.username = username;
-        this.password = password;
+        this.password = password == null ? new char[0] : password.toCharArray();
         this.domain = domain;
         this.ntHost = ntHost;
         this.credentialsHelper = credentialsHelper;
@@ -54,7 +54,7 @@ public class ProxyHttpClientConfigurer implements HttpClientConfigurer {
 
     @Override
     public void configureHttpClient(HttpClientBuilder clientBuilder) {
-        clientBuilder.setProxy(new HttpHost(host, port, scheme));
+        clientBuilder.setProxy(new HttpHost(scheme, host, port));
 
         if (username != null && password != null) {
             Credentials defaultcreds;
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/BaseHttpTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/BaseHttpTest.java
index 9fdd72d3df2..0a7e3238ab8 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/BaseHttpTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/BaseHttpTest.java
@@ -20,21 +20,21 @@ import java.util.Map;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
-import org.apache.http.HttpStatus;
+import org.apache.hc.core5.http.HttpStatus;
 
-import static org.apache.http.HttpHeaders.CONTENT_LENGTH;
-import static org.apache.http.HttpHeaders.CONTENT_TYPE;
+import static org.apache.hc.core5.http.HttpHeaders.CONTENT_LENGTH;
+import static org.apache.hc.core5.http.HttpHeaders.CONTENT_TYPE;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNull;
 
 public abstract class BaseHttpTest extends HttpServerTestSupport {
 
     protected void assertExchange(Exchange exchange) {
         assertNotNull(exchange);
-
-        assertTrue(exchange.hasOut());
+        assertNull(exchange.getException());
         Message out = exchange.getMessage();
+        assertNotNull(out);
         assertHeaders(out.getHeaders());
         assertBody(out.getBody(String.class));
     }
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/BaseHttpsTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/BaseHttpsTest.java
index e09042f449b..1b51e3e17e7 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/BaseHttpsTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/BaseHttpsTest.java
@@ -20,18 +20,19 @@ import java.util.Map;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
-import org.apache.http.HttpStatus;
+import org.apache.hc.core5.http.HttpStatus;
 
-import static org.apache.http.HttpHeaders.CONTENT_LENGTH;
-import static org.apache.http.HttpHeaders.CONTENT_TYPE;
+import static org.apache.hc.core5.http.HttpHeaders.CONTENT_LENGTH;
+import static org.apache.hc.core5.http.HttpHeaders.CONTENT_TYPE;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
 
 public abstract class BaseHttpsTest extends HttpsServerTestSupport {
 
     protected void assertExchange(Exchange exchange) {
         assertNotNull(exchange);
-
+        assertNull(exchange.getException());
         Message out = exchange.getMessage();
         assertNotNull(out);
         assertHeaders(out.getHeaders());
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/CamelComponentVerifierExtensionTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/CamelComponentVerifierExtensionTest.java
index a0fa90a3756..2ba4779bb71 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/CamelComponentVerifierExtensionTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/CamelComponentVerifierExtensionTest.java
@@ -25,15 +25,15 @@ import org.apache.camel.Component;
 import org.apache.camel.component.extension.ComponentVerifierExtension;
 import org.apache.camel.component.http.handler.AuthenticationValidationHandler;
 import org.apache.camel.component.http.handler.BasicValidationHandler;
-import org.apache.http.HttpStatus;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
-import org.apache.http.localserver.RequestBasicAuth;
-import org.apache.http.localserver.ResponseBasicUnauthorized;
-import org.apache.http.protocol.HttpProcessor;
-import org.apache.http.protocol.HttpRequestHandler;
-import org.apache.http.protocol.ImmutableHttpProcessor;
-import org.apache.http.protocol.ResponseContent;
+import org.apache.camel.component.http.interceptor.RequestBasicAuth;
+import org.apache.camel.component.http.interceptor.ResponseBasicUnauthorized;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.io.HttpRequestHandler;
+import org.apache.hc.core5.http.protocol.DefaultHttpProcessor;
+import org.apache.hc.core5.http.protocol.HttpProcessor;
+import org.apache.hc.core5.http.protocol.ResponseContent;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -56,12 +56,12 @@ public class CamelComponentVerifierExtensionTest extends BaseHttpTest {
 
         localServer = ServerBootstrap.bootstrap()
                 .setHttpProcessor(getHttpProcessor())
-                .registerHandler("/basic", new BasicValidationHandler(GET.name(), null, null, getExpectedContent()))
-                .registerHandler("/auth",
+                .register("/basic", new BasicValidationHandler(GET.name(), null, null, getExpectedContent()))
+                .register("/auth",
                         new AuthenticationValidationHandler(
                                 GET.name(), null, null, getExpectedContent(), AUTH_USERNAME, AUTH_PASSWORD))
-                .registerHandler("/redirect", redirectTo(HttpStatus.SC_MOVED_PERMANENTLY, "/redirected"))
-                .registerHandler("/redirected", new BasicValidationHandler(GET.name(), null, null, getExpectedContent()))
+                .register("/redirect", redirectTo(HttpStatus.SC_MOVED_PERMANENTLY, "/redirected"))
+                .register("/redirected", new BasicValidationHandler(GET.name(), null, null, getExpectedContent()))
                 .create();
 
         localServer.start();
@@ -86,7 +86,7 @@ public class CamelComponentVerifierExtensionTest extends BaseHttpTest {
     }
 
     private HttpProcessor getHttpProcessor() {
-        return new ImmutableHttpProcessor(
+        return new DefaultHttpProcessor(
                 Collections.singletonList(
                         new RequestBasicAuth()),
                 Arrays.asList(
@@ -99,9 +99,7 @@ public class CamelComponentVerifierExtensionTest extends BaseHttpTest {
     // *************************************************
 
     protected String getLocalServerUri(String contextPath) {
-        return "http://"
-               + localServer.getInetAddress().getHostName()
-               + ":"
+        return "http://localhost:"
                + localServer.getLocalPort()
                + (contextPath != null
                        ? contextPath.startsWith("/") ? contextPath : "/" + contextPath
@@ -111,7 +109,7 @@ public class CamelComponentVerifierExtensionTest extends BaseHttpTest {
     private HttpRequestHandler redirectTo(int code, String path) {
         return (request, response, context) -> {
             response.setHeader("location", getLocalServerUri(path));
-            response.setStatusCode(code);
+            response.setCode(code);
         };
     }
 
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/CamelComponentVerifierTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/CamelComponentVerifierTest.java
index aedb39ea67e..82d8e1ffc5f 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/CamelComponentVerifierTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/CamelComponentVerifierTest.java
@@ -24,15 +24,15 @@ import java.util.Map;
 import org.apache.camel.component.extension.ComponentVerifierExtension;
 import org.apache.camel.component.http.handler.AuthenticationValidationHandler;
 import org.apache.camel.component.http.handler.BasicValidationHandler;
-import org.apache.http.HttpStatus;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
-import org.apache.http.localserver.RequestBasicAuth;
-import org.apache.http.localserver.ResponseBasicUnauthorized;
-import org.apache.http.protocol.HttpProcessor;
-import org.apache.http.protocol.HttpRequestHandler;
-import org.apache.http.protocol.ImmutableHttpProcessor;
-import org.apache.http.protocol.ResponseContent;
+import org.apache.camel.component.http.interceptor.RequestBasicAuth;
+import org.apache.camel.component.http.interceptor.ResponseBasicUnauthorized;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.io.HttpRequestHandler;
+import org.apache.hc.core5.http.protocol.DefaultHttpProcessor;
+import org.apache.hc.core5.http.protocol.HttpProcessor;
+import org.apache.hc.core5.http.protocol.ResponseContent;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -55,12 +55,12 @@ public class CamelComponentVerifierTest extends BaseHttpTest {
 
         localServer = ServerBootstrap.bootstrap()
                 .setHttpProcessor(getHttpProcessor())
-                .registerHandler("/basic", new BasicValidationHandler(GET.name(), null, null, getExpectedContent()))
-                .registerHandler("/auth",
+                .register("/basic", new BasicValidationHandler(GET.name(), null, null, getExpectedContent()))
+                .register("/auth",
                         new AuthenticationValidationHandler(
                                 GET.name(), null, null, getExpectedContent(), AUTH_USERNAME, AUTH_PASSWORD))
-                .registerHandler("/redirect", redirectTo(HttpStatus.SC_MOVED_PERMANENTLY, "/redirected"))
-                .registerHandler("/redirected", new BasicValidationHandler(GET.name(), null, null, getExpectedContent()))
+                .register("/redirect", redirectTo(HttpStatus.SC_MOVED_PERMANENTLY, "/redirected"))
+                .register("/redirected", new BasicValidationHandler(GET.name(), null, null, getExpectedContent()))
                 .create();
 
         localServer.start();
@@ -85,7 +85,7 @@ public class CamelComponentVerifierTest extends BaseHttpTest {
     }
 
     private HttpProcessor getHttpProcessor() {
-        return new ImmutableHttpProcessor(
+        return new DefaultHttpProcessor(
                 Collections.singletonList(
                         new RequestBasicAuth()),
                 Arrays.asList(
@@ -98,9 +98,7 @@ public class CamelComponentVerifierTest extends BaseHttpTest {
     // *************************************************
 
     protected String getLocalServerUri(String contextPath) {
-        return "http://"
-               + localServer.getInetAddress().getHostName()
-               + ":"
+        return "http://localhost:"
                + localServer.getLocalPort()
                + (contextPath != null
                        ? contextPath.startsWith("/") ? contextPath : "/" + contextPath
@@ -110,7 +108,7 @@ public class CamelComponentVerifierTest extends BaseHttpTest {
     private HttpRequestHandler redirectTo(int code, String path) {
         return (request, response, context) -> {
             response.setHeader("location", getLocalServerUri(path));
-            response.setStatusCode(code);
+            response.setCode(code);
         };
     }
 
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/FollowRedirectTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/FollowRedirectTest.java
index 0e604c98ec6..d39e2c0cdb0 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/FollowRedirectTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/FollowRedirectTest.java
@@ -18,8 +18,8 @@ package org.apache.camel.component.http;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.component.http.handler.BasicValidationHandler;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -35,11 +35,11 @@ public class FollowRedirectTest extends BaseHttpTest {
     public void setUp() throws Exception {
         localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
                 .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
-                .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext())
-                .registerHandler("/someplaceelse", new BasicValidationHandler(GET.name(), null, null, "Bye World"))
-                .registerHandler("/redirect", (request, response, context) -> {
+                .setSslContext(getSSLContext())
+                .register("/someplaceelse", new BasicValidationHandler(GET.name(), null, null, "Bye World"))
+                .register("/redirect", (request, response, context) -> {
                     response.setHeader("Location", "someplaceelse");
-                    response.setStatusCode(303);
+                    response.setCode(303);
                 }).create();
         localServer.start();
 
@@ -51,7 +51,7 @@ public class FollowRedirectTest extends BaseHttpTest {
         HttpComponent http = context.getComponent("http", HttpComponent.class);
         http.setFollowRedirects(true);
 
-        String uri = "http://" + localServer.getInetAddress().getHostName() + ":" + localServer.getLocalPort() + "/redirect";
+        String uri = "http://localhost:" + localServer.getLocalPort() + "/redirect";
         Exchange out = fluentTemplate.to(uri).send();
 
         Assertions.assertEquals(200, out.getMessage().getHeader(Exchange.HTTP_RESPONSE_CODE));
@@ -64,7 +64,7 @@ public class FollowRedirectTest extends BaseHttpTest {
         HttpComponent http = context.getComponent("http", HttpComponent.class);
         http.setFollowRedirects(false);
 
-        String uri = "http://" + localServer.getInetAddress().getHostName() + ":" + localServer.getLocalPort()
+        String uri = "http://localhost:" + localServer.getLocalPort()
                      + "/redirect?throwExceptionOnFailure=false";
         Exchange out = fluentTemplate.to(uri).send();
 
@@ -76,7 +76,7 @@ public class FollowRedirectTest extends BaseHttpTest {
         HttpComponent http = context.getComponent("http", HttpComponent.class);
         http.setRedirectHandlingDisabled(false);
 
-        String uri = "http://" + localServer.getInetAddress().getHostName() + ":" + localServer.getLocalPort()
+        String uri = "http://localhost:" + localServer.getLocalPort()
                      + "/redirect?throwExceptionOnFailure=false";
         Exchange out = fluentTemplate.to(uri).send();
 
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HeaderFilteringTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HeaderFilteringTest.java
index 195aecd55aa..611387fec5c 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HeaderFilteringTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HeaderFilteringTest.java
@@ -38,9 +38,9 @@ import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
+import static com.github.dockerjava.zerodep.shaded.org.apache.hc.core5.http.ContentType.APPLICATION_JSON;
 import static org.apache.camel.component.http.HttpMethods.POST;
-import static org.apache.http.HttpHeaders.HOST;
-import static org.apache.http.entity.ContentType.APPLICATION_JSON;
+import static org.apache.hc.core5.http.HttpHeaders.HOST;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.fail;
 
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpAuthenticationTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpAuthenticationTest.java
index baedef0cef0..9b37bd0d640 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpAuthenticationTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpAuthenticationTest.java
@@ -23,22 +23,22 @@ import java.util.Map;
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.apache.camel.component.http.handler.AuthenticationValidationHandler;
-import org.apache.http.HttpRequestInterceptor;
-import org.apache.http.HttpResponseInterceptor;
-import org.apache.http.HttpStatus;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
-import org.apache.http.localserver.RequestBasicAuth;
-import org.apache.http.localserver.ResponseBasicUnauthorized;
-import org.apache.http.protocol.HttpProcessor;
-import org.apache.http.protocol.ImmutableHttpProcessor;
-import org.apache.http.protocol.ResponseContent;
+import org.apache.camel.component.http.interceptor.RequestBasicAuth;
+import org.apache.camel.component.http.interceptor.ResponseBasicUnauthorized;
+import org.apache.hc.core5.http.HttpRequestInterceptor;
+import org.apache.hc.core5.http.HttpResponseInterceptor;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.protocol.DefaultHttpProcessor;
+import org.apache.hc.core5.http.protocol.HttpProcessor;
+import org.apache.hc.core5.http.protocol.ResponseContent;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
 import static org.apache.camel.component.http.HttpMethods.GET;
-import static org.apache.http.HttpHeaders.CONTENT_TYPE;
+import static org.apache.hc.core5.http.HttpHeaders.CONTENT_TYPE;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertNull;
@@ -47,16 +47,16 @@ public class HttpAuthenticationTest extends BaseHttpTest {
 
     private HttpServer localServer;
 
-    private String user = "camel";
-    private String password = "password";
+    private final String user = "camel";
+    private final String password = "password";
 
     @BeforeEach
     @Override
     public void setUp() throws Exception {
         localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
                 .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
-                .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext())
-                .registerHandler("/search",
+                .setSslContext(getSSLContext())
+                .register("/search",
                         new AuthenticationValidationHandler(GET.name(), null, null, getExpectedContent(), user, password))
                 .create();
         localServer.start();
@@ -76,7 +76,7 @@ public class HttpAuthenticationTest extends BaseHttpTest {
 
     @Test
     public void basicAuthenticationShouldSuccess() throws Exception {
-        Exchange exchange = template.request("http://" + localServer.getInetAddress().getHostName() + ":"
+        Exchange exchange = template.request("http://localhost:"
                                              + localServer.getLocalPort() + "/search?authUsername=" + user + "&authPassword="
                                              + password,
                 exchange1 -> {
@@ -87,7 +87,7 @@ public class HttpAuthenticationTest extends BaseHttpTest {
 
     @Test
     public void basicAuthenticationPreemptiveShouldSuccess() throws Exception {
-        Exchange exchange = template.request("http://" + localServer.getInetAddress().getHostName() + ":"
+        Exchange exchange = template.request("http://localhost:"
                                              + localServer.getLocalPort() + "/search?authUsername=" + user + "&authPassword="
                                              + password + "&authenticationPreemptive=true",
                 exchange1 -> {
@@ -99,7 +99,7 @@ public class HttpAuthenticationTest extends BaseHttpTest {
     @Test
     public void basicAuthenticationShouldFailWithoutCreds() throws Exception {
         Exchange exchange
-                = template.request("http://" + localServer.getInetAddress().getHostName() + ":" + localServer.getLocalPort()
+                = template.request("http://localhost:" + localServer.getLocalPort()
                                    + "/search?throwExceptionOnFailure=false",
                         exchange1 -> {
                         });
@@ -110,7 +110,7 @@ public class HttpAuthenticationTest extends BaseHttpTest {
     @Test
     public void basicAuthenticationShouldFailWithWrongCreds() throws Exception {
         Exchange exchange = template
-                .request("http://" + localServer.getInetAddress().getHostName() + ":" + localServer.getLocalPort()
+                .request("http://localhost:" + localServer.getLocalPort()
                          + "/search?throwExceptionOnFailure=false&authUsername=camel&authPassword=wrong",
                         exchange1 -> {
                         });
@@ -126,7 +126,7 @@ public class HttpAuthenticationTest extends BaseHttpTest {
         responseInterceptors.add(new ResponseContent());
         responseInterceptors.add(new ResponseBasicUnauthorized());
 
-        return new ImmutableHttpProcessor(requestInterceptors, responseInterceptors);
+        return new DefaultHttpProcessor(requestInterceptors, responseInterceptors);
     }
 
     protected void assertExchangeFailed(Exchange exchange) {
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpBodyTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpBodyTest.java
index 9fb2d683b69..5dd95a5a2e5 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpBodyTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpBodyTest.java
@@ -24,20 +24,20 @@ import java.util.Map;
 import org.apache.camel.Exchange;
 import org.apache.camel.component.http.handler.BasicValidationHandler;
 import org.apache.camel.component.http.handler.HeaderValidationHandler;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
+import static com.github.dockerjava.zerodep.shaded.org.apache.hc.core5.http.ContentType.IMAGE_JPEG;
 import static org.apache.camel.component.http.HttpMethods.POST;
-import static org.apache.http.HttpHeaders.CONTENT_TYPE;
-import static org.apache.http.entity.ContentType.IMAGE_JPEG;
+import static org.apache.hc.core5.http.HttpHeaders.CONTENT_TYPE;
 
 public class HttpBodyTest extends BaseHttpTest {
     private String protocolString = "http://";
     // default content encoding of the local test server
-    private String charset = "ISO-8859-1";
+    private final String charset = "ISO-8859-1";
     private HttpServer localServer;
     private String endpointUrl;
 
@@ -49,14 +49,14 @@ public class HttpBodyTest extends BaseHttpTest {
 
         localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
                 .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
-                .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext())
-                .registerHandler("/post", new BasicValidationHandler(POST.name(), null, getBody(), getExpectedContent()))
-                .registerHandler("/post1",
+                .setSslContext(getSSLContext())
+                .register("/post", new BasicValidationHandler(POST.name(), null, getBody(), getExpectedContent()))
+                .register("/post1",
                         new HeaderValidationHandler(POST.name(), null, null, getExpectedContent(), expectedHeaders))
                 .create();
         localServer.start();
 
-        endpointUrl = getProtocolString() + localServer.getInetAddress().getHostName() + ":" + localServer.getLocalPort();
+        endpointUrl = getProtocolString() + "localhost:" + localServer.getLocalPort();
 
         super.setUp();
     }
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpBodyWithOtherProtocalNameTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpBodyWithOtherProtocolNameTest.java
similarity index 90%
rename from components/camel-http/src/test/java/org/apache/camel/component/http/HttpBodyWithOtherProtocalNameTest.java
rename to components/camel-http/src/test/java/org/apache/camel/component/http/HttpBodyWithOtherProtocolNameTest.java
index 5fd61a4248c..39857c3f580 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpBodyWithOtherProtocalNameTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpBodyWithOtherProtocolNameTest.java
@@ -19,7 +19,7 @@ package org.apache.camel.component.http;
 import org.apache.camel.CamelContext;
 import org.junit.jupiter.api.BeforeEach;
 
-public class HttpBodyWithOtherProtocalNameTest extends HttpBodyTest {
+public class HttpBodyWithOtherProtocolNameTest extends HttpBodyTest {
 
     @BeforeEach
     @Override
@@ -31,7 +31,7 @@ public class HttpBodyWithOtherProtocalNameTest extends HttpBodyTest {
     @Override
     public CamelContext createCamelContext() throws Exception {
         CamelContext answer = super.createCamelContext();
-        // register the a new HttpComponent with different protocol name
+        // register a new HttpComponent with different protocol name
         answer.addComponent("newHttp", new HttpComponent());
         return answer;
     }
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpBridgeEndpointTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpBridgeEndpointTest.java
index 68c7e2612e9..fa2cc3e25f8 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpBridgeEndpointTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpBridgeEndpointTest.java
@@ -19,8 +19,8 @@ package org.apache.camel.component.http;
 import org.apache.camel.Exchange;
 import org.apache.camel.component.http.handler.BasicRawQueryValidationHandler;
 import org.apache.camel.component.http.handler.BasicValidationHandler;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -41,13 +41,13 @@ public class HttpBridgeEndpointTest extends BaseHttpTest {
     public void setUp() throws Exception {
         localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
                 .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
-                .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext())
-                .registerHandler("/", new BasicValidationHandler(GET.name(), null, null, getExpectedContent()))
-                .registerHandler("/query", new BasicRawQueryValidationHandler(GET.name(), "x=%3B", null, getExpectedContent()))
+                .setSslContext(getSSLContext())
+                .register("/", new BasicValidationHandler(GET.name(), null, null, getExpectedContent()))
+                .register("/query", new BasicRawQueryValidationHandler(GET.name(), "x=%3B", null, getExpectedContent()))
                 .create();
         localServer.start();
 
-        url = "http://" + localServer.getInetAddress().getHostName() + ":" + localServer.getLocalPort();
+        url = "http://localhost:" + localServer.getLocalPort();
 
         super.setUp();
     }
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpCamelHeadersNotCopiedTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpCamelHeadersNotCopiedTest.java
index 7ea169d7c6f..0a30c1a0576 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpCamelHeadersNotCopiedTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpCamelHeadersNotCopiedTest.java
@@ -19,7 +19,7 @@ package org.apache.camel.component.http;
 import java.util.Map;
 
 import org.apache.camel.Exchange;
-import org.apache.http.HttpStatus;
+import org.apache.hc.core5.http.HttpStatus;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpCamelHeadersTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpCamelHeadersTest.java
index 67db64685ae..f2716960d0d 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpCamelHeadersTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpCamelHeadersTest.java
@@ -22,19 +22,19 @@ import java.util.Map;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.component.http.handler.HeaderValidationHandler;
-import org.apache.http.HttpException;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
-import org.apache.http.protocol.HttpContext;
+import org.apache.hc.core5.http.ClassicHttpRequest;
+import org.apache.hc.core5.http.ClassicHttpResponse;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.protocol.HttpContext;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
 import static org.apache.camel.component.http.HttpMethods.GET;
-import static org.apache.http.HttpHeaders.ACCEPT_LANGUAGE;
+import static org.apache.hc.core5.http.HttpHeaders.ACCEPT_LANGUAGE;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 
 public class HttpCamelHeadersTest extends BaseHttpTest {
@@ -51,8 +51,8 @@ public class HttpCamelHeadersTest extends BaseHttpTest {
         localServer
                 = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
                         .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
-                        .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext())
-                        .registerHandler("/",
+                        .setSslContext(getSSLContext())
+                        .register("/",
                                 new MyHeaderValidationHandler(GET.name(), "HTTP/1.0", getExpectedContent(), expectedHeaders))
                         .create();
         localServer.start();
@@ -85,9 +85,7 @@ public class HttpCamelHeadersTest extends BaseHttpTest {
 
     private Exchange doExchange() {
         return template.request(
-                "http://"
-                                + localServer.getInetAddress().getHostName()
-                                + ":"
+                "http://localhost:"
                                 + localServer.getLocalPort()
                                 + "/"
                                 + setupEndpointParams(),
@@ -102,8 +100,8 @@ public class HttpCamelHeadersTest extends BaseHttpTest {
         return "";
     }
 
-    private class MyHeaderValidationHandler extends HeaderValidationHandler {
-        private String expectProtocolVersion;
+    private static class MyHeaderValidationHandler extends HeaderValidationHandler {
+        private final String expectProtocolVersion;
 
         MyHeaderValidationHandler(String expectedMethod, String protocolVersion,
                                   String responseContent, Map<String, String> expectedHeaders) {
@@ -113,11 +111,11 @@ public class HttpCamelHeadersTest extends BaseHttpTest {
 
         @Override
         public void handle(
-                final HttpRequest request, final HttpResponse response,
+                final ClassicHttpRequest request, final ClassicHttpResponse response,
                 final HttpContext context)
                 throws HttpException, IOException {
-            if (!expectProtocolVersion.equals(request.getProtocolVersion().toString())) {
-                response.setStatusCode(HttpStatus.SC_HTTP_VERSION_NOT_SUPPORTED);
+            if (!expectProtocolVersion.equals(request.getVersion().toString())) {
+                response.setCode(HttpStatus.SC_HTTP_VERSION_NOT_SUPPORTED);
                 return;
             }
             super.handle(request, response, context);
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpCharsetTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpCharsetTest.java
index 9cfd73b3433..3b0d93d7a5f 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpCharsetTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpCharsetTest.java
@@ -20,8 +20,8 @@ import java.io.ByteArrayInputStream;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.component.http.handler.BasicValidationHandler;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -31,7 +31,7 @@ import static org.apache.camel.component.http.HttpMethods.POST;
 public class HttpCharsetTest extends BaseHttpTest {
 
     // default content encoding of the local test server
-    private String charset = "ISO-8859-1";
+    private final String charset = "ISO-8859-1";
 
     private HttpServer localServer;
 
@@ -40,8 +40,8 @@ public class HttpCharsetTest extends BaseHttpTest {
     public void setUp() throws Exception {
         localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
                 .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
-                .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext())
-                .registerHandler("/", new BasicValidationHandler(POST.name(), null, getBody(), getExpectedContent())).create();
+                .setSslContext(getSSLContext())
+                .register("/", new BasicValidationHandler(POST.name(), null, getBody(), getExpectedContent())).create();
         localServer.start();
 
         super.setUp();
@@ -60,7 +60,7 @@ public class HttpCharsetTest extends BaseHttpTest {
     @Test
     public void sendCharsetInExchangeProperty() throws Exception {
         Exchange exchange = template.request(
-                "http://" + localServer.getInetAddress().getHostName() + ":" + localServer.getLocalPort() + "/", exchange1 -> {
+                "http://localhost:" + localServer.getLocalPort() + "/", exchange1 -> {
                     exchange1.setProperty(Exchange.CHARSET_NAME, charset);
                     exchange1.getIn().setBody(getBody());
                 });
@@ -71,7 +71,7 @@ public class HttpCharsetTest extends BaseHttpTest {
     @Test
     public void sendByteArrayCharsetInExchangeProperty() throws Exception {
         Exchange exchange = template.request(
-                "http://" + localServer.getInetAddress().getHostName() + ":" + localServer.getLocalPort() + "/", exchange1 -> {
+                "http://localhost:" + localServer.getLocalPort() + "/", exchange1 -> {
                     exchange1.setProperty(Exchange.CHARSET_NAME, charset);
                     exchange1.getIn().setBody(getBody().getBytes(charset));
                 });
@@ -82,7 +82,7 @@ public class HttpCharsetTest extends BaseHttpTest {
     @Test
     public void sendInputStreamCharsetInExchangeProperty() throws Exception {
         Exchange exchange = template.request(
-                "http://" + localServer.getInetAddress().getHostName() + ":" + localServer.getLocalPort() + "/", exchange1 -> {
+                "http://localhost:" + localServer.getLocalPort() + "/", exchange1 -> {
                     exchange1.setProperty(Exchange.CHARSET_NAME, charset);
                     exchange1.getIn().setBody(new ByteArrayInputStream(getBody().getBytes(charset)));
                 });
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpCompressionTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpCompressionTest.java
index cc0fa4a2e74..8a1f28db4da 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpCompressionTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpCompressionTest.java
@@ -29,32 +29,32 @@ import java.util.zip.GZIPOutputStream;
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.apache.camel.component.http.handler.HeaderValidationHandler;
-import org.apache.http.Header;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpEntityEnclosingRequest;
-import org.apache.http.HttpException;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpRequestInterceptor;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpResponseInterceptor;
-import org.apache.http.HttpStatus;
-import org.apache.http.entity.HttpEntityWrapper;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
-import org.apache.http.localserver.ResponseBasicUnauthorized;
-import org.apache.http.message.BasicHeader;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.protocol.HttpProcessor;
-import org.apache.http.protocol.ImmutableHttpProcessor;
-import org.apache.http.util.EntityUtils;
+import org.apache.camel.component.http.interceptor.ResponseBasicUnauthorized;
+import org.apache.hc.core5.http.ClassicHttpRequest;
+import org.apache.hc.core5.http.ClassicHttpResponse;
+import org.apache.hc.core5.http.EntityDetails;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpRequestInterceptor;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpResponseInterceptor;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.io.entity.HttpEntityWrapper;
+import org.apache.hc.core5.http.protocol.DefaultHttpProcessor;
+import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.http.protocol.HttpProcessor;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
 import static org.apache.camel.http.common.HttpMethods.POST;
-import static org.apache.http.HttpHeaders.CONTENT_ENCODING;
-import static org.apache.http.HttpHeaders.CONTENT_TYPE;
-import static org.apache.http.entity.ContentType.TEXT_PLAIN;
+import static org.apache.hc.core5.http.ContentType.TEXT_PLAIN;
+import static org.apache.hc.core5.http.HttpHeaders.CONTENT_ENCODING;
+import static org.apache.hc.core5.http.HttpHeaders.CONTENT_TYPE;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 
@@ -71,8 +71,8 @@ public class HttpCompressionTest extends BaseHttpTest {
 
         localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
                 .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
-                .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext())
-                .registerHandler("/",
+                .setSslContext(getSSLContext())
+                .register("/",
                         new HeaderValidationHandler(POST.name(), null, getBody(), getExpectedContent(), expectedHeaders))
                 .create();
         localServer.start();
@@ -93,7 +93,7 @@ public class HttpCompressionTest extends BaseHttpTest {
     @Test
     public void compressedHttpPost() {
         Exchange exchange = template.request(
-                "http://" + localServer.getInetAddress().getHostName() + ":" + localServer.getLocalPort() + "/", exchange1 -> {
+                "http://localhost:" + localServer.getLocalPort() + "/", exchange1 -> {
                     exchange1.getIn().setHeader(Exchange.CONTENT_TYPE, "text/plain");
                     exchange1.getIn().setHeader(Exchange.CONTENT_ENCODING, "gzip");
                     exchange1.getIn().setBody(getBody());
@@ -118,7 +118,7 @@ public class HttpCompressionTest extends BaseHttpTest {
         responseInterceptors.add(new ResponseCompressingInterceptor());
         responseInterceptors.add(new ResponseBasicUnauthorized());
 
-        return new ImmutableHttpProcessor(requestInterceptors, responseInterceptors);
+        return new DefaultHttpProcessor(requestInterceptors, responseInterceptors);
     }
 
     protected String getBody() {
@@ -128,15 +128,14 @@ public class HttpCompressionTest extends BaseHttpTest {
     static class RequestDecompressingInterceptor implements HttpRequestInterceptor {
 
         @Override
-        public void process(HttpRequest request, HttpContext context) throws HttpException, IOException {
+        public void process(HttpRequest request, EntityDetails details, HttpContext context) throws HttpException, IOException {
             Header contentEncoding = request.getFirstHeader(CONTENT_ENCODING);
 
             if (contentEncoding != null
                     && contentEncoding.getValue().equalsIgnoreCase("gzip")) {
-                HttpEntity entity = ((HttpEntityEnclosingRequest) request)
-                        .getEntity();
-                ((HttpEntityEnclosingRequest) request)
-                        .setEntity(new GzipDecompressingEntity(entity));
+                ClassicHttpRequest classicHttpRequest = (ClassicHttpRequest) request;
+                HttpEntity entity = classicHttpRequest.getEntity();
+                classicHttpRequest.setEntity(new GzipDecompressingEntity(entity));
             }
         }
 
@@ -150,8 +149,7 @@ public class HttpCompressionTest extends BaseHttpTest {
             public InputStream getContent()
                     throws IOException,
                     IllegalStateException {
-                InputStream wrappedIn = wrappedEntity.getContent();
-                return new GZIPInputStream(wrappedIn);
+                return new GZIPInputStream(super.getContent());
             }
 
             @Override
@@ -169,10 +167,12 @@ public class HttpCompressionTest extends BaseHttpTest {
     static class ResponseCompressingInterceptor implements HttpResponseInterceptor {
 
         @Override
-        public void process(HttpResponse response, HttpContext context) throws HttpException, IOException {
+        public void process(HttpResponse response, EntityDetails details, HttpContext context)
+                throws HttpException, IOException {
             response.setHeader(CONTENT_ENCODING, "gzip");
-            HttpEntity entity = response.getEntity();
-            response.setEntity(new GzipCompressingEntity(entity));
+            ClassicHttpResponse classicHttpResponse = (ClassicHttpResponse) response;
+            HttpEntity entity = classicHttpResponse.getEntity();
+            classicHttpResponse.setEntity(new GzipCompressingEntity(entity));
         }
 
         static class GzipCompressingEntity extends HttpEntityWrapper {
@@ -182,15 +182,15 @@ public class HttpCompressionTest extends BaseHttpTest {
             }
 
             @Override
-            public Header getContentEncoding() {
-                return new BasicHeader(CONTENT_ENCODING, "gzip");
+            public String getContentEncoding() {
+                return "gzip";
             }
 
             @Override
             public void writeTo(OutputStream outStream) throws IOException {
-                GZIPOutputStream gzip = new GZIPOutputStream(outStream);
-                gzip.write(EntityUtils.toByteArray(wrappedEntity));
-                gzip.close();
+                try (GZIPOutputStream gzip = new GZIPOutputStream(outStream)) {
+                    super.writeTo(gzip);
+                }
             }
 
             @Override
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpConcurrentTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpConcurrentTest.java
index 4ca96c072f3..5250255b0ae 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpConcurrentTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpConcurrentTest.java
@@ -25,10 +25,10 @@ import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
 import java.util.concurrent.atomic.AtomicInteger;
 
-import org.apache.http.HttpStatus;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.io.entity.StringEntity;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -46,14 +46,14 @@ public class HttpConcurrentTest extends BaseHttpTest {
     public void setUp() throws Exception {
         localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
                 .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
-                .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext())
-                .registerHandler("/", (request, response, context) -> {
+                .setSslContext(getSSLContext())
+                .register("/", (request, response, context) -> {
                     try {
                         Thread.sleep(1000);
                     } catch (InterruptedException e) {
                         // ignore
                     }
-                    response.setStatusCode(HttpStatus.SC_OK);
+                    response.setCode(HttpStatus.SC_OK);
                     response.setEntity(new StringEntity("" + counter.incrementAndGet()));
                 }).create();
         localServer.start();
@@ -88,7 +88,7 @@ public class HttpConcurrentTest extends BaseHttpTest {
         Map<Integer, Future<String>> responses = new HashMap<>();
         for (int i = 0; i < files; i++) {
             Future<String> out = executor.submit(() -> template.requestBody(
-                    "http://" + localServer.getInetAddress().getHostName() + ":" + localServer.getLocalPort(), null,
+                    "http://localhost:" + localServer.getLocalPort(), null,
                     String.class));
             responses.put(i, out);
         }
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpCredentialsHelperTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpCredentialsHelperTest.java
index 10e0de90341..84fa60d15f8 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpCredentialsHelperTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpCredentialsHelperTest.java
@@ -17,72 +17,77 @@
 package org.apache.camel.component.http;
 
 import org.apache.camel.test.junit5.CamelTestSupport;
-import org.apache.http.auth.AuthScope;
-import org.apache.http.auth.Credentials;
-import org.apache.http.auth.UsernamePasswordCredentials;
-import org.apache.http.client.CredentialsProvider;
+import org.apache.hc.client5.http.auth.AuthScope;
+import org.apache.hc.client5.http.auth.Credentials;
+import org.apache.hc.client5.http.auth.CredentialsProvider;
+import org.apache.hc.client5.http.auth.UsernamePasswordCredentials;
+import org.apache.hc.core5.http.protocol.BasicHttpContext;
+import org.apache.hc.core5.http.protocol.HttpContext;
 import org.junit.jupiter.api.Test;
 
-import static org.junit.jupiter.api.Assertions.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
 
 class HttpCredentialsHelperTest extends CamelTestSupport {
 
-    HttpCredentialsHelper credentialsHelper = new HttpCredentialsHelper();
+    private final HttpCredentialsHelper credentialsHelper = new HttpCredentialsHelper();
+    private final HttpContext context = new BasicHttpContext();
 
     private final String host = "credentials.test.org";
-    private final Integer port = Integer.valueOf(80);
+    private final Integer port = 80;
     private final String proxyHost = "proxy.test.org";
-    private final Integer proxyPort = Integer.valueOf(8080);
-    private String username = "testUser";
-    private String password = "testPassowrd";
-
-    private String proxyUsername = "proxyUser";
-    private String proxyPassword = "proxyPassowrd";
+    private final Integer proxyPort = 8080;
+    private final String username = "testUser";
+    private final String password = "testPassowrd";
 
     @Test
     void testOneCredential() {
-        Credentials credentials = new UsernamePasswordCredentials(username, password);
+        Credentials credentials = new UsernamePasswordCredentials(username, password.toCharArray());
         CredentialsProvider provider = credentialsHelper.getCredentialsProvider(host, port, credentials);
         assertNotNull(provider);
-        assertEquals(credentials, provider.getCredentials(new AuthScope(host, port)));
+        assertEquals(credentials, provider.getCredentials(new AuthScope(host, port), context));
     }
 
     @Test
     void testCredentialsNoPort() {
-        Credentials credentials = new UsernamePasswordCredentials(username, password);
+        Credentials credentials = new UsernamePasswordCredentials(username, password.toCharArray());
         CredentialsProvider provider = credentialsHelper.getCredentialsProvider(host, null, credentials);
         assertNotNull(provider);
-        assertEquals(credentials, provider.getCredentials(new AuthScope(host, AuthScope.ANY_PORT)));
+        assertEquals(credentials, provider.getCredentials(new AuthScope(host, -1), context));
     }
 
     @Test
     void testTwoCredentials() {
-        Credentials credentials = new UsernamePasswordCredentials(username, password);
+        Credentials credentials = new UsernamePasswordCredentials(username, password.toCharArray());
         CredentialsProvider provider = credentialsHelper.getCredentialsProvider(host, port, credentials);
-        Credentials proxyCredentials = new UsernamePasswordCredentials(proxyUsername, proxyPassword);
+        String proxyPassword = "proxyPassowrd";
+        String proxyUsername = "proxyUser";
+        Credentials proxyCredentials = new UsernamePasswordCredentials(proxyUsername, proxyPassword.toCharArray());
         CredentialsProvider provider2 = credentialsHelper.getCredentialsProvider(proxyHost, proxyPort,
                 proxyCredentials);
 
         assertNotNull(provider);
         assertEquals(provider, provider2);
-        assertEquals(credentials, provider.getCredentials(new AuthScope(host, port)));
-        assertEquals(proxyCredentials, provider.getCredentials(new AuthScope(proxyHost, proxyPort)));
+        assertEquals(credentials, provider.getCredentials(new AuthScope(host, port), context));
+        assertEquals(proxyCredentials, provider.getCredentials(new AuthScope(proxyHost, proxyPort), context));
 
     }
 
     @Test
     void testTwoCredentialsDifferentHttpComponents() {
-        Credentials credentials1 = new UsernamePasswordCredentials(username, password);
+        Credentials credentials1 = new UsernamePasswordCredentials(username, password.toCharArray());
         CredentialsProvider provider1 = credentialsHelper.getCredentialsProvider(host, port, credentials1);
-        Credentials credentials2 = new UsernamePasswordCredentials(username + "2", password + "2");
+        Credentials credentials2 = new UsernamePasswordCredentials(username + "2", (password + "2").toCharArray());
 
         CredentialsProvider provider2
                 = new HttpCredentialsHelper().getCredentialsProvider(proxyHost, proxyPort, credentials2);
         assertNotEquals(provider1, provider2);
-        assertEquals(credentials1, provider1.getCredentials(new AuthScope(host, port)));
-        assertEquals(credentials2, provider2.getCredentials(new AuthScope(proxyHost, proxyPort)));
-        assertNull(provider2.getCredentials(new AuthScope(host, port)));
-        assertNull(provider1.getCredentials(new AuthScope(proxyHost, proxyPort)));
+        assertEquals(credentials1, provider1.getCredentials(new AuthScope(host, port), context));
+        assertEquals(credentials2, provider2.getCredentials(new AuthScope(proxyHost, proxyPort), context));
+        assertNull(provider2.getCredentials(new AuthScope(host, port), context));
+        assertNull(provider1.getCredentials(new AuthScope(proxyHost, proxyPort), context));
     }
 
 }
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpDefaultPortNumberTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpDefaultPortNumberTest.java
index 6c5a5a78778..d7b2ac409a7 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpDefaultPortNumberTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpDefaultPortNumberTest.java
@@ -21,9 +21,9 @@ import java.util.Map;
 import org.apache.camel.Exchange;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.http.handler.BasicValidationHandler;
-import org.apache.http.conn.HttpHostConnectException;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.client5.http.HttpHostConnectException;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Disabled;
@@ -44,8 +44,8 @@ public class HttpDefaultPortNumberTest extends BaseHttpTest {
     public void setUp() throws Exception {
         localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
                 .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
-                .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext())
-                .registerHandler("/search", new BasicValidationHandler(GET.name(), null, null, getExpectedContent())).create();
+                .setSslContext(getSSLContext())
+                .register("/search", new BasicValidationHandler(GET.name(), null, null, getExpectedContent())).create();
         localServer.start();
 
         super.setUp();
@@ -67,9 +67,9 @@ public class HttpDefaultPortNumberTest extends BaseHttpTest {
             @Override
             public void configure() {
                 from("direct:start")
-                        .to("http://" + localServer.getInetAddress().getHostName() + "/search");
+                        .to("http://localhost/search");
                 from("direct:dummy")
-                        .to("http://" + localServer.getInetAddress().getHostName() + ":" + localServer.getLocalPort()
+                        .to("http://localhost:" + localServer.getLocalPort()
                             + "/search");
             }
         });
@@ -87,9 +87,9 @@ public class HttpDefaultPortNumberTest extends BaseHttpTest {
             @Override
             public void configure() {
                 from("direct:start")
-                        .to("http://" + localServer.getInetAddress().getHostName() + ":80/search");
+                        .to("http://localhost:80/search");
                 from("direct:dummy")
-                        .to("http://" + localServer.getInetAddress().getHostName() + ":" + localServer.getLocalPort()
+                        .to("http://localhost:" + localServer.getLocalPort()
                             + "/search");
             }
         });
@@ -107,9 +107,9 @@ public class HttpDefaultPortNumberTest extends BaseHttpTest {
             @Override
             public void configure() {
                 from("direct:start")
-                        .to("http://" + localServer.getInetAddress().getHostName() + "/search");
+                        .to("http://localhost/search");
                 from("direct:dummy")
-                        .to("http://" + localServer.getInetAddress().getHostName() + ":" + localServer.getLocalPort()
+                        .to("http://localhost:" + localServer.getLocalPort()
                             + "/search");
             }
         });
@@ -128,7 +128,7 @@ public class HttpDefaultPortNumberTest extends BaseHttpTest {
             @Override
             public void configure() {
                 from("direct:start")
-                        .to("http://" + localServer.getInetAddress().getHostName() + "/search");
+                        .to("http://localhost/search");
             }
         });
 
@@ -152,6 +152,6 @@ public class HttpDefaultPortNumberTest extends BaseHttpTest {
         //and got an exception:
         assertIsInstanceOf(HttpHostConnectException.class, exchange.getException());
         //with message:
-        assertEquals("Connection to http://127.0.0.1" + portExt + " refused", exchange.getException().getMessage());
+        assertEquals("Connection to http://localhost" + portExt + " refused", exchange.getException().getMessage());
     }
 }
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpDisableStreamCacheTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpDisableStreamCacheTest.java
index a94f7a4eb11..5bf884d1a5e 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpDisableStreamCacheTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpDisableStreamCacheTest.java
@@ -22,8 +22,8 @@ import org.apache.camel.Exchange;
 import org.apache.camel.TypeConversionException;
 import org.apache.camel.TypeConverter;
 import org.apache.camel.component.http.handler.BasicValidationHandler;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -43,8 +43,8 @@ public class HttpDisableStreamCacheTest extends BaseHttpTest {
     public void setUp() throws Exception {
         localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
                 .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
-                .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext())
-                .registerHandler("/test/", new BasicValidationHandler(GET.name(), null, null, getExpectedContent())).create();
+                .setSslContext(getSSLContext())
+                .register("/test/", new BasicValidationHandler(GET.name(), null, null, getExpectedContent())).create();
         localServer.start();
 
         super.setUp();
@@ -62,7 +62,7 @@ public class HttpDisableStreamCacheTest extends BaseHttpTest {
 
     @Test
     public void httpDisableStreamCache() {
-        Exchange exchange = template.request("http://" + localServer.getInetAddress().getHostName() + ":"
+        Exchange exchange = template.request("http://localhost:"
                                              + localServer.getLocalPort() + "/test/?disableStreamCache=true",
                 exchange1 -> {
                 });
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpEndpointURLTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpEndpointURLTest.java
index b3656dda5e1..e29c611c325 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpEndpointURLTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpEndpointURLTest.java
@@ -19,8 +19,8 @@ package org.apache.camel.component.http;
 import org.apache.camel.ResolveEndpointFailedException;
 import org.apache.camel.test.junit5.CamelTestSupport;
 import org.apache.camel.util.URISupport;
-import org.apache.http.conn.HttpClientConnectionManager;
-import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
+import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager;
+import org.apache.hc.client5.http.io.HttpClientConnectionManager;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -62,7 +62,6 @@ public class HttpEndpointURLTest extends CamelTestSupport {
                 = context.getEndpoint("http://www.google.com?maxTotalConnections=40&connectionsPerRoute=5", HttpEndpoint.class);
         HttpClientConnectionManager connectionManager = http1.getClientConnectionManager();
         assertTrue(connectionManager instanceof PoolingHttpClientConnectionManager, "Get a wrong type of connection manager");
-        @SuppressWarnings("resource")
         PoolingHttpClientConnectionManager poolManager = (PoolingHttpClientConnectionManager) connectionManager;
         assertEquals(40, poolManager.getMaxTotal(), "Get a wrong setting of maxTotalConnections");
         assertEquals(5, poolManager.getDefaultMaxPerRoute(), "Get a wrong setting of connectionsPerRoute");
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpEndpointUriAssemblerTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpEndpointUriAssemblerTest.java
index 9ad2e3e892b..02ba33c95f5 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpEndpointUriAssemblerTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpEndpointUriAssemblerTest.java
@@ -40,20 +40,20 @@ public class HttpEndpointUriAssemblerTest {
         params.put("proxyAuthPassword", "pwd");
 
         // should find the source code generated assembler via classpath
-        CamelContext context = new DefaultCamelContext();
-        context.start();
+        try (CamelContext context = new DefaultCamelContext()) {
+            context.start();
 
-        EndpointUriFactory assembler = context.getCamelContextExtension().getEndpointUriFactory("https");
+            EndpointUriFactory assembler = context.getCamelContextExtension().getEndpointUriFactory("https");
 
-        assertNotNull(assembler);
-        assertTrue(assembler instanceof HttpEndpointUriFactory);
+            assertNotNull(assembler);
+            assertTrue(assembler instanceof HttpEndpointUriFactory);
 
-        String uri = assembler.buildUri("https", params);
-        assertNotNull(uri);
-        assertEquals(
-                "https://www.google.com?proxyAuthHost=myotherproxy&proxyAuthPassword=RAW(pwd)&proxyAuthPort=2345&proxyAuthUsername=RAW(usr)",
-                uri);
+            String uri = assembler.buildUri("https", params);
+            assertNotNull(uri);
+            assertEquals(
+                    "https://www.google.com?proxyAuthHost=myotherproxy&proxyAuthPassword=RAW(pwd)&proxyAuthPort=2345&proxyAuthUsername=RAW(usr)",
+                    uri);
 
-        context.stop();
+        }
     }
 }
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpMethodsTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpMethodsTest.java
index 569e5f8ace1..88882baaca1 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpMethodsTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpMethodsTest.java
@@ -21,9 +21,9 @@ import java.util.Map;
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.apache.camel.component.http.handler.BasicValidationHandler;
-import org.apache.http.HttpStatus;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -52,22 +52,22 @@ public class HttpMethodsTest extends BaseHttpTest {
     public void setUp() throws Exception {
         localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
                 .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
-                .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext())
-                .registerHandler("/get", new BasicValidationHandler(GET.name(), null, null, getExpectedContent()))
-                .registerHandler("/patch", new BasicValidationHandler(PATCH.name(), null, null, getExpectedContent()))
-                .registerHandler("/patch1",
+                .setSslContext(getSSLContext())
+                .register("/get", new BasicValidationHandler(GET.name(), null, null, getExpectedContent()))
+                .register("/patch", new BasicValidationHandler(PATCH.name(), null, null, getExpectedContent()))
+                .register("/patch1",
                         new BasicValidationHandler(PATCH.name(), null, "rocks camel?", getExpectedContent()))
-                .registerHandler("/post", new BasicValidationHandler(POST.name(), null, null, getExpectedContent()))
-                .registerHandler("/post1", new BasicValidationHandler(POST.name(), null, "rocks camel?", getExpectedContent()))
-                .registerHandler("/put", new BasicValidationHandler(PUT.name(), null, null, getExpectedContent()))
-                .registerHandler("/trace", new BasicValidationHandler(TRACE.name(), null, null, getExpectedContent()))
-                .registerHandler("/options", new BasicValidationHandler(OPTIONS.name(), null, null, getExpectedContent()))
-                .registerHandler("/delete", new BasicValidationHandler(DELETE.name(), null, null, getExpectedContent()))
-                .registerHandler("/delete1", new BasicValidationHandler(DELETE.name(), null, null, getExpectedContent()))
-                .registerHandler("/head", new BasicValidationHandler(HEAD.name(), null, null, getExpectedContent())).create();
+                .register("/post", new BasicValidationHandler(POST.name(), null, null, getExpectedContent()))
+                .register("/post1", new BasicValidationHandler(POST.name(), null, "rocks camel?", getExpectedContent()))
+                .register("/put", new BasicValidationHandler(PUT.name(), null, null, getExpectedContent()))
+                .register("/trace", new BasicValidationHandler(TRACE.name(), null, null, getExpectedContent()))
+                .register("/options", new BasicValidationHandler(OPTIONS.name(), null, null, getExpectedContent()))
+                .register("/delete", new BasicValidationHandler(DELETE.name(), null, null, getExpectedContent()))
+                .register("/delete1", new BasicValidationHandler(DELETE.name(), null, null, getExpectedContent()))
+                .register("/head", new BasicValidationHandler(HEAD.name(), null, null, getExpectedContent())).create();
         localServer.start();
 
-        baseUrl = "http://" + localServer.getInetAddress().getHostName() + ":" + localServer.getLocalPort();
+        baseUrl = "http://localhost:" + localServer.getLocalPort();
 
         super.setUp();
     }
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpNoCamelHeaderTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpNoCamelHeaderTest.java
index 6e78b17e2a8..587b879f115 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpNoCamelHeaderTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpNoCamelHeaderTest.java
@@ -17,10 +17,10 @@
 package org.apache.camel.component.http;
 
 import org.apache.camel.Exchange;
-import org.apache.http.Header;
-import org.apache.http.HttpStatus;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -29,6 +29,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.fail;
 
 public class HttpNoCamelHeaderTest extends BaseHttpTest {
 
@@ -39,15 +40,15 @@ public class HttpNoCamelHeaderTest extends BaseHttpTest {
     public void setUp() throws Exception {
         localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
                 .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
-                .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext())
-                .registerHandler("/hello", (request, response, context) -> {
-                    response.setStatusCode(HttpStatus.SC_OK);
+                .setSslContext(getSSLContext())
+                .register("/hello", (request, response, context) -> {
+                    response.setCode(HttpStatus.SC_OK);
                     Object header = request.getFirstHeader(Exchange.FILE_NAME);
                     assertNull(header, "There should be no Camel header");
 
-                    for (Header h : request.getAllHeaders()) {
+                    for (Header h : request.getHeaders()) {
                         if (h.getName().startsWith("Camel") || h.getName().startsWith("org.apache.camel")) {
-                            assertNull(h, "There should be no Camel header");
+                            fail("There should be no Camel header");
                         }
                     }
 
@@ -73,7 +74,7 @@ public class HttpNoCamelHeaderTest extends BaseHttpTest {
     @Test
     public void testNoCamelHeader() throws Exception {
         Exchange out = template.request(
-                "http://" + localServer.getInetAddress().getHostName() + ":" + localServer.getLocalPort() + "/hello",
+                "http://localhost:" + localServer.getLocalPort() + "/hello",
                 exchange -> {
                     exchange.getIn().setHeader(Exchange.CONTENT_TYPE, "text/plain");
                     exchange.getIn().setHeader(Exchange.FILE_NAME, "hello.txt");
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpNoConnectionRedeliveryTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpNoConnectionRedeliveryTest.java
index 74c5c0a3f1e..a02bd1b45e8 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpNoConnectionRedeliveryTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpNoConnectionRedeliveryTest.java
@@ -17,13 +17,13 @@
 package org.apache.camel.component.http;
 
 import java.net.ConnectException;
-import java.util.concurrent.TimeUnit;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.http.handler.BasicValidationHandler;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.util.TimeValue;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -42,8 +42,8 @@ public class HttpNoConnectionRedeliveryTest extends BaseHttpTest {
     public void setUp() throws Exception {
         localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
                 .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
-                .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext())
-                .registerHandler("/search", new BasicValidationHandler(GET.name(), null, null, getExpectedContent())).create();
+                .setSslContext(getSSLContext())
+                .register("/search", new BasicValidationHandler(GET.name(), null, null, getExpectedContent())).create();
         localServer.start();
 
         super.setUp();
@@ -71,7 +71,7 @@ public class HttpNoConnectionRedeliveryTest extends BaseHttpTest {
         // stop server so there are no connection
         // and wait for it to terminate
         localServer.stop();
-        localServer.awaitTermination(5000, TimeUnit.MILLISECONDS);
+        localServer.awaitTermination(TimeValue.ofSeconds(5));
 
         Exchange exchange = template.request("direct:start", null);
         assertTrue(exchange.isFailed());
@@ -96,7 +96,7 @@ public class HttpNoConnectionRedeliveryTest extends BaseHttpTest {
                         .maximumRedeliveryDelay(5000)
                         .useExponentialBackOff()
                         .end()
-                        .to("http://" + localServer.getInetAddress().getHostName() + ":" + localServer.getLocalPort()
+                        .to("http://localhost:" + localServer.getLocalPort()
                             + "/search");
             }
         };
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpNoConnectionTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpNoConnectionTest.java
index 13e5074176d..1a9e39d67e1 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpNoConnectionTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpNoConnectionTest.java
@@ -17,12 +17,12 @@
 package org.apache.camel.component.http;
 
 import java.net.ConnectException;
-import java.util.concurrent.TimeUnit;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.component.http.handler.BasicValidationHandler;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.util.TimeValue;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -43,11 +43,11 @@ public class HttpNoConnectionTest extends BaseHttpTest {
     public void setUp() throws Exception {
         localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
                 .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
-                .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext())
-                .registerHandler("/search", new BasicValidationHandler(GET.name(), null, null, getExpectedContent())).create();
+                .setSslContext(getSSLContext())
+                .register("/search", new BasicValidationHandler(GET.name(), null, null, getExpectedContent())).create();
         localServer.start();
 
-        endpointUrl = "http://" + localServer.getInetAddress().getHostName() + ":" + localServer.getLocalPort();
+        endpointUrl = "http://localhost:" + localServer.getLocalPort();
 
         super.setUp();
     }
@@ -75,7 +75,7 @@ public class HttpNoConnectionTest extends BaseHttpTest {
         String url = endpointUrl + "/search";
         // stop server so there are no connection
         localServer.stop();
-        localServer.awaitTermination(1000, TimeUnit.MILLISECONDS);
+        localServer.awaitTermination(TimeValue.ofSeconds(1));
 
         Exchange reply = template.request(url, null);
         Exception e = reply.getException();
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpPathTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpPathTest.java
index 03f7975a4d9..66cbf040f0c 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpPathTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpPathTest.java
@@ -18,8 +18,8 @@ package org.apache.camel.component.http;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.component.http.handler.BasicValidationHandler;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -37,15 +37,15 @@ public class HttpPathTest extends BaseHttpTest {
     public void setUp() throws Exception {
         localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
                 .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
-                .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext())
-                .registerHandler("/search", new BasicValidationHandler(GET.name(), null, null, getExpectedContent()))
-                .registerHandler("/test%20/path", new BasicValidationHandler(GET.name(), null, null, getExpectedContent()))
-                .registerHandler("/testWithQueryParams",
+                .setSslContext(getSSLContext())
+                .register("/search", new BasicValidationHandler(GET.name(), null, null, getExpectedContent()))
+                .register("/test%20/path", new BasicValidationHandler(GET.name(), null, null, getExpectedContent()))
+                .register("/testWithQueryParams",
                         new BasicValidationHandler(GET.name(), "abc=123", null, getExpectedContent()))
                 .create();
         localServer.start();
 
-        endpointUrl = "http://" + localServer.getInetAddress().getHostName() + ":" + localServer.getLocalPort();
+        endpointUrl = "http://localhost:" + localServer.getLocalPort();
 
         super.setUp();
     }
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpPollingConsumerTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpPollingConsumerTest.java
index 79a7a50ed19..d6a3ac7f055 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpPollingConsumerTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpPollingConsumerTest.java
@@ -20,8 +20,8 @@ import java.net.SocketTimeoutException;
 
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.component.http.handler.DelayValidationHandler;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -34,8 +34,8 @@ import static org.junit.jupiter.api.Assertions.fail;
 public class HttpPollingConsumerTest extends BaseHttpTest {
 
     private HttpServer localServer;
-    private String user = "camel";
-    private String password = "password";
+    private final String user = "camel";
+    private final String password = "password";
     private String endpointUrl;
 
     @BeforeEach
@@ -45,11 +45,11 @@ public class HttpPollingConsumerTest extends BaseHttpTest {
 
         localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
                 .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
-                .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext())
-                .registerHandler("/", new DelayValidationHandler(GET.name(), null, null, getExpectedContent(), 1000)).create();
+                .setSslContext(getSSLContext())
+                .register("/", new DelayValidationHandler(GET.name(), null, null, getExpectedContent(), 1000)).create();
         localServer.start();
 
-        endpointUrl = "http://" + localServer.getInetAddress().getHostName() + ":" + localServer.getLocalPort();
+        endpointUrl = "http://localhost:" + localServer.getLocalPort();
     }
 
     @AfterEach
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerBridgeEndpointTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerBridgeEndpointTest.java
index f1f3ed7c415..92a5d2c9cd6 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerBridgeEndpointTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerBridgeEndpointTest.java
@@ -23,8 +23,8 @@ import java.util.Map;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.component.http.handler.HeaderValidationHandler;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -33,8 +33,8 @@ public class HttpProducerBridgeEndpointTest extends BaseHttpTest {
 
     private static final Instant INSTANT = Instant.parse("2021-06-10T14:42:00Z");
     private static final String STRING = "text";
-    private static final Integer INTEGER = Integer.valueOf(1);
-    private static final Long LONG = Long.valueOf(999999999999999L);
+    private static final Integer INTEGER = 1;
+    private static final Long LONG = 999999999999999L;
     private static final Boolean BOOLEAN = true;
     private static final String QUERY
             = "qp1=" + INSTANT + "&qp2=" + STRING + "&qp3=" + INTEGER + "&qp4=" + LONG + "&qp5=" + BOOLEAN;
@@ -54,8 +54,8 @@ public class HttpProducerBridgeEndpointTest extends BaseHttpTest {
 
         localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
                 .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
-                .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext())
-                .registerHandler("/bridged",
+                .setSslContext(getSSLContext())
+                .register("/bridged",
                         new HeaderValidationHandler(
                                 "GET",
                                 QUERY,
@@ -63,7 +63,7 @@ public class HttpProducerBridgeEndpointTest extends BaseHttpTest {
                                 getExpectedContent(),
                                 null,
                                 Arrays.asList(absentHeaders)))
-                .registerHandler("/notbridged",
+                .register("/notbridged",
                         new HeaderValidationHandler(
                                 "GET",
                                 QUERY,
@@ -94,8 +94,7 @@ public class HttpProducerBridgeEndpointTest extends BaseHttpTest {
         component.setConnectionTimeToLive(1000L);
 
         HttpEndpoint endpoint = (HttpEndpoint) component
-                .createEndpoint("http://" + localServer.getInetAddress().getHostName() + ":"
-                                + localServer.getLocalPort() + "/bridged?bridgeEndpoint=true");
+                .createEndpoint("http://localhost:" + localServer.getLocalPort() + "/bridged?bridgeEndpoint=true");
         HttpProducer producer = new HttpProducer(endpoint);
 
         Exchange exchange = producer.createExchange();
@@ -121,8 +120,7 @@ public class HttpProducerBridgeEndpointTest extends BaseHttpTest {
         component.setConnectionTimeToLive(1000L);
 
         HttpEndpoint endpoint = (HttpEndpoint) component
-                .createEndpoint("http://" + localServer.getInetAddress().getHostName() + ":"
-                                + localServer.getLocalPort() + "/notbridged");
+                .createEndpoint("http://localhost:" + localServer.getLocalPort() + "/notbridged");
         HttpProducer producer = new HttpProducer(endpoint);
 
         Exchange exchange = producer.createExchange();
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerConnectionCloseTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerConnectionCloseTest.java
index 0d0c64efbb6..2167895d457 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerConnectionCloseTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerConnectionCloseTest.java
@@ -22,9 +22,9 @@ import org.apache.camel.component.http.handler.BasicValidationHandler;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.http.common.HttpHeaderFilterStrategy;
 import org.apache.camel.spi.Registry;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
-import org.apache.http.protocol.HTTP;
+import org.apache.hc.core5.http.HeaderElements;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -47,8 +47,8 @@ public class HttpProducerConnectionCloseTest extends BaseHttpTest {
     public void setUp() throws Exception {
         localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
                 .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
-                .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext())
-                .registerHandler("/myget", new BasicValidationHandler(GET.name(), null, null, getExpectedContent())).create();
+                .setSslContext(getSSLContext())
+                .register("/myget", new BasicValidationHandler(GET.name(), null, null, getExpectedContent())).create();
         localServer.start();
 
         super.setUp();
@@ -69,17 +69,17 @@ public class HttpProducerConnectionCloseTest extends BaseHttpTest {
         HttpComponent component = context.getComponent("http", HttpComponent.class);
         component.setConnectionTimeToLive(1000L);
         HttpEndpoint endpoint = (HttpEndpoint) component
-                .createEndpoint("http://" + localServer.getInetAddress().getHostName() + ":"
+                .createEndpoint("http://localhost:"
                                 + localServer.getLocalPort() + "/myget?headerFilterStrategy=#myFilter");
         HttpProducer producer = new HttpProducer(endpoint);
         Exchange exchange = producer.createExchange();
         exchange.getIn().setBody(null);
-        exchange.getIn().setHeader("connection", HTTP.CONN_CLOSE);
+        exchange.getIn().setHeader("connection", HeaderElements.CLOSE);
         producer.start();
         producer.process(exchange);
         producer.stop();
 
-        assertEquals(HTTP.CONN_CLOSE, exchange.getMessage().getHeader("connection"));
+        assertEquals(HeaderElements.CLOSE, exchange.getMessage().getHeader("connection"));
         assertExchange(exchange);
     }
 
@@ -89,7 +89,7 @@ public class HttpProducerConnectionCloseTest extends BaseHttpTest {
         registry.bind("myFilter", connectionCloseFilterStrategy);
     }
 
-    class ConnectionCloseHeaderFilter extends HttpHeaderFilterStrategy {
+    static class ConnectionCloseHeaderFilter extends HttpHeaderFilterStrategy {
         @Override
         protected void initialize() {
             super.initialize();
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerContentLengthTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerContentLengthTest.java
index 0b2d2663ebf..7d0bfec9170 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerContentLengthTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerContentLengthTest.java
@@ -20,10 +20,10 @@ import java.io.ByteArrayInputStream;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.converter.stream.ByteArrayInputStreamCache;
-import org.apache.http.Header;
-import org.apache.http.HttpStatus;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -47,8 +47,8 @@ public class HttpProducerContentLengthTest extends BaseHttpTest {
 
         localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
                 .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
-                .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext())
-                .registerHandler("/content-streamed", (request, response, context) -> {
+                .setSslContext(getSSLContext())
+                .register("/content-streamed", (request, response, context) -> {
                     Header contentLengthHeader = request.getFirstHeader(Exchange.CONTENT_LENGTH);
                     String contentLength = contentLengthHeader != null ? contentLengthHeader.getValue() : "";
                     Header transferEncodingHeader = request.getFirstHeader(Exchange.TRANSFER_ENCODING);
@@ -57,9 +57,9 @@ public class HttpProducerContentLengthTest extends BaseHttpTest {
                     //Request Body Chunked if no Content-Length set.
                     assertEquals("", contentLength);
                     assertEquals("chunked", transferEncoding);
-                    response.setStatusCode(HttpStatus.SC_OK);
+                    response.setCode(HttpStatus.SC_OK);
                 })
-                .registerHandler("/content-not-streamed", (request, response, context) -> {
+                .register("/content-not-streamed", (request, response, context) -> {
                     Header contentLengthHeader = request.getFirstHeader(Exchange.CONTENT_LENGTH);
                     String contentLength = contentLengthHeader != null ? contentLengthHeader.getValue() : "";
                     Header transferEncodingHeader = request.getFirstHeader(Exchange.TRANSFER_ENCODING);
@@ -68,13 +68,13 @@ public class HttpProducerContentLengthTest extends BaseHttpTest {
                     //Content-Length should match byte array
                     assertEquals("35", contentLength);
                     assertEquals("", transferEncoding);
-                    response.setStatusCode(HttpStatus.SC_OK);
+                    response.setCode(HttpStatus.SC_OK);
                 })
                 .create();
 
         localServer.start();
 
-        endpointUrl = "http://" + localServer.getInetAddress().getHostName() + ":" + localServer.getLocalPort();
+        endpointUrl = "http://localhost:" + localServer.getLocalPort();
 
     }
 
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerContentTypeTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerContentTypeTest.java
index 898ed0ee80d..12e0972cfe2 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerContentTypeTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerContentTypeTest.java
@@ -16,11 +16,13 @@
  */
 package org.apache.camel.component.http;
 
+import java.nio.charset.StandardCharsets;
+
 import org.apache.camel.Exchange;
-import org.apache.http.HttpStatus;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.io.entity.StringEntity;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -45,18 +47,18 @@ public class HttpProducerContentTypeTest extends BaseHttpTest {
 
         localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
                 .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
-                .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext())
-                .registerHandler("/content", (request, response, context) -> {
+                .setSslContext(getSSLContext())
+                .register("/content", (request, response, context) -> {
                     String contentType = request.getFirstHeader(Exchange.CONTENT_TYPE).getValue();
 
                     assertEquals(CONTENT_TYPE, contentType);
 
-                    response.setEntity(new StringEntity(contentType, "ASCII"));
-                    response.setStatusCode(HttpStatus.SC_OK);
+                    response.setEntity(new StringEntity(contentType, StandardCharsets.US_ASCII));
+                    response.setCode(HttpStatus.SC_OK);
                 }).create();
         localServer.start();
 
-        endpointUrl = "http://" + localServer.getInetAddress().getHostName() + ":" + localServer.getLocalPort();
+        endpointUrl = "http://localhost:" + localServer.getLocalPort();
     }
 
     @AfterEach
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerContentTypeWithSemiColonTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerContentTypeWithSemiColonTest.java
index b49eabbb6dd..a57dd936428 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerContentTypeWithSemiColonTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerContentTypeWithSemiColonTest.java
@@ -16,11 +16,13 @@
  */
 package org.apache.camel.component.http;
 
+import java.nio.charset.StandardCharsets;
+
 import org.apache.camel.Exchange;
-import org.apache.http.HttpStatus;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.io.entity.StringEntity;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -45,18 +47,18 @@ public class HttpProducerContentTypeWithSemiColonTest extends BaseHttpTest {
 
         localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
                 .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
-                .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext())
-                .registerHandler("/content", (request, response, context) -> {
+                .setSslContext(getSSLContext())
+                .register("/content", (request, response, context) -> {
                     String contentType = request.getFirstHeader(Exchange.CONTENT_TYPE).getValue();
 
                     assertEquals(CONTENT_TYPE.replace(";", "; "), contentType);
 
-                    response.setEntity(new StringEntity(contentType, "ASCII"));
-                    response.setStatusCode(HttpStatus.SC_OK);
+                    response.setEntity(new StringEntity(contentType, StandardCharsets.US_ASCII));
+                    response.setCode(HttpStatus.SC_OK);
                 }).create();
         localServer.start();
 
-        endpointUrl = "http://" + localServer.getInetAddress().getHostName() + ":" + localServer.getLocalPort();
+        endpointUrl = "http://localhost:" + localServer.getLocalPort();
     }
 
     @AfterEach
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerCustomHeaderTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerCustomHeaderTest.java
index 3035c466747..8e2335b96e5 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerCustomHeaderTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerCustomHeaderTest.java
@@ -21,14 +21,13 @@ import java.util.Map;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.component.http.handler.HeaderValidationHandler;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.HttpHeaders;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
-import static org.apache.http.HttpHeaders.HOST;
-
 public class HttpProducerCustomHeaderTest extends BaseHttpTest {
 
     private static final String CUSTOM_HOST = "test";
@@ -39,18 +38,19 @@ public class HttpProducerCustomHeaderTest extends BaseHttpTest {
     @Override
     public void setUp() throws Exception {
         Map<String, String> expectedHeaders = new HashMap<>();
-        expectedHeaders.put(HOST, CUSTOM_HOST);
+        expectedHeaders.put(HttpHeaders.HOST, CUSTOM_HOST);
 
         localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
                 .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
-                .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext()).registerHandler("*",
+                .setSslContext(getSSLContext())
+                .registerVirtual(CUSTOM_HOST, "*",
                         new HeaderValidationHandler(
                                 "GET",
-                                "customHostHeader=" + CUSTOM_HOST,
+                                null,
                                 null,
                                 getExpectedContent(),
                                 expectedHeaders))
-                .registerHandler("*",
+                .register("*",
                         new HeaderValidationHandler(
                                 "GET",
                                 null,
@@ -81,8 +81,8 @@ public class HttpProducerCustomHeaderTest extends BaseHttpTest {
         component.setConnectionTimeToLive(1000L);
 
         HttpEndpoint endpoint = (HttpEndpoint) component
-                .createEndpoint("http://" + localServer.getInetAddress().getHostName() + ":"
-                                + localServer.getLocalPort() + "/myget?customHostHeader=" + CUSTOM_HOST);
+                .createEndpoint(
+                        "http://localhost:" + localServer.getLocalPort() + "/myget?customHostHeader=" + CUSTOM_HOST);
         HttpProducer producer = new HttpProducer(endpoint);
 
         Exchange exchange = producer.createExchange();
@@ -102,7 +102,7 @@ public class HttpProducerCustomHeaderTest extends BaseHttpTest {
         component.setConnectionTimeToLive(1000L);
 
         HttpEndpoint endpoint
-                = (HttpEndpoint) component.createEndpoint("http://" + localServer.getInetAddress().getHostName() + ":"
+                = (HttpEndpoint) component.createEndpoint("http://localhost:"
                                                           + localServer.getLocalPort() + "/myget");
         HttpProducer producer = new HttpProducer(endpoint);
 
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerExplicitConnectionCloseTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerExplicitConnectionCloseTest.java
index 519c3f829ab..f6afd7c5c15 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerExplicitConnectionCloseTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerExplicitConnectionCloseTest.java
@@ -16,13 +16,11 @@
  */
 package org.apache.camel.component.http;
 
-import org.apache.camel.EndpointInject;
 import org.apache.camel.Exchange;
 import org.apache.camel.component.http.handler.BasicValidationHandler;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
-import org.apache.http.protocol.HTTP;
+import org.apache.hc.core5.http.HeaderElements;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -35,9 +33,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
  */
 public class HttpProducerExplicitConnectionCloseTest extends BaseHttpTest {
 
-    @EndpointInject("mock:result")
-    protected MockEndpoint mockResultEndpoint;
-
     private HttpServer localServer;
 
     @BeforeEach
@@ -45,8 +40,8 @@ public class HttpProducerExplicitConnectionCloseTest extends BaseHttpTest {
     public void setUp() throws Exception {
         localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
                 .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
-                .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext())
-                .registerHandler("/myget", new BasicValidationHandler(GET.name(), null, null, getExpectedContent())).create();
+                .setSslContext(getSSLContext())
+                .register("/myget", new BasicValidationHandler(GET.name(), null, null, getExpectedContent())).create();
         localServer.start();
 
         super.setUp();
@@ -67,7 +62,7 @@ public class HttpProducerExplicitConnectionCloseTest extends BaseHttpTest {
         HttpComponent component = context.getComponent("http", HttpComponent.class);
         component.setConnectionTimeToLive(1000L);
         HttpEndpoint endpoiont
-                = (HttpEndpoint) component.createEndpoint("http://" + localServer.getInetAddress().getHostName() + ":"
+                = (HttpEndpoint) component.createEndpoint("http://localhost:"
                                                           + localServer.getLocalPort() + "/myget?connectionClose=true");
         HttpProducer producer = new HttpProducer(endpoiont);
         Exchange exchange = producer.createExchange();
@@ -76,7 +71,7 @@ public class HttpProducerExplicitConnectionCloseTest extends BaseHttpTest {
         producer.process(exchange);
         producer.stop();
 
-        assertEquals(HTTP.CONN_CLOSE, exchange.getMessage().getHeader("connection"));
+        assertEquals(HeaderElements.CLOSE, exchange.getMessage().getHeader("connection"));
         assertExchange(exchange);
     }
 }
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerLoadManualIT.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerLoadManualIT.java
index f6160d20a60..217d7c5becf 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerLoadManualIT.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerLoadManualIT.java
@@ -26,8 +26,8 @@ import org.apache.camel.RoutesBuilder;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.http.handler.DrinkValidationHandler;
 import org.apache.camel.util.StopWatch;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Disabled;
@@ -49,8 +49,8 @@ public class HttpProducerLoadManualIT extends BaseHttpTest {
     public void setUp() throws Exception {
         localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
                 .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
-                .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext())
-                .registerHandler("/echo", new DrinkValidationHandler(GET.name(), null, null, "myHeader")).create();
+                .setSslContext(getSSLContext())
+                .register("/echo", new DrinkValidationHandler(GET.name(), null, null, "myHeader")).create();
         localServer.start();
 
         super.setUp();
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerRestartTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerRestartTest.java
index f2c4da439f7..5bd52a2b35a 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerRestartTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerRestartTest.java
@@ -16,12 +16,14 @@
  */
 package org.apache.camel.component.http;
 
+import java.nio.charset.StandardCharsets;
+
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.http.HttpStatus;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
-import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.io.entity.StringEntity;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -41,17 +43,17 @@ public class HttpProducerRestartTest extends BaseHttpTest {
 
         localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
                 .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
-                .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext())
-                .registerHandler("/hello", (request, response, context) -> {
+                .setSslContext(getSSLContext())
+                .register("/hello", (request, response, context) -> {
                     Object agent = request.getFirstHeader("User-Agent").getValue();
                     assertEquals("MyAgent", agent);
 
-                    response.setEntity(new StringEntity("Bye World", "ASCII"));
-                    response.setStatusCode(HttpStatus.SC_OK);
+                    response.setEntity(new StringEntity("Bye World", StandardCharsets.US_ASCII));
+                    response.setCode(HttpStatus.SC_OK);
                 }).create();
         localServer.start();
 
-        endpointUrl = "http://" + localServer.getInetAddress().getHostName() + ":" + localServer.getLocalPort();
+        endpointUrl = "http://localhost:" + localServer.getLocalPort();
     }
 
     @AfterEach
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerSelectMethodTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerSelectMethodTest.java
index fa6bccfffdd..e8077050c54 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerSelectMethodTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerSelectMethodTest.java
@@ -18,8 +18,8 @@ package org.apache.camel.component.http;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.component.http.handler.BasicValidationHandler;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -46,14 +46,14 @@ public class HttpProducerSelectMethodTest extends BaseHttpTest {
 
         localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
                 .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
-                .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext())
-                .registerHandler("/myget", new BasicValidationHandler(GET.name(), null, null, getExpectedContent()))
-                .registerHandler("/mypost", new BasicValidationHandler(POST.name(), null, null, getExpectedContent()))
-                .registerHandler("/myget2", new BasicValidationHandler(GET.name(), "q=Camel", null, getExpectedContent()))
+                .setSslContext(getSSLContext())
+                .register("/myget", new BasicValidationHandler(GET.name(), null, null, getExpectedContent()))
+                .register("/mypost", new BasicValidationHandler(POST.name(), null, null, getExpectedContent()))
+                .register("/myget2", new BasicValidationHandler(GET.name(), "q=Camel", null, getExpectedContent()))
                 .create();
         localServer.start();
 
-        baseUrl = "http://" + localServer.getInetAddress().getHostName() + ":" + localServer.getLocalPort();
+        baseUrl = "http://localhost:" + localServer.getLocalPort();
 
     }
 
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerSessionTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerSessionTest.java
index 06f527d7572..fdb8247e65b 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerSessionTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerSessionTest.java
@@ -86,7 +86,7 @@ public class HttpProducerSessionTest extends CamelTestSupport {
 
     private String getTestServerEndpointSessionUrl() {
         // session handling will not work for localhost
-        return "http://127.0.0.1:" + PORT + "/session/";
+        return "http://localhost:" + PORT + "/session/";
     }
 
     @Override
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerTwoHeadersWithSameKeyTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerTwoHeadersWithSameKeyTest.java
index 7e51a9481eb..08f60ef9df7 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerTwoHeadersWithSameKeyTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerTwoHeadersWithSameKeyTest.java
@@ -16,15 +16,16 @@
  */
 package org.apache.camel.component.http;
 
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.camel.Exchange;
-import org.apache.http.Header;
-import org.apache.http.HttpStatus;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.io.entity.StringEntity;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -45,8 +46,8 @@ public class HttpProducerTwoHeadersWithSameKeyTest extends BaseHttpTest {
     public void setUp() throws Exception {
         localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
                 .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
-                .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext())
-                .registerHandler("/myapp", (request, response, context) -> {
+                .setSslContext(getSSLContext())
+                .register("/myapp", (request, response, context) -> {
                     Header[] from = request.getHeaders("from");
                     assertEquals("me", from[0].getValue());
                     Header[] to = request.getHeaders("to");
@@ -55,9 +56,10 @@ public class HttpProducerTwoHeadersWithSameKeyTest extends BaseHttpTest {
                     response.setHeader("bar", "yes");
                     response.addHeader("foo", "123");
                     response.addHeader("foo", "456");
-                    response.setEntity(new StringEntity("OK", "ASCII"));
-                    response.setStatusCode(HttpStatus.SC_OK);
-                }).registerHandler("/myapp", (request, response, context) -> {
+                    response.setEntity(new StringEntity("OK", StandardCharsets.US_ASCII));
+                    response.setCode(HttpStatus.SC_OK);
+                })
+                .register("/myapp", (request, response, context) -> {
                     Header[] from = request.getHeaders("from");
                     assertEquals("me", from[0].getValue());
                     Header[] to = request.getHeaders("to");
@@ -66,8 +68,8 @@ public class HttpProducerTwoHeadersWithSameKeyTest extends BaseHttpTest {
                     response.setHeader("bar", "yes");
                     response.addHeader("foo", "123");
                     response.addHeader("foo", "456");
-                    response.setEntity(new StringEntity("OK", "ASCII"));
-                    response.setStatusCode(HttpStatus.SC_OK);
+                    response.setEntity(new StringEntity("OK", StandardCharsets.US_ASCII));
+                    response.setCode(HttpStatus.SC_OK);
                 }).create();
         localServer.start();
 
@@ -87,7 +89,7 @@ public class HttpProducerTwoHeadersWithSameKeyTest extends BaseHttpTest {
     @Test
     public void testTwoHeadersWithSameKeyHeader() throws Exception {
         String endpointUri
-                = "http://" + localServer.getInetAddress().getHostName() + ":" + localServer.getLocalPort() + "/myapp";
+                = "http://localhost:" + localServer.getLocalPort() + "/myapp";
 
         Exchange out = template.request(endpointUri, exchange -> {
             exchange.getIn().setBody(null);
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerTwoParametersWithSameKeyTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerTwoParametersWithSameKeyTest.java
index 762deb26d7f..19f43af21f1 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerTwoParametersWithSameKeyTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerTwoParametersWithSameKeyTest.java
@@ -16,13 +16,14 @@
  */
 package org.apache.camel.component.http;
 
+import java.nio.charset.StandardCharsets;
 import java.util.List;
 
 import org.apache.camel.Exchange;
-import org.apache.http.HttpStatus;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.io.entity.StringEntity;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -43,16 +44,16 @@ public class HttpProducerTwoParametersWithSameKeyTest extends BaseHttpTest {
     public void setUp() throws Exception {
         localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
                 .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
-                .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext())
-                .registerHandler("/myapp", (request, response, context) -> {
-                    String uri = request.getRequestLine().getUri();
+                .setSslContext(getSSLContext())
+                .register("/myapp", (request, response, context) -> {
+                    String uri = request.getRequestUri();
                     assertEquals("/myapp?from=me&to=foo&to=bar", uri);
 
                     response.setHeader("bar", "yes");
                     response.addHeader("foo", "123");
                     response.addHeader("foo", "456");
-                    response.setEntity(new StringEntity("OK", "ASCII"));
-                    response.setStatusCode(HttpStatus.SC_OK);
+                    response.setEntity(new StringEntity("OK", StandardCharsets.US_ASCII));
+                    response.setCode(HttpStatus.SC_OK);
                 }).create();
         localServer.start();
 
@@ -71,7 +72,7 @@ public class HttpProducerTwoParametersWithSameKeyTest extends BaseHttpTest {
 
     @Test
     public void testTwoParametersWithSameKey() throws Exception {
-        String endpointUri = "http://" + localServer.getInetAddress().getHostName() + ":" + localServer.getLocalPort()
+        String endpointUri = "http://localhost:" + localServer.getLocalPort()
                              + "/myapp?from=me&to=foo&to=bar";
 
         Exchange out = template.request(endpointUri, null);
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerUserAgentTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerUserAgentTest.java
index 3ef37accd5d..02576e3324c 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerUserAgentTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerUserAgentTest.java
@@ -16,11 +16,13 @@
  */
 package org.apache.camel.component.http;
 
+import java.nio.charset.StandardCharsets;
+
 import org.apache.camel.Exchange;
-import org.apache.http.HttpStatus;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.io.entity.StringEntity;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -42,16 +44,16 @@ public class HttpProducerUserAgentTest extends BaseHttpTest {
 
         localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
                 .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
-                .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext())
-                .registerHandler("/agent", (request, response, context) -> {
+                .setSslContext(getSSLContext())
+                .register("/agent", (request, response, context) -> {
                     String agent = request.getFirstHeader("User-Agent").getValue();
                     assertEquals("MyAgent", agent);
-                    response.setEntity(new StringEntity(agent, "ASCII"));
-                    response.setStatusCode(HttpStatus.SC_OK);
+                    response.setEntity(new StringEntity(agent, StandardCharsets.US_ASCII));
+                    response.setCode(HttpStatus.SC_OK);
                 }).create();
         localServer.start();
 
-        endpointUrl = "http://" + localServer.getInetAddress().getHostName() + ":" + localServer.getLocalPort();
+        endpointUrl = "http://localhost:" + localServer.getLocalPort();
 
         HttpComponent http = context.getComponent("http", HttpComponent.class);
         http.setUserAgent("MyAgent");
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProxyAndBasicAuthTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProxyAndBasicAuthTest.java
index 66b3e5dc526..473b8b6befe 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProxyAndBasicAuthTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProxyAndBasicAuthTest.java
@@ -16,32 +16,22 @@
  */
 package org.apache.camel.component.http;
 
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.component.http.handler.ProxyAndBasicAuthenticationValidationHandler;
-import org.apache.commons.codec.BinaryDecoder;
-import org.apache.commons.codec.DecoderException;
-import org.apache.commons.codec.binary.Base64;
-import org.apache.http.Header;
-import org.apache.http.HttpException;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpRequestInterceptor;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpResponseInterceptor;
-import org.apache.http.HttpStatus;
-import org.apache.http.ProtocolException;
-import org.apache.http.auth.AUTH;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
-import org.apache.http.localserver.RequestBasicAuth;
-import org.apache.http.localserver.ResponseBasicUnauthorized;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.protocol.HttpProcessor;
-import org.apache.http.protocol.ImmutableHttpProcessor;
-import org.apache.http.protocol.ResponseContent;
+import org.apache.camel.component.http.interceptor.RequestBasicAuth;
+import org.apache.camel.component.http.interceptor.RequestProxyBasicAuth;
+import org.apache.camel.component.http.interceptor.ResponseBasicUnauthorized;
+import org.apache.camel.component.http.interceptor.ResponseProxyBasicUnauthorized;
+import org.apache.hc.core5.http.HttpRequestInterceptor;
+import org.apache.hc.core5.http.HttpResponseInterceptor;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.protocol.DefaultHttpProcessor;
+import org.apache.hc.core5.http.protocol.HttpProcessor;
+import org.apache.hc.core5.http.protocol.ResponseContent;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -52,18 +42,18 @@ public class HttpProxyAndBasicAuthTest extends BaseHttpTest {
 
     private HttpServer proxy;
 
-    private String user = "camel";
-    private String password = "password";
-    private String proxyUser = "proxyuser";
-    private String proxyPassword = "proxypassword";
+    private final String user = "camel";
+    private final String password = "password";
+    private final String proxyUser = "proxyuser";
+    private final String proxyPassword = "proxypassword";
 
     @BeforeEach
     @Override
     public void setUp() throws Exception {
         proxy = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
                 .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
-                .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext())
-                .registerHandler("*", new ProxyAndBasicAuthenticationValidationHandler(
+                .setSslContext(getSSLContext())
+                .registerVirtual("authtest.org", "*", new ProxyAndBasicAuthenticationValidationHandler(
                         GET.name(),
                         null, null, getExpectedContent(), user, password, proxyUser, proxyPassword))
                 .create();
@@ -92,13 +82,13 @@ public class HttpProxyAndBasicAuthTest extends BaseHttpTest {
         responseInterceptors.add(new ResponseContent());
         responseInterceptors.add(new ResponseProxyBasicUnauthorized());
         responseInterceptors.add(new ResponseBasicUnauthorized());
-        return new ImmutableHttpProcessor(requestInterceptors, responseInterceptors);
+        return new DefaultHttpProcessor(requestInterceptors, responseInterceptors);
     }
 
     @Test
     public void httpGetWithProxyAndUser() throws Exception {
-        Exchange exchange = template.request("http://authtest.org" + "?proxyAuthHost="
-                                             + getProxyHost() + "&proxyAuthPort=" + getProxyPort()
+        Exchange exchange = template.request("http://authtest.org" + "?proxyAuthHost=localhost"
+                                             + "&proxyAuthPort=" + proxy.getLocalPort()
                                              + "&proxyAuthUsername=" + proxyUser + "&proxyAuthPassword=" + proxyPassword
                                              + "&authUsername=" + user + "&authPassword=" + password,
                 exchange1 -> {
@@ -106,60 +96,4 @@ public class HttpProxyAndBasicAuthTest extends BaseHttpTest {
 
         assertExchange(exchange);
     }
-
-    private String getProxyHost() {
-        return proxy.getInetAddress().getHostName();
-    }
-
-    private String getProxyPort() {
-        return "" + proxy.getLocalPort();
-    }
-
-    private static class RequestProxyBasicAuth implements HttpRequestInterceptor {
-        @Override
-        public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException {
-            String auth = null;
-
-            String requestLine = request.getRequestLine().toString();
-            // assert we set a write GET URI
-            if (requestLine.contains("http://localhost")) {
-                throw new HttpException("Get a wrong proxy GET url");
-            }
-            Header h = request.getFirstHeader(AUTH.PROXY_AUTH_RESP);
-            if (h != null) {
-                String s = h.getValue();
-                if (s != null) {
-                    auth = s.trim();
-                }
-            }
-
-            if (auth != null) {
-                int i = auth.indexOf(' ');
-                if (i == -1) {
-                    throw new ProtocolException("Invalid Authorization header: " + auth);
-                }
-                String authscheme = auth.substring(0, i);
-                if (authscheme.equalsIgnoreCase("basic")) {
-                    String s = auth.substring(i + 1).trim();
-                    byte[] credsRaw = s.getBytes("ASCII");
-                    BinaryDecoder codec = new Base64();
-                    try {
-                        String creds = new String(codec.decode(credsRaw), "ASCII");
-                        context.setAttribute("proxy-creds", creds);
-                    } catch (DecoderException ex) {
-                        throw new ProtocolException("Malformed BASIC credentials");
-                    }
-                }
-            }
-        }
-    }
-
-    private static class ResponseProxyBasicUnauthorized implements HttpResponseInterceptor {
-        @Override
-        public void process(final HttpResponse response, final HttpContext context) throws HttpException, IOException {
-            if (response.getStatusLine().getStatusCode() == HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED) {
-                response.addHeader(AUTH.PROXY_AUTH, "Basic realm=\"test realm\"");
-            }
-        }
-    }
 }
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 4440dc2075c..c95513810ff 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
@@ -16,7 +16,6 @@
  */
 package org.apache.camel.component.http;
 
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -24,25 +23,16 @@ import java.util.Map;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.component.http.handler.HeaderValidationHandler;
+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.commons.codec.BinaryDecoder;
-import org.apache.commons.codec.DecoderException;
-import org.apache.commons.codec.binary.Base64;
-import org.apache.http.Header;
-import org.apache.http.HttpException;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpRequestInterceptor;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpResponseInterceptor;
-import org.apache.http.HttpStatus;
-import org.apache.http.ProtocolException;
-import org.apache.http.auth.AUTH;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.protocol.HttpProcessor;
-import org.apache.http.protocol.ImmutableHttpProcessor;
-import org.apache.http.protocol.ResponseContent;
+import org.apache.hc.core5.http.HttpRequestInterceptor;
+import org.apache.hc.core5.http.HttpResponseInterceptor;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.protocol.DefaultHttpProcessor;
+import org.apache.hc.core5.http.protocol.HttpProcessor;
+import org.apache.hc.core5.http.protocol.ResponseContent;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -58,10 +48,13 @@ public class HttpProxyServerTest extends BaseHttpTest {
     @Override
     public void setUp() throws Exception {
         Map<String, String> expectedHeaders = new HashMap<>();
-        expectedHeaders.put("Proxy-Connection", "Keep-Alive");
+        // Don't test anymore the Proxy-Connection header as it is highly discouraged, so its support has been removed
+        // https://issues.apache.org/jira/browse/HTTPCLIENT-1957
+        //        expectedHeaders.put("Proxy-Connection", "Keep-Alive");
         proxy = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
                 .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
-                .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext()).registerHandler("*",
+                .setSslContext(getSSLContext())
+                .register("*",
                         new HeaderValidationHandler(GET.name(), null, null, getExpectedContent(), expectedHeaders))
                 .create();
         proxy.start();
@@ -86,7 +79,7 @@ public class HttpProxyServerTest extends BaseHttpTest {
         List<HttpResponseInterceptor> responseInterceptors = new ArrayList<>();
         responseInterceptors.add(new ResponseContent());
         responseInterceptors.add(new ResponseProxyBasicUnauthorized());
-        return new ImmutableHttpProcessor(requestInterceptors, responseInterceptors);
+        return new DefaultHttpProcessor(requestInterceptors, responseInterceptors);
     }
 
     @Test
@@ -109,7 +102,7 @@ public class HttpProxyServerTest extends BaseHttpTest {
     @Test
     public void httpGetWithProxyAndWithoutUser() throws Exception {
 
-        Exchange exchange = template.request("http://" + getProxyHost() + ":" + getProxyPort() + "?proxyAuthHost="
+        Exchange exchange = template.request("http://" + getHost() + ":" + getProxyPort() + "?proxyAuthHost="
                                              + getProxyHost() + "&proxyAuthPort=" + getProxyPort(),
                 exchange1 -> {
                 });
@@ -120,7 +113,7 @@ public class HttpProxyServerTest extends BaseHttpTest {
     @Test
     public void httpGetWithProxyAndWithoutUserTwo() throws Exception {
 
-        Exchange exchange = template.request("http://" + getProxyHost() + ":" + getProxyPort() + "?proxyHost=" + getProxyHost()
+        Exchange exchange = template.request("http://" + getHost() + ":" + getProxyPort() + "?proxyHost=" + getProxyHost()
                                              + "&proxyPort=" + getProxyPort(),
                 exchange1 -> {
                 });
@@ -134,7 +127,7 @@ public class HttpProxyServerTest extends BaseHttpTest {
         http.setProxyAuthHost(getProxyHost());
         http.setProxyAuthPort(Integer.parseInt(getProxyPort()));
 
-        Exchange exchange = template.request("http://" + getProxyHost() + ":" + getProxyPort(), exchange1 -> {
+        Exchange exchange = template.request("http://" + getHost() + ":" + getProxyPort(), exchange1 -> {
         });
 
         http.setProxyAuthHost(null);
@@ -143,59 +136,16 @@ public class HttpProxyServerTest extends BaseHttpTest {
         assertExchange(exchange);
     }
 
+    private String getHost() {
+        return "127.0.0.1";
+    }
+
     private String getProxyHost() {
-        return proxy.getInetAddress().getHostName();
+        return "localhost";
     }
 
     private String getProxyPort() {
         return "" + proxy.getLocalPort();
     }
 
-    private static class RequestProxyBasicAuth implements HttpRequestInterceptor {
-        @Override
-        public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException {
-            String auth = null;
-
-            String requestLine = request.getRequestLine().toString();
-            // assert we set a write GET URI
-            if (requestLine.contains("http://localhost")) {
-                throw new HttpException("Get a wrong proxy GET url");
-            }
-            Header h = request.getFirstHeader(AUTH.PROXY_AUTH_RESP);
-            if (h != null) {
-                String s = h.getValue();
-                if (s != null) {
-                    auth = s.trim();
-                }
-            }
-
-            if (auth != null) {
-                int i = auth.indexOf(' ');
-                if (i == -1) {
-                    throw new ProtocolException("Invalid Authorization header: " + auth);
-                }
-                String authscheme = auth.substring(0, i);
-                if (authscheme.equalsIgnoreCase("basic")) {
-                    String s = auth.substring(i + 1).trim();
-                    byte[] credsRaw = s.getBytes("ASCII");
-                    BinaryDecoder codec = new Base64();
-                    try {
-                        String creds = new String(codec.decode(credsRaw), "ASCII");
-                        context.setAttribute("proxy-creds", creds);
-                    } catch (DecoderException ex) {
-                        throw new ProtocolException("Malformed BASIC credentials");
-                    }
-                }
-            }
-        }
-    }
-
-    private static class ResponseProxyBasicUnauthorized implements HttpResponseInterceptor {
-        @Override
-        public void process(final HttpResponse response, final HttpContext context) throws HttpException, IOException {
-            if (response.getStatusLine().getStatusCode() == HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED) {
-                response.addHeader(AUTH.PROXY_AUTH, "Basic realm=\"test realm\"");
-            }
-        }
-    }
 }
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpQueryParameterTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpQueryParameterTest.java
index 0559939a14c..5b37dd31e48 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpQueryParameterTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpQueryParameterTest.java
@@ -19,8 +19,8 @@ package org.apache.camel.component.http;
 import org.apache.camel.RoutesBuilder;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.http.handler.DrinkQueryValidationHandler;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -37,9 +37,9 @@ public class HttpQueryParameterTest extends BaseHttpTest {
     public void setUp() throws Exception {
         localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
                 .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
-                .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext())
-                .registerHandler("/moes", new DrinkQueryValidationHandler(GET.name(), null, null, "drink"))
-                .registerHandler("/joes", new DrinkQueryValidationHandler(GET.name(), null, null, "drink")).create();
+                .setSslContext(getSSLContext())
+                .register("/moes", new DrinkQueryValidationHandler(GET.name(), null, null, "drink"))
+                .register("/joes", new DrinkQueryValidationHandler(GET.name(), null, null, "drink")).create();
         localServer.start();
 
         super.setUp();
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpQueryTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpQueryTest.java
index f466870681b..f7288bb6131 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpQueryTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpQueryTest.java
@@ -18,8 +18,8 @@ package org.apache.camel.component.http;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.component.http.handler.BasicValidationHandler;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -39,15 +39,15 @@ public class HttpQueryTest extends BaseHttpTest {
 
         localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
                 .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
-                .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext())
-                .registerHandler("/", new BasicValidationHandler(GET.name(), "hl=en&q=camel", null, getExpectedContent()))
-                .registerHandler("/test/", new BasicValidationHandler(GET.name(), "my=@+camel", null, getExpectedContent()))
-                .registerHandler("/user/pass",
+                .setSslContext(getSSLContext())
+                .register("/", new BasicValidationHandler(GET.name(), "hl=en&q=camel", null, getExpectedContent()))
+                .register("/test/", new BasicValidationHandler(GET.name(), "my=@+camel", null, getExpectedContent()))
+                .register("/user/pass",
                         new BasicValidationHandler(GET.name(), "password=baa&username=foo", null, getExpectedContent()))
                 .create();
         localServer.start();
 
-        baseUrl = "http://" + localServer.getInetAddress().getHostName() + ":" + localServer.getLocalPort();
+        baseUrl = "http://localhost:" + localServer.getLocalPort();
     }
 
     @AfterEach
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpRedirectTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpRedirectTest.java
index 9831232909b..3014d8335c0 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpRedirectTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpRedirectTest.java
@@ -21,21 +21,22 @@ import java.io.IOException;
 import org.apache.camel.Exchange;
 import org.apache.camel.component.http.handler.BasicValidationHandler;
 import org.apache.camel.http.base.HttpOperationFailedException;
-import org.apache.http.HttpException;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.protocol.HttpRequestHandler;
+import org.apache.hc.core5.http.ClassicHttpRequest;
+import org.apache.hc.core5.http.ClassicHttpResponse;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.io.HttpRequestHandler;
+import org.apache.hc.core5.http.protocol.HttpContext;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
 import static org.apache.camel.component.http.HttpMethods.GET;
 import static org.apache.camel.component.http.HttpMethods.POST;
-import static org.junit.jupiter.api.Assertions.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 /**
  *
@@ -49,11 +50,11 @@ public class HttpRedirectTest extends BaseHttpTest {
     public void setUp() throws Exception {
         localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
                 .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
-                .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext())
-                .registerHandler("/someplaceelse", new BasicValidationHandler(GET.name(), null, null, "Bye World"))
-                .registerHandler("/redirectplace", new BasicValidationHandler(POST.name(), null, null, ""))
-                .registerHandler("/testPost", new RedirectPostHandler(308))
-                .registerHandler("/test", new RedirectHandler(HttpStatus.SC_MOVED_PERMANENTLY)).create();
+                .setSslContext(getSSLContext())
+                .register("/someplaceelse", new BasicValidationHandler(GET.name(), null, null, "Bye World"))
+                .register("/redirectplace", new BasicValidationHandler(POST.name(), null, null, ""))
+                .register("/testPost", new RedirectPostHandler(308))
+                .register("/test", new RedirectHandler(HttpStatus.SC_MOVED_PERMANENTLY)).create();
         localServer.start();
 
         super.setUp();
@@ -72,9 +73,9 @@ public class HttpRedirectTest extends BaseHttpTest {
     @Test
     public void httpRedirectFalse() throws Exception {
 
-        String uri = "http://" + localServer.getInetAddress().getHostName() + ":" + localServer.getLocalPort()
-                     + "/test?httpClient.redirectsEnabled=false&httpClient.socketTimeout=60000&httpClient.connectTimeout=60000"
-                     + "&httpClient.staleConnectionCheckEnabled=false";
+        String uri = "http://localhost:" + localServer.getLocalPort()
+                     + "/test?httpClient.redirectsEnabled=false&httpClient.responseTimeout=60000&httpClient.connectTimeout=60000"
+                     + "&httpConnection.validateAfterInactivity=-1";
         Exchange out = template.request(uri, exchange -> {
             // no data
         });
@@ -84,16 +85,16 @@ public class HttpRedirectTest extends BaseHttpTest {
         assertNotNull(cause);
         assertEquals(HttpStatus.SC_MOVED_PERMANENTLY, cause.getStatusCode());
         assertEquals(
-                "http://" + localServer.getInetAddress().getHostName() + ":" + localServer.getLocalPort() + "/someplaceelse",
+                "http://localhost:" + localServer.getLocalPort() + "/someplaceelse",
                 cause.getRedirectLocation());
     }
 
     @Test
     public void httpHandleRedirect() throws Exception {
 
-        String uri = "http://" + localServer.getInetAddress().getHostName() + ":" + localServer.getLocalPort()
-                     + "/test?httpClient.socketTimeout=60000&httpClient.connectTimeout=60000"
-                     + "&httpClient.staleConnectionCheckEnabled=false&followRedirects=true";
+        String uri = "http://localhost:" + localServer.getLocalPort()
+                     + "/test?httpClient.responseTimeout=60000&httpClient.connectTimeout=60000"
+                     + "&httpConnection.validateAfterInactivity=-1&followRedirects=true";
         Exchange out = template.request(uri, exchange -> {
             // no data
         });
@@ -107,9 +108,9 @@ public class HttpRedirectTest extends BaseHttpTest {
     @Test
     public void httpHandleFollowRedirect() throws Exception {
 
-        String uri = "http://" + localServer.getInetAddress().getHostName() + ":" + localServer.getLocalPort()
-                     + "/testPost?httpClient.socketTimeout=60000&httpClient.connectTimeout=60000"
-                     + "&httpClient.staleConnectionCheckEnabled=false&followRedirects=true&httpMethod=POST";
+        String uri = "http://localhost:" + localServer.getLocalPort()
+                     + "/testPost?httpClient.responseTimeout=60000&httpClient.connectTimeout=60000"
+                     + "&httpConnection.validateAfterInactivity=-1&followRedirects=true&httpMethod=POST";
         Exchange out = template.request(uri, exchange -> {
             // no data
         });
@@ -126,9 +127,9 @@ public class HttpRedirectTest extends BaseHttpTest {
         HttpComponent component = context.getComponent("http", HttpComponent.class);
         component.setFollowRedirects(true);
         component.setConnectionTimeToLive(1000L);
-        String uri = "http://" + localServer.getInetAddress().getHostName() + ":" + localServer.getLocalPort()
-                     + "/testPost?httpClient.socketTimeout=60000&httpClient.connectTimeout=60000"
-                     + "&httpClient.staleConnectionCheckEnabled=false&httpMethod=POST";
+        String uri = "http://localhost:" + localServer.getLocalPort()
+                     + "/testPost?httpClient.responseTimeout=60000&httpClient.connectTimeout=60000"
+                     + "&httpConnection.validateAfterInactivity=-1&httpMethod=POST";
         HttpEndpoint httpEndpoint = (HttpEndpoint) component.createEndpoint(uri);
 
         Exchange out = template.request(httpEndpoint, exchange -> {
@@ -151,11 +152,11 @@ public class HttpRedirectTest extends BaseHttpTest {
         }
 
         @Override
-        public void handle(HttpRequest httpRequest, HttpResponse httpResponse, HttpContext httpContext)
+        public void handle(ClassicHttpRequest request, ClassicHttpResponse response, HttpContext context)
                 throws HttpException, IOException {
-            httpResponse.setHeader("location", "http://" + localServer.getInetAddress().getHostName() + ":"
-                                               + localServer.getLocalPort() + "/someplaceelse");
-            httpResponse.setStatusCode(code);
+            response.setHeader("location", "http://localhost:"
+                                           + localServer.getLocalPort() + "/someplaceelse");
+            response.setCode(code);
         }
     }
 
@@ -168,11 +169,11 @@ public class HttpRedirectTest extends BaseHttpTest {
         }
 
         @Override
-        public void handle(HttpRequest httpRequest, HttpResponse httpResponse, HttpContext httpContext)
+        public void handle(ClassicHttpRequest request, ClassicHttpResponse response, HttpContext context)
                 throws HttpException, IOException {
-            httpResponse.setHeader("location", "http://" + localServer.getInetAddress().getHostName() + ":"
-                                               + localServer.getLocalPort() + "/redirectplace");
-            httpResponse.setStatusCode(code);
+            response.setHeader("location", "http://localhost:"
+                                           + localServer.getLocalPort() + "/redirectplace");
+            response.setCode(code);
         }
     }
 
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpReferenceParameterTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpReferenceParameterTest.java
index 9dc75325fd4..c5c31d89554 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpReferenceParameterTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpReferenceParameterTest.java
@@ -20,9 +20,9 @@ import org.apache.camel.BindToRegistry;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.http.common.DefaultHttpBinding;
 import org.apache.camel.test.junit5.CamelTestSupport;
-import org.apache.http.impl.client.HttpClientBuilder;
-import org.apache.http.protocol.BasicHttpContext;
-import org.apache.http.protocol.HttpContext;
+import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
+import org.apache.hc.core5.http.protocol.BasicHttpContext;
+import org.apache.hc.core5.http.protocol.HttpContext;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSOTimeoutTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSOTimeoutTest.java
index 7a1273e28b8..ea4a96cca47 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSOTimeoutTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSOTimeoutTest.java
@@ -18,8 +18,9 @@ package org.apache.camel.component.http;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.component.http.handler.DelayValidationHandler;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.util.Timeout;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
@@ -37,8 +38,8 @@ public class HttpSOTimeoutTest extends BaseHttpTest {
     public void setUp() throws Exception {
         localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
                 .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
-                .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext())
-                .registerHandler("/", new DelayValidationHandler(GET.name(), null, null, getExpectedContent(), 2000)).create();
+                .setSslContext(getSSLContext())
+                .register("/", new DelayValidationHandler(GET.name(), null, null, getExpectedContent(), 2000)).create();
         localServer.start();
 
         super.setUp();
@@ -56,8 +57,8 @@ public class HttpSOTimeoutTest extends BaseHttpTest {
 
     @Test
     public void httpGet() throws Exception {
-        Exchange exchange = template.request("http://" + localServer.getInetAddress().getHostName() + ":"
-                                             + localServer.getLocalPort() + "?httpClient.SocketTimeout=5000",
+        Exchange exchange = template.request("http://localhost:"
+                                             + localServer.getLocalPort() + "?httpClient.responseTimeout=5000",
                 exchange1 -> {
                 });
 
@@ -66,8 +67,8 @@ public class HttpSOTimeoutTest extends BaseHttpTest {
 
     @Test
     public void httpGetShouldThrowASocketTimeoutException() throws Exception {
-        Exchange reply = template.request("http://" + localServer.getInetAddress().getHostName() + ":"
-                                          + localServer.getLocalPort() + "?httpClient.SocketTimeout=1000",
+        Exchange reply = template.request("http://localhost:"
+                                          + localServer.getLocalPort() + "?httpClient.responseTimeout=1000",
                 exchange -> {
                 });
         Exception e = reply.getException();
@@ -76,8 +77,8 @@ public class HttpSOTimeoutTest extends BaseHttpTest {
 
     @Test
     public void httpGetUriOption() throws Exception {
-        HttpEndpoint endpoint = context.getEndpoint("http://" + localServer.getInetAddress().getHostName() + ":"
-                                                    + localServer.getLocalPort() + "?socketTimeout=5000",
+        HttpEndpoint endpoint = context.getEndpoint("http://localhost:"
+                                                    + localServer.getLocalPort() + "?responseTimeout=5000",
                 HttpEndpoint.class);
         Exchange exchange = template.request(endpoint,
                 exchange1 -> {
@@ -85,13 +86,13 @@ public class HttpSOTimeoutTest extends BaseHttpTest {
 
         assertExchange(exchange);
 
-        Assertions.assertEquals(5000, endpoint.getSocketTimeout());
+        Assertions.assertEquals(Timeout.ofSeconds(5), endpoint.getResponseTimeout());
     }
 
     @Test
     public void httpGetUriOptionShouldThrowASocketTimeoutException() throws Exception {
-        Exchange reply = template.request("http://" + localServer.getInetAddress().getHostName() + ":"
-                                          + localServer.getLocalPort() + "?socketTimeout=1000",
+        Exchange reply = template.request("http://localhost:"
+                                          + localServer.getLocalPort() + "?responseTimeout=1000",
                 exchange -> {
                 });
         Exception e = reply.getException();
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwareBasicAuthTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwareBasicAuthTest.java
index 02827df9780..0cc9801c12a 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwareBasicAuthTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwareBasicAuthTest.java
@@ -22,8 +22,8 @@ import org.apache.camel.CamelContext;
 import org.apache.camel.RoutesBuilder;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.http.handler.DrinkAuthValidationHandler;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -40,9 +40,8 @@ public class HttpSendDynamicAwareBasicAuthTest extends BaseHttpTest {
     public void setUp() throws Exception {
         localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
                 .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
-                .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext())
-                .registerHandler("/moes", new DrinkAuthValidationHandler(GET.name(), null, null, "drink"))
-                .registerHandler("/joes", new DrinkAuthValidationHandler(GET.name(), null, null, "drink")).create();
+                .setSslContext(getSSLContext())
+                .register("/joes", new DrinkAuthValidationHandler(GET.name(), null, null, "drink")).create();
 
         localServer.start();
 
@@ -76,9 +75,11 @@ public class HttpSendDynamicAwareBasicAuthTest extends BaseHttpTest {
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("direct:moes")
-                        .toD("http://{{myUsername}}:{{myPassword}}@localhost:" + localServer.getLocalPort()
-                             + "/moes?authMethod=Basic&authenticationPreemptive=true&throwExceptionOnFailure=false&drink=${header.drink}");
+                // Providing the username and password as user info is considered as an HTTP protocol violation
+                // according to the RFC 7230, so its support has been removed
+                //                from("direct:moes")
+                //                        .toD("http://{{myUsername}}:{{myPassword}}@localhost:" + localServer.getLocalPort()
+                //                             + "/moes?authMethod=Basic&authenticationPreemptive=true&throwExceptionOnFailure=false&drink=${header.drink}");
 
                 from("direct:joes")
                         .toD("http://localhost:" + localServer.getLocalPort()
@@ -89,18 +90,15 @@ public class HttpSendDynamicAwareBasicAuthTest extends BaseHttpTest {
 
     @Test
     public void testDynamicAware() throws Exception {
-        String out = fluentTemplate.to("direct:moes").withHeader("drink", "beer").request(String.class);
-        assertEquals("Drinking beer", out);
-
-        out = fluentTemplate.to("direct:joes").withHeader("drink", "wine").request(String.class);
+        String out = fluentTemplate.to("direct:joes").withHeader("drink", "wine").request(String.class);
         assertEquals("Drinking wine", out);
 
-        // and there should be two http endpoint as they use different ways to configure username/password
+        // and there should be one http endpoint
         long count = context.getEndpoints().stream().filter(e -> e instanceof HttpEndpoint).count();
-        assertEquals(2, count);
+        assertEquals(1, count);
 
-        // we only have 2xdirect and 2xhttp
-        assertEquals(4, context.getEndpointRegistry().size());
+        // we only have one direct and one http
+        assertEquals(2, context.getEndpointRegistry().size());
     }
 
 }
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwareEmptyPathTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwareEmptyPathTest.java
index 27b368f2887..76799777f60 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwareEmptyPathTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwareEmptyPathTest.java
@@ -19,8 +19,8 @@ package org.apache.camel.component.http;
 import org.apache.camel.RoutesBuilder;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.http.handler.DrinkValidationHandler;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -37,8 +37,8 @@ public class HttpSendDynamicAwareEmptyPathTest extends BaseHttpTest {
     public void setUp() throws Exception {
         localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
                 .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
-                .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext())
-                .registerHandler("/", new DrinkValidationHandler(GET.name(), null, null, "drink")).create();
+                .setSslContext(getSSLContext())
+                .register("/", new DrinkValidationHandler(GET.name(), null, null, "drink")).create();
         localServer.start();
 
         super.setUp();
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwareHeadersTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwareHeadersTest.java
index bec5de6a7ef..2f2625c075d 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwareHeadersTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwareHeadersTest.java
@@ -20,8 +20,8 @@ import org.apache.camel.Exchange;
 import org.apache.camel.RoutesBuilder;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.http.handler.BasicValidationHandler;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -38,8 +38,8 @@ public class HttpSendDynamicAwareHeadersTest extends BaseHttpTest {
     public void setUp() throws Exception {
         localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
                 .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
-                .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext())
-                .registerHandler("/dynamicAware", new BasicValidationHandler(GET.name(), "par1=val1&par2=val2", null, null))
+                .setSslContext(getSSLContext())
+                .register("/dynamicAware", new BasicValidationHandler(GET.name(), "par1=val1&par2=val2", null, null))
                 .create();
         localServer.start();
 
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwarePathHeaderTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwarePathHeaderTest.java
index e4014478442..e288ea3e67a 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwarePathHeaderTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwarePathHeaderTest.java
@@ -20,8 +20,8 @@ import org.apache.camel.Exchange;
 import org.apache.camel.RoutesBuilder;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.http.handler.DrinkValidationHandler;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -38,8 +38,8 @@ public class HttpSendDynamicAwarePathHeaderTest extends BaseHttpTest {
     public void setUp() throws Exception {
         localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
                 .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
-                .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext())
-                .registerHandler("/mybar", new DrinkValidationHandler(GET.name(), null, null, "drink")).create();
+                .setSslContext(getSSLContext())
+                .register("/mybar", new DrinkValidationHandler(GET.name(), null, null, "drink")).create();
         localServer.start();
 
         super.setUp();
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwareRawParameterTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwareRawParameterTest.java
index 0ea7aa021e0..c949250460c 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwareRawParameterTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwareRawParameterTest.java
@@ -20,8 +20,8 @@ import org.apache.camel.Exchange;
 import org.apache.camel.RoutesBuilder;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.http.handler.BasicValidationHandler;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -39,9 +39,8 @@ public class HttpSendDynamicAwareRawParameterTest extends BaseHttpTest {
                 .setHttpProcessor(getBasicHttpProcessor())
                 .setConnectionReuseStrategy(getConnectionReuseStrategy())
                 .setResponseFactory(getHttpResponseFactory())
-                .setExpectationVerifier(getHttpExpectationVerifier())
                 .setSslContext(getSSLContext())
-                .registerHandler("/dynamicAware", new BasicValidationHandler("GET", "par1=val1&par2=val2", null, null))
+                .register("/dynamicAware", new BasicValidationHandler("GET", "par1=val1&par2=val2", null, null))
                 .create();
         localServer.start();
 
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwareRawTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwareRawTest.java
index 3445929cb17..415fbe8db44 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwareRawTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwareRawTest.java
@@ -20,8 +20,8 @@ import org.apache.camel.BindToRegistry;
 import org.apache.camel.RoutesBuilder;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.http.handler.DrinkValidationHandler;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -42,9 +42,9 @@ public class HttpSendDynamicAwareRawTest extends BaseHttpTest {
     public void setUp() throws Exception {
         localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
                 .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
-                .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext())
-                .registerHandler("/moes", new DrinkValidationHandler(GET.name(), "drink=beer&password=se+%ret", null, "drink"))
-                .registerHandler("/joes",
+                .setSslContext(getSSLContext())
+                .register("/moes", new DrinkValidationHandler(GET.name(), "drink=beer&password=se+%ret", null, "drink"))
+                .register("/joes",
                         new DrinkValidationHandler(GET.name(), "drink=wine&password=se+%ret.$", null, "drink"))
                 .create();
         localServer.start();
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwareTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwareTest.java
index 2d994d76452..b5fdf6a38fc 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwareTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwareTest.java
@@ -19,8 +19,8 @@ package org.apache.camel.component.http;
 import org.apache.camel.RoutesBuilder;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.http.handler.DrinkValidationHandler;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -38,9 +38,9 @@ public class HttpSendDynamicAwareTest extends BaseHttpTest {
     public void setUp() throws Exception {
         localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
                 .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
-                .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext())
-                .registerHandler("/moes", new DrinkValidationHandler(GET.name(), null, null, "drink"))
-                .registerHandler("/joes", new DrinkValidationHandler(GET.name(), null, null, "drink")).create();
+                .setSslContext(getSSLContext())
+                .register("/moes", new DrinkValidationHandler(GET.name(), null, null, "drink"))
+                .register("/joes", new DrinkValidationHandler(GET.name(), null, null, "drink")).create();
         localServer.start();
 
         super.setUp();
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwareUriWithSpacesTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwareUriWithSpacesTest.java
index 8c6614910a1..6f10465f0bf 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwareUriWithSpacesTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwareUriWithSpacesTest.java
@@ -23,8 +23,8 @@ import org.apache.camel.RoutesBuilder;
 import org.apache.camel.builder.ExchangeBuilder;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.http.handler.BasicValidationHandler;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -41,8 +41,8 @@ public class HttpSendDynamicAwareUriWithSpacesTest extends BaseHttpTest {
     public void setUp() throws Exception {
         localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
                 .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
-                .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext())
-                .registerHandler("/users/*", new BasicValidationHandler("GET", null, null, "a user")).create();
+                .setSslContext(getSSLContext())
+                .register("/users/*", new BasicValidationHandler("GET", null, null, "a user")).create();
         localServer.start();
 
         super.setUp();
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwareUriWithoutSlashTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwareUriWithoutSlashTest.java
index 8c00cca6d1e..6c1b3446faa 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwareUriWithoutSlashTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwareUriWithoutSlashTest.java
@@ -23,8 +23,8 @@ import org.apache.camel.RoutesBuilder;
 import org.apache.camel.builder.ExchangeBuilder;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.http.handler.BasicValidationHandler;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -41,8 +41,8 @@ public class HttpSendDynamicAwareUriWithoutSlashTest extends BaseHttpTest {
     public void setUp() throws Exception {
         localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
                 .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
-                .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext())
-                .registerHandler("/users/*", new BasicValidationHandler("GET", null, null, "a user")).create();
+                .setSslContext(getSSLContext())
+                .register("/users/*", new BasicValidationHandler("GET", null, null, "a user")).create();
         localServer.start();
 
         super.setUp();
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpServerTestSupport.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpServerTestSupport.java
index ea08ffaf906..8df4d9ed17b 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpServerTestSupport.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpServerTestSupport.java
@@ -19,10 +19,10 @@ package org.apache.camel.component.http;
 import javax.net.ssl.SSLContext;
 
 import org.apache.camel.test.junit5.CamelTestSupport;
-import org.apache.http.ConnectionReuseStrategy;
-import org.apache.http.HttpResponseFactory;
-import org.apache.http.protocol.HttpExpectationVerifier;
-import org.apache.http.protocol.HttpProcessor;
+import org.apache.hc.core5.http.ClassicHttpResponse;
+import org.apache.hc.core5.http.ConnectionReuseStrategy;
+import org.apache.hc.core5.http.HttpResponseFactory;
+import org.apache.hc.core5.http.protocol.HttpProcessor;
 
 /**
  * Abstract base class for unit testing using a http server. This class contains an empty configuration to be used.
@@ -39,7 +39,7 @@ public abstract class HttpServerTestSupport extends CamelTestSupport {
     }
 
     /**
-     * Returns the org.apache.http.ConnectionReuseStrategy which should be used by the server.
+     * Returns the org.apache.hc.core5.http.ConnectionReuseStrategy which should be used by the server.
      *
      * @return connectionReuseStrategy
      */
@@ -48,20 +48,11 @@ public abstract class HttpServerTestSupport extends CamelTestSupport {
     }
 
     /**
-     * Returns the org.apache.http.HttpResponseFactory which should be used by the server.
+     * Returns the org.apache.hc.core5.http.HttpResponseFactory which should be used by the server.
      *
      * @return httpResponseFactory
      */
-    protected HttpResponseFactory getHttpResponseFactory() {
-        return null;
-    }
-
-    /**
-     * Returns the org.apache.http.protocol.HttpExpectationVerifier which should be used by the server.
-     *
-     * @return httpExpectationVerifier
-     */
-    protected HttpExpectationVerifier getHttpExpectationVerifier() {
+    protected HttpResponseFactory<ClassicHttpResponse> getHttpResponseFactory() {
         return null;
     }
 
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSetHeaderIdsTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSetHeaderIdsTest.java
index 27af50bdae0..511d852ba77 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSetHeaderIdsTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSetHeaderIdsTest.java
@@ -21,9 +21,9 @@ import java.util.List;
 import org.apache.camel.Exchange;
 import org.apache.camel.RoutesBuilder;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.io.entity.StringEntity;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
@@ -38,10 +38,10 @@ public class HttpSetHeaderIdsTest extends BaseHttpTest {
     public void setUp() throws Exception {
         localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
                 .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
-                .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext())
-                .registerHandler("/myids", (httpRequest, httpResponse, httpContext) -> {
+                .setSslContext(getSSLContext())
+                .register("/myids", (httpRequest, httpResponse, httpContext) -> {
                     Assertions.assertNull(httpRequest.getFirstHeader("ids"));
-                    String u = httpRequest.getRequestLine().getUri();
+                    String u = httpRequest.getRequestUri();
                     httpResponse.setEntity(new StringEntity(u));
                 }).create();
         localServer.start();
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSquareBracketTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSquareBracketTest.java
index 9571b73a210..0627f0b757f 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSquareBracketTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSquareBracketTest.java
@@ -18,8 +18,8 @@ package org.apache.camel.component.http;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.component.http.handler.BasicValidationHandler;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -39,15 +39,15 @@ public class HttpSquareBracketTest extends BaseHttpTest {
 
         localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
                 .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
-                .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext())
-                .registerHandler("/",
+                .setSslContext(getSSLContext())
+                .register("/",
                         new BasicValidationHandler(
                                 GET.name(), "country=dk&filter[end-date]=2022-12-31&filter[start-date]=2022-01-01", null,
                                 getExpectedContent()))
                 .create();
         localServer.start();
 
-        baseUrl = "http://" + localServer.getInetAddress().getHostName() + ":" + localServer.getLocalPort();
+        baseUrl = "http://localhost:" + localServer.getLocalPort();
     }
 
     @AfterEach
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpThrowExceptionOnFailureTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpThrowExceptionOnFailureTest.java
index 1dcd41f95dc..c524772c0be 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpThrowExceptionOnFailureTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpThrowExceptionOnFailureTest.java
@@ -22,9 +22,9 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.apache.camel.component.http.handler.BasicValidationHandler;
 import org.apache.camel.http.base.HttpOperationFailedException;
-import org.apache.http.HttpStatus;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -46,11 +46,11 @@ public class HttpThrowExceptionOnFailureTest extends BaseHttpTest {
     public void setUp() throws Exception {
         localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
                 .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
-                .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext())
-                .registerHandler("/", new BasicValidationHandler(GET.name(), null, null, getExpectedContent())).create();
+                .setSslContext(getSSLContext())
+                .register("/", new BasicValidationHandler(GET.name(), null, null, getExpectedContent())).create();
         localServer.start();
 
-        baseUrl = "http://" + localServer.getInetAddress().getHostName() + ":" + localServer.getLocalPort();
+        baseUrl = "http://localhost:" + localServer.getLocalPort();
 
         super.setUp();
     }
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpToDSOTimeoutTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpToDSOTimeoutTest.java
index 708782a1161..1145590bf3f 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpToDSOTimeoutTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpToDSOTimeoutTest.java
@@ -20,8 +20,8 @@ import org.apache.camel.Exchange;
 import org.apache.camel.RoutesBuilder;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.http.handler.BasicValidationHandler;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -39,23 +39,23 @@ public class HttpToDSOTimeoutTest extends BaseHttpTest {
     public void setUp() throws Exception {
         localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
                 .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
-                .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext())
-                .registerHandler("/foo",
+                .setSslContext(getSSLContext())
+                .register("/foo",
                         new BasicValidationHandler(
                                 "/foo", GET.name(), null, null,
                                 getExpectedContent()))
-                .registerHandler("/bar",
+                .register("/bar",
                         new BasicValidationHandler(
                                 "/bar", GET.name(), null, null,
                                 getExpectedContent()))
-                .registerHandler("/baz",
+                .register("/baz",
                         new BasicValidationHandler(
                                 "/baz", GET.name(), null, null,
                                 getExpectedContent()))
                 .create();
         localServer.start();
 
-        baseUrl = "http://" + localServer.getInetAddress().getHostName() + ":" + localServer.getLocalPort();
+        baseUrl = "http://localhost:" + localServer.getLocalPort();
 
         super.setUp();
     }
@@ -100,13 +100,13 @@ public class HttpToDSOTimeoutTest extends BaseHttpTest {
             @Override
             public void configure() throws Exception {
                 from("direct:to")
-                        .to(baseUrl + "/foo?httpClient.SocketTimeout=5000");
+                        .to(baseUrl + "/foo?httpClient.responseTimeout=5000");
 
                 from("direct:toD")
-                        .toD(baseUrl + "/bar?httpClient.SocketTimeout=5000");
+                        .toD(baseUrl + "/bar?httpClient.responseTimeout=5000");
 
                 from("direct:toDoff")
-                        .toD().allowOptimisedComponents(false).uri(baseUrl + "/baz?httpClient.SocketTimeout=5000");
+                        .toD().allowOptimisedComponents(false).uri(baseUrl + "/baz?httpClient.responseTimeout=5000");
             }
         };
     }
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpWithHttpUriHeaderTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpWithHttpUriHeaderTest.java
index 7e3bd63d5de..62cc50a52db 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpWithHttpUriHeaderTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpWithHttpUriHeaderTest.java
@@ -18,8 +18,8 @@ package org.apache.camel.component.http;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.component.http.handler.BasicValidationHandler;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -35,8 +35,8 @@ public class HttpWithHttpUriHeaderTest extends BaseHttpTest {
     public void setUp() throws Exception {
         localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
                 .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
-                .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext())
-                .registerHandler("/", new BasicValidationHandler(GET.name(), null, null, getExpectedContent())).create();
+                .setSslContext(getSSLContext())
+                .register("/", new BasicValidationHandler(GET.name(), null, null, getExpectedContent())).create();
         localServer.start();
 
         super.setUp();
@@ -56,7 +56,7 @@ public class HttpWithHttpUriHeaderTest extends BaseHttpTest {
     public void notBridgeEndpointWithDefault() throws Exception {
 
         Exchange exchange = template.request("http://host/", exchange1 -> exchange1.getIn().setHeader(Exchange.HTTP_URI,
-                "http://" + localServer.getInetAddress().getHostName() + ":" + localServer.getLocalPort() + "/"));
+                "http://localhost:" + localServer.getLocalPort() + "/"));
         assertExchange(exchange);
     }
 }
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpsAuthenticationTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpsAuthenticationTest.java
index 0cc7ba84d2b..2ce323579d8 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpsAuthenticationTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpsAuthenticationTest.java
@@ -22,17 +22,17 @@ import java.util.List;
 import org.apache.camel.BindToRegistry;
 import org.apache.camel.Exchange;
 import org.apache.camel.component.http.handler.AuthenticationValidationHandler;
+import org.apache.camel.component.http.interceptor.RequestBasicAuth;
+import org.apache.camel.component.http.interceptor.ResponseBasicUnauthorized;
 import org.apache.camel.support.jsse.SSLContextParameters;
-import org.apache.http.HttpRequestInterceptor;
-import org.apache.http.HttpResponseInterceptor;
-import org.apache.http.conn.ssl.NoopHostnameVerifier;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
-import org.apache.http.localserver.RequestBasicAuth;
-import org.apache.http.localserver.ResponseBasicUnauthorized;
-import org.apache.http.protocol.HttpProcessor;
-import org.apache.http.protocol.ImmutableHttpProcessor;
-import org.apache.http.protocol.ResponseContent;
+import org.apache.hc.client5.http.ssl.NoopHostnameVerifier;
+import org.apache.hc.core5.http.HttpRequestInterceptor;
+import org.apache.hc.core5.http.HttpResponseInterceptor;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.protocol.DefaultHttpProcessor;
+import org.apache.hc.core5.http.protocol.HttpProcessor;
+import org.apache.hc.core5.http.protocol.ResponseContent;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -41,8 +41,8 @@ import static org.apache.camel.component.http.HttpMethods.GET;
 
 public class HttpsAuthenticationTest extends BaseHttpsTest {
 
-    private String user = "camel";
-    private String password = "password";
+    private final String user = "camel";
+    private final String password = "password";
     private HttpServer localServer;
 
     @BindToRegistry("x509HostnameVerifier")
@@ -56,8 +56,8 @@ public class HttpsAuthenticationTest extends BaseHttpsTest {
     public void setUp() throws Exception {
         localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
                 .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
-                .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext())
-                .registerHandler("/",
+                .setSslContext(getSSLContext())
+                .register("/",
                         new AuthenticationValidationHandler(GET.name(), null, null, getExpectedContent(), user, password))
                 .create();
         localServer.start();
@@ -78,7 +78,7 @@ public class HttpsAuthenticationTest extends BaseHttpsTest {
     @Test
     public void httpsGetWithAuthentication() throws Exception {
 
-        Exchange exchange = template.request("https://127.0.0.1:" + localServer.getLocalPort()
+        Exchange exchange = template.request("https://localhost:" + localServer.getLocalPort()
                                              + "/?authUsername=camel&authPassword=password&x509HostnameVerifier=#x509HostnameVerifier&sslContextParameters=#sslContextParameters",
                 exchange1 -> {
                 });
@@ -94,6 +94,6 @@ public class HttpsAuthenticationTest extends BaseHttpsTest {
         responseInterceptors.add(new ResponseContent());
         responseInterceptors.add(new ResponseBasicUnauthorized());
 
-        return new ImmutableHttpProcessor(requestInterceptors, responseInterceptors);
+        return new DefaultHttpProcessor(requestInterceptors, responseInterceptors);
     }
 }
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpsGetTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpsGetTest.java
index b0134aa0385..5a2986f99ac 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpsGetTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpsGetTest.java
@@ -20,9 +20,9 @@ import org.apache.camel.BindToRegistry;
 import org.apache.camel.Exchange;
 import org.apache.camel.component.http.handler.BasicValidationHandler;
 import org.apache.camel.support.jsse.SSLContextParameters;
-import org.apache.http.conn.ssl.NoopHostnameVerifier;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.client5.http.ssl.NoopHostnameVerifier;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -44,8 +44,8 @@ public class HttpsGetTest extends BaseHttpsTest {
     public void setUp() throws Exception {
         localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
                 .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
-                .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext())
-                .registerHandler("/mail/", new BasicValidationHandler(GET.name(), null, null, getExpectedContent())).create();
+                .setSslContext(getSSLContext())
+                .register("/mail/", new BasicValidationHandler(GET.name(), null, null, getExpectedContent())).create();
         localServer.start();
 
         super.setUp();
@@ -64,7 +64,7 @@ public class HttpsGetTest extends BaseHttpsTest {
     @Test
     public void httpsGet() throws Exception {
 
-        Exchange exchange = template.request("https://127.0.0.1:" + localServer.getLocalPort()
+        Exchange exchange = template.request("https://localhost:" + localServer.getLocalPort()
                                              + "/mail/?x509HostnameVerifier=#x509HostnameVerifier&sslContextParameters=#sslContextParameters",
                 exchange1 -> {
                 });
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpsProducerWithSystemPropertiesTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpsProducerWithSystemPropertiesTest.java
index 3f9852d137d..76926a86ae7 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpsProducerWithSystemPropertiesTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpsProducerWithSystemPropertiesTest.java
@@ -27,10 +27,10 @@ import org.apache.camel.BindToRegistry;
 import org.apache.camel.Exchange;
 import org.apache.camel.component.http.handler.BasicValidationHandler;
 import org.apache.camel.component.http.handler.HeaderValidationHandler;
-import org.apache.http.conn.ssl.NoopHostnameVerifier;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
-import org.apache.http.ssl.SSLContexts;
+import org.apache.hc.client5.http.ssl.NoopHostnameVerifier;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.ssl.SSLContexts;
 import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeAll;
@@ -41,8 +41,8 @@ import static org.apache.camel.component.http.HttpMethods.GET;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
 /**
- * If SSLContext is created via system properties, is is cached. Automatically created next sslContext (with different
- * system properties) contains values from the first creation. Therefore it is not possible to create different test,
+ * If SSLContext is created via system properties, is cached. Automatically created next sslContext (with different
+ * system properties) contains values from the first creation. Therefore, it is not possible to create different test,
  * which uses systemProperties without forked JVM.
  */
 public class HttpsProducerWithSystemPropertiesTest extends BaseHttpTest {
@@ -97,10 +97,10 @@ public class HttpsProducerWithSystemPropertiesTest extends BaseHttpTest {
 
         localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
                 .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
-                .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(sslcontext)
+                .setSslContext(sslcontext)
                 .setSslSetupHandler(socket -> socket.setNeedClientAuth(true))
-                .registerHandler("/mail/", new BasicValidationHandler(GET.name(), null, null, getExpectedContent()))
-                .registerHandler("/header/",
+                .register("/mail/", new BasicValidationHandler(GET.name(), null, null, getExpectedContent()))
+                .register("/header/",
                         new HeaderValidationHandler(GET.name(), null, null, getExpectedContent(), expectedHeaders))
                 .create();
         localServer.start();
@@ -120,7 +120,7 @@ public class HttpsProducerWithSystemPropertiesTest extends BaseHttpTest {
     @Test
     public void httpGetWithProxyFromSystemProperties() throws Exception {
 
-        String endpointUri = "https://" + localServer.getInetAddress().getHostName() + ":" + localServer.getLocalPort()
+        String endpointUri = "https://localhost:" + localServer.getLocalPort()
                              + "/header/?x509HostnameVerifier=x509HostnameVerifier&useSystemProperties=true";
         Exchange exchange = template.request(endpointUri, exchange1 -> {
         });
@@ -130,7 +130,7 @@ public class HttpsProducerWithSystemPropertiesTest extends BaseHttpTest {
 
     @Test
     public void testTwoWaySuccessfull() throws Exception {
-        Exchange exchange = template.request("https://127.0.0.1:" + localServer.getLocalPort()
+        Exchange exchange = template.request("https://localhost:" + localServer.getLocalPort()
                                              + "/mail/?x509HostnameVerifier=x509HostnameVerifier&useSystemProperties=true",
                 exchange1 -> {
                 });
@@ -140,7 +140,7 @@ public class HttpsProducerWithSystemPropertiesTest extends BaseHttpTest {
 
     @Test
     public void testTwoWayFailure() throws Exception {
-        Exchange exchange = template.request("https://127.0.0.1:" + localServer.getLocalPort()
+        Exchange exchange = template.request("https://localhost:" + localServer.getLocalPort()
                                              + "/mail/?x509HostnameVerifier=x509HostnameVerifier",
                 exchange1 -> {
                 });
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpsSslContextParametersGetTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpsSslContextParametersGetTest.java
index 268679059d3..d2233741e76 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpsSslContextParametersGetTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpsSslContextParametersGetTest.java
@@ -18,8 +18,8 @@ package org.apache.camel.component.http;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.component.http.handler.BasicValidationHandler;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -35,8 +35,8 @@ public class HttpsSslContextParametersGetTest extends HttpsGetTest {
     public void setUp() throws Exception {
         localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
                 .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
-                .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext())
-                .registerHandler("/mail/", new BasicValidationHandler(GET.name(), null, null, getExpectedContent())).create();
+                .setSslContext(getSSLContext())
+                .register("/mail/", new BasicValidationHandler(GET.name(), null, null, getExpectedContent())).create();
         localServer.start();
 
         super.setUp();
@@ -56,7 +56,7 @@ public class HttpsSslContextParametersGetTest extends HttpsGetTest {
     @Test
     public void httpsGet() throws Exception {
 
-        Exchange exchange = template.request("https://127.0.0.1:" + localServer.getLocalPort()
+        Exchange exchange = template.request("https://localhost:" + localServer.getLocalPort()
                                              + "/mail/?x509HostnameVerifier=x509HostnameVerifier&sslContextParameters=#sslContextParameters",
                 exchange1 -> {
                 });
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpsTwoComponentsSslContextParametersGetTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpsTwoComponentsSslContextParametersGetTest.java
index 21f082203ac..d5c46bb28c1 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpsTwoComponentsSslContextParametersGetTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpsTwoComponentsSslContextParametersGetTest.java
@@ -20,9 +20,9 @@ import org.apache.camel.BindToRegistry;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.support.jsse.SSLContextParameters;
 import org.apache.camel.test.AvailablePortFinder;
-import org.apache.http.conn.ssl.NoopHostnameVerifier;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.client5.http.ssl.NoopHostnameVerifier;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -54,7 +54,7 @@ public class HttpsTwoComponentsSslContextParametersGetTest extends BaseHttpsTest
     public void setUp() throws Exception {
         localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
                 .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
-                .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext()).create();
+                .setSslContext(getSSLContext()).create();
         localServer.start();
 
         super.setUp();
@@ -77,7 +77,7 @@ public class HttpsTwoComponentsSslContextParametersGetTest extends BaseHttpsTest
 
     @Test
     public void httpsTwoDifferentSSLContextNotSupported() {
-        assertDoesNotThrow(() -> runTest());
+        assertDoesNotThrow(this::runTest);
     }
 
     private void runTest() throws Exception {
@@ -87,11 +87,11 @@ public class HttpsTwoComponentsSslContextParametersGetTest extends BaseHttpsTest
                 port2 = AvailablePortFinder.getNextAvailable();
 
                 from("direct:foo")
-                        .to("https-foo://127.0.0.1:" + localServer.getLocalPort()
+                        .to("https-foo://localhost:" + localServer.getLocalPort()
                             + "/mail?x509HostnameVerifier=#x509HostnameVerifier&sslContextParameters=#sslContextParameters");
 
                 from("direct:bar")
-                        .to("https-bar://127.0.0.1:" + port2
+                        .to("https-bar://localhost:" + port2
                             + "/mail?x509HostnameVerifier=#x509HostnameVerifier&sslContextParameters=#sslContextParameters2");
             }
         });
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpsTwoDifferentSslContextParametersGetTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpsTwoDifferentSslContextParametersGetTest.java
index 800d789918b..85e6844ba85 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpsTwoDifferentSslContextParametersGetTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpsTwoDifferentSslContextParametersGetTest.java
@@ -19,9 +19,9 @@ package org.apache.camel.component.http;
 import org.apache.camel.BindToRegistry;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.support.jsse.SSLContextParameters;
-import org.apache.http.conn.ssl.NoopHostnameVerifier;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.client5.http.ssl.NoopHostnameVerifier;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Disabled;
@@ -50,7 +50,7 @@ public class HttpsTwoDifferentSslContextParametersGetTest extends BaseHttpsTest
     public void setUp() throws Exception {
         localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
                 .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
-                .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext()).create();
+                .setSslContext(getSSLContext()).create();
         localServer.start();
 
         super.setUp();
@@ -77,11 +77,11 @@ public class HttpsTwoDifferentSslContextParametersGetTest extends BaseHttpsTest
             @Override
             public void configure() throws Exception {
                 from("direct:foo")
-                        .to("https://127.0.0.1:" + localServer.getLocalPort()
+                        .to("https://localhost:" + localServer.getLocalPort()
                             + "/mail?x509HostnameVerifier=x509HostnameVerifier&sslContextParameters=#sslContextParameters");
 
                 from("direct:bar")
-                        .to("https://127.0.0.1:" + localServer.getLocalPort()
+                        .to("https://localhost:" + localServer.getLocalPort()
                             + "/mail?x509HostnameVerifier=x509HostnameVerifier&sslContextParameters=#sslContextParameters2");
             }
         });
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/ManagedHttpProducerPoolStatsTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/ManagedHttpProducerPoolStatsTest.java
index aae00192fc2..3f9d9f04bb4 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/ManagedHttpProducerPoolStatsTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/ManagedHttpProducerPoolStatsTest.java
@@ -16,14 +16,16 @@
  */
 package org.apache.camel.component.http;
 
+import java.nio.charset.StandardCharsets;
+
 import javax.management.MBeanServer;
 import javax.management.ObjectName;
 
 import org.apache.camel.Exchange;
-import org.apache.http.HttpStatus;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.io.entity.StringEntity;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -46,10 +48,10 @@ public class ManagedHttpProducerPoolStatsTest extends BaseHttpTest {
     public void setUp() throws Exception {
         localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
                 .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())
-                .setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext())
-                .registerHandler("/myapp", (request, response, context) -> {
-                    response.setEntity(new StringEntity("OK", "ASCII"));
-                    response.setStatusCode(HttpStatus.SC_OK);
+                .setSslContext(getSSLContext())
+                .register("/myapp", (request, response, context) -> {
+                    response.setEntity(new StringEntity("OK", StandardCharsets.US_ASCII));
+                    response.setCode(HttpStatus.SC_OK);
                 }).create();
         localServer.start();
 
@@ -71,7 +73,7 @@ public class ManagedHttpProducerPoolStatsTest extends BaseHttpTest {
         // turn on registering jmx always so the producer is also registered
         context.getManagementStrategy().getManagementAgent().setRegisterAlways(true);
 
-        String uri = "http://" + localServer.getInetAddress().getHostName() + ":" + localServer.getLocalPort() + "/myapp";
+        String uri = "http://localhost:" + localServer.getLocalPort() + "/myapp";
 
         Exchange out = template.request(uri, exchange -> exchange.getIn().setBody("Hello World"));
 
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/handler/AuthenticationValidationHandler.java b/components/camel-http/src/test/java/org/apache/camel/component/http/handler/AuthenticationValidationHandler.java
index 43ad0179f36..b83e18b068e 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/handler/AuthenticationValidationHandler.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/handler/AuthenticationValidationHandler.java
@@ -18,11 +18,11 @@ package org.apache.camel.component.http.handler;
 
 import java.io.IOException;
 
-import org.apache.http.HttpException;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.protocol.HttpContext;
+import org.apache.hc.core5.http.ClassicHttpRequest;
+import org.apache.hc.core5.http.ClassicHttpResponse;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.protocol.HttpContext;
 
 public class AuthenticationValidationHandler extends BasicValidationHandler {
 
@@ -40,11 +40,11 @@ public class AuthenticationValidationHandler extends BasicValidationHandler {
 
     @Override
     public void handle(
-            final HttpRequest request, final HttpResponse response,
+            final ClassicHttpRequest request, final ClassicHttpResponse response,
             final HttpContext context)
             throws HttpException, IOException {
         if (!getExpectedCredential().equals(context.getAttribute("creds"))) {
-            response.setStatusCode(HttpStatus.SC_UNAUTHORIZED);
+            response.setCode(HttpStatus.SC_UNAUTHORIZED);
             return;
         }
 
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/handler/BasicRawQueryValidationHandler.java b/components/camel-http/src/test/java/org/apache/camel/component/http/handler/BasicRawQueryValidationHandler.java
index 9ef9b8b003d..de8dafa70c1 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/handler/BasicRawQueryValidationHandler.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/handler/BasicRawQueryValidationHandler.java
@@ -17,10 +17,9 @@
 package org.apache.camel.component.http.handler;
 
 import java.io.IOException;
-import java.net.URI;
 import java.net.URISyntaxException;
 
-import org.apache.http.HttpRequest;
+import org.apache.hc.core5.http.ClassicHttpRequest;
 
 /**
  * Similar to {@link BasicValidationHandler} but validates the raw query instead.
@@ -33,9 +32,9 @@ public class BasicRawQueryValidationHandler extends BasicValidationHandler {
     }
 
     @Override
-    protected boolean validateQuery(HttpRequest request) throws IOException {
+    protected boolean validateQuery(ClassicHttpRequest request) throws IOException {
         try {
-            String query = new URI(request.getRequestLine().getUri()).getRawQuery();
+            String query = request.getUri().getRawQuery();
             if (expectedQuery != null && !expectedQuery.equals(query)) {
                 return false;
             }
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/handler/BasicValidationHandler.java b/components/camel-http/src/test/java/org/apache/camel/component/http/handler/BasicValidationHandler.java
index 186c02584b7..8a648b63846 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/handler/BasicValidationHandler.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/handler/BasicValidationHandler.java
@@ -17,19 +17,18 @@
 package org.apache.camel.component.http.handler;
 
 import java.io.IOException;
-import java.net.URI;
 import java.net.URISyntaxException;
-
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpEntityEnclosingRequest;
-import org.apache.http.HttpException;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.protocol.HttpRequestHandler;
-import org.apache.http.util.EntityUtils;
+import java.nio.charset.StandardCharsets;
+
+import org.apache.hc.core5.http.ClassicHttpRequest;
+import org.apache.hc.core5.http.ClassicHttpResponse;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.io.HttpRequestHandler;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
+import org.apache.hc.core5.http.io.entity.StringEntity;
+import org.apache.hc.core5.http.protocol.HttpContext;
 
 public class BasicValidationHandler implements HttpRequestHandler {
 
@@ -58,45 +57,45 @@ public class BasicValidationHandler implements HttpRequestHandler {
 
     @Override
     public void handle(
-            final HttpRequest request, final HttpResponse response,
+            final ClassicHttpRequest request, final ClassicHttpResponse response,
             final HttpContext context)
             throws HttpException, IOException {
 
-        if (expectedUri != null && !expectedUri.equals(request.getRequestLine().getUri())) {
-            response.setStatusCode(HttpStatus.SC_BAD_REQUEST);
+        if (expectedUri != null && !expectedUri.equals(request.getRequestUri())) {
+            response.setCode(HttpStatus.SC_BAD_REQUEST);
             return;
         }
 
-        if (expectedMethod != null && !expectedMethod.equals(request.getRequestLine().getMethod())) {
-            response.setStatusCode(HttpStatus.SC_METHOD_FAILURE);
+        if (expectedMethod != null && !expectedMethod.equals(request.getMethod())) {
+            response.setCode(HttpStatus.SC_METHOD_FAILURE);
             return;
         }
 
         if (!validateQuery(request)) {
-            response.setStatusCode(HttpStatus.SC_BAD_REQUEST);
+            response.setCode(HttpStatus.SC_BAD_REQUEST);
             return;
         }
 
         if (expectedContent != null) {
-            HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity();
+            HttpEntity entity = request.getEntity();
             String content = EntityUtils.toString(entity);
 
             if (!expectedContent.equals(content)) {
-                response.setStatusCode(HttpStatus.SC_BAD_REQUEST);
+                response.setCode(HttpStatus.SC_BAD_REQUEST);
                 return;
             }
         }
 
-        response.setStatusCode(HttpStatus.SC_OK);
+        response.setCode(HttpStatus.SC_OK);
         String content = buildResponse(request);
         if (content != null) {
-            response.setEntity(new StringEntity(content, "ASCII"));
+            response.setEntity(new StringEntity(content, StandardCharsets.US_ASCII));
         }
     }
 
-    protected boolean validateQuery(HttpRequest request) throws IOException {
+    protected boolean validateQuery(ClassicHttpRequest request) throws IOException {
         try {
-            String query = new URI(request.getRequestLine().getUri()).getQuery();
+            String query = request.getUri().getQuery();
             if (expectedQuery != null && !expectedQuery.equals(query)) {
                 return false;
             }
@@ -106,7 +105,7 @@ public class BasicValidationHandler implements HttpRequestHandler {
         return true;
     }
 
-    protected String buildResponse(HttpRequest request) {
+    protected String buildResponse(ClassicHttpRequest request) {
         return responseContent;
     }
 
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/handler/DelayValidationHandler.java b/components/camel-http/src/test/java/org/apache/camel/component/http/handler/DelayValidationHandler.java
index 61e11e49dec..e5c9d4fc3ef 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/handler/DelayValidationHandler.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/handler/DelayValidationHandler.java
@@ -18,10 +18,10 @@ package org.apache.camel.component.http.handler;
 
 import java.io.IOException;
 
-import org.apache.http.HttpException;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.protocol.HttpContext;
+import org.apache.hc.core5.http.ClassicHttpRequest;
+import org.apache.hc.core5.http.ClassicHttpResponse;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.protocol.HttpContext;
 
 public class DelayValidationHandler extends BasicValidationHandler {
 
@@ -35,7 +35,7 @@ public class DelayValidationHandler extends BasicValidationHandler {
 
     @Override
     public void handle(
-            final HttpRequest request, final HttpResponse response,
+            final ClassicHttpRequest request, final ClassicHttpResponse response,
             final HttpContext context)
             throws HttpException, IOException {
         try {
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/handler/DrinkAuthValidationHandler.java b/components/camel-http/src/test/java/org/apache/camel/component/http/handler/DrinkAuthValidationHandler.java
index 590ee5a60cb..48ae429ae9a 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/handler/DrinkAuthValidationHandler.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/handler/DrinkAuthValidationHandler.java
@@ -18,10 +18,12 @@ package org.apache.camel.component.http.handler;
 
 import java.io.IOException;
 
-import org.apache.http.HttpException;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.protocol.HttpContext;
+import org.apache.hc.core5.http.ClassicHttpRequest;
+import org.apache.hc.core5.http.ClassicHttpResponse;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpHeaders;
+import org.apache.hc.core5.http.protocol.HttpContext;
 import org.junit.jupiter.api.Assertions;
 
 public class DrinkAuthValidationHandler extends DrinkValidationHandler {
@@ -31,8 +33,11 @@ public class DrinkAuthValidationHandler extends DrinkValidationHandler {
     }
 
     @Override
-    public void handle(HttpRequest request, HttpResponse response, HttpContext context) throws HttpException, IOException {
-        String auth = request.getFirstHeader("Authorization").getValue();
+    public void handle(ClassicHttpRequest request, ClassicHttpResponse response, HttpContext context)
+            throws HttpException, IOException {
+        Header authorization = request.getFirstHeader(HttpHeaders.AUTHORIZATION);
+        Assertions.assertNotNull(authorization);
+        String auth = authorization.getValue();
         Assertions.assertTrue(auth.startsWith("Basic"));
         super.handle(request, response, context);
     }
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/handler/DrinkQueryValidationHandler.java b/components/camel-http/src/test/java/org/apache/camel/component/http/handler/DrinkQueryValidationHandler.java
index 0af130335c6..e3e02450249 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/handler/DrinkQueryValidationHandler.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/handler/DrinkQueryValidationHandler.java
@@ -16,7 +16,7 @@
  */
 package org.apache.camel.component.http.handler;
 
-import org.apache.http.HttpRequest;
+import org.apache.hc.core5.http.ClassicHttpRequest;
 
 public class DrinkQueryValidationHandler extends BasicValidationHandler {
 
@@ -28,7 +28,11 @@ public class DrinkQueryValidationHandler extends BasicValidationHandler {
     }
 
     @Override
-    protected String buildResponse(HttpRequest request) {
-        return "Drinking " + request.getRequestLine().getUri();
+    protected String buildResponse(ClassicHttpRequest request) {
+        return "Drinking " + request.getRequestUri();
+    }
+
+    public String getName() {
+        return name;
     }
 }
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/handler/DrinkValidationHandler.java b/components/camel-http/src/test/java/org/apache/camel/component/http/handler/DrinkValidationHandler.java
index b5ea060fe87..64fe5254a3a 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/handler/DrinkValidationHandler.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/handler/DrinkValidationHandler.java
@@ -16,7 +16,7 @@
  */
 package org.apache.camel.component.http.handler;
 
-import org.apache.http.HttpRequest;
+import org.apache.hc.core5.http.ClassicHttpRequest;
 
 public class DrinkValidationHandler extends BasicValidationHandler {
 
@@ -28,7 +28,7 @@ public class DrinkValidationHandler extends BasicValidationHandler {
     }
 
     @Override
-    protected String buildResponse(HttpRequest request) {
+    protected String buildResponse(ClassicHttpRequest request) {
         return "Drinking " + request.getFirstHeader(header).getValue();
     }
 }
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/handler/HeaderValidationHandler.java b/components/camel-http/src/test/java/org/apache/camel/component/http/handler/HeaderValidationHandler.java
index 240e56b06f2..83b41f0d5db 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/handler/HeaderValidationHandler.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/handler/HeaderValidationHandler.java
@@ -21,12 +21,12 @@ import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 
-import org.apache.http.Header;
-import org.apache.http.HttpException;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.protocol.HttpContext;
+import org.apache.hc.core5.http.ClassicHttpRequest;
+import org.apache.hc.core5.http.ClassicHttpResponse;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.protocol.HttpContext;
 
 public class HeaderValidationHandler extends BasicValidationHandler {
 
@@ -54,7 +54,7 @@ public class HeaderValidationHandler extends BasicValidationHandler {
 
     @Override
     public void handle(
-            final HttpRequest request, final HttpResponse response,
+            final ClassicHttpRequest request, final ClassicHttpResponse response,
             final HttpContext context)
             throws HttpException, IOException {
 
@@ -71,7 +71,7 @@ public class HeaderValidationHandler extends BasicValidationHandler {
                 }
 
                 if (!headerExist) {
-                    response.setStatusCode(HttpStatus.SC_EXPECTATION_FAILED);
+                    response.setCode(HttpStatus.SC_EXPECTATION_FAILED);
                     return;
                 }
             }
@@ -80,7 +80,7 @@ public class HeaderValidationHandler extends BasicValidationHandler {
         if (absentHeaders != null) {
             for (String header : absentHeaders) {
                 if (request.getHeaders(header).length > 0) {
-                    response.setStatusCode(HttpStatus.SC_EXPECTATION_FAILED);
+                    response.setCode(HttpStatus.SC_EXPECTATION_FAILED);
                     return;
                 }
             }
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/handler/ProxyAndBasicAuthenticationValidationHandler.java b/components/camel-http/src/test/java/org/apache/camel/component/http/handler/ProxyAndBasicAuthenticationValidationHandler.java
index 272a511f0c7..4a324f436c9 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/handler/ProxyAndBasicAuthenticationValidationHandler.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/handler/ProxyAndBasicAuthenticationValidationHandler.java
@@ -18,11 +18,11 @@ package org.apache.camel.component.http.handler;
 
 import java.io.IOException;
 
-import org.apache.http.HttpException;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.protocol.HttpContext;
+import org.apache.hc.core5.http.ClassicHttpRequest;
+import org.apache.hc.core5.http.ClassicHttpResponse;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.protocol.HttpContext;
 
 public class ProxyAndBasicAuthenticationValidationHandler extends AuthenticationValidationHandler {
 
@@ -40,12 +40,12 @@ public class ProxyAndBasicAuthenticationValidationHandler extends Authentication
 
     @Override
     public void handle(
-            final HttpRequest request, final HttpResponse response,
+            final ClassicHttpRequest request, final ClassicHttpResponse response,
             final HttpContext context)
             throws HttpException, IOException {
 
         if (!getExpectedProxyCredential().equals(context.getAttribute("proxy-creds"))) {
-            response.setStatusCode(HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED);
+            response.setCode(HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED);
             return;
         }
 
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/handler/ProxyAuthenticationValidationHandler.java b/components/camel-http/src/test/java/org/apache/camel/component/http/handler/ProxyAuthenticationValidationHandler.java
index 05cfe35f714..1290fa44c81 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/handler/ProxyAuthenticationValidationHandler.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/handler/ProxyAuthenticationValidationHandler.java
@@ -18,11 +18,11 @@ package org.apache.camel.component.http.handler;
 
 import java.io.IOException;
 
-import org.apache.http.HttpException;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.protocol.HttpContext;
+import org.apache.hc.core5.http.ClassicHttpRequest;
+import org.apache.hc.core5.http.ClassicHttpResponse;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.protocol.HttpContext;
 
 public class ProxyAuthenticationValidationHandler extends BasicValidationHandler {
 
@@ -39,12 +39,12 @@ public class ProxyAuthenticationValidationHandler extends BasicValidationHandler
 
     @Override
     public void handle(
-            final HttpRequest request, final HttpResponse response,
+            final ClassicHttpRequest request, final ClassicHttpResponse response,
             final HttpContext context)
             throws HttpException, IOException {
 
         if (!getExpectedCredential().equals(context.getAttribute("proxy-creds"))) {
-            response.setStatusCode(HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED);
+            response.setCode(HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED);
             return;
         }
 
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/interceptor/BasicAuthTokenExtractor.java b/components/camel-http/src/test/java/org/apache/camel/component/http/interceptor/BasicAuthTokenExtractor.java
new file mode 100644
index 00000000000..4d92617eaee
--- /dev/null
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/interceptor/BasicAuthTokenExtractor.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.http.interceptor;
+
+import java.nio.charset.StandardCharsets;
+import java.util.Base64;
+
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpHeaders;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.ProtocolException;
+
+public class BasicAuthTokenExtractor {
+
+    public String extract(final HttpRequest request) throws HttpException {
+        String auth = null;
+
+        Header h = request.getFirstHeader(HttpHeaders.AUTHORIZATION);
+        if (h != null) {
+            final String s = h.getValue();
+            if (s != null) {
+                auth = s.trim();
+            }
+        }
+
+        if (auth != null) {
+            final int i = auth.indexOf(' ');
+            if (i == -1) {
+                throw new ProtocolException("Invalid Authorization header: " + auth);
+            }
+            final String authscheme = auth.substring(0, i);
+            if (authscheme.equalsIgnoreCase("basic")) {
+                final String s = auth.substring(i + 1).trim();
+                byte[] credsRaw = s.getBytes(StandardCharsets.US_ASCII);
+                Base64.Decoder codec = Base64.getDecoder();
+                auth = new String(codec.decode(credsRaw), StandardCharsets.US_ASCII);
+            }
+        }
+        return auth;
+    }
+}
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpGetWithBodyMethod.java b/components/camel-http/src/test/java/org/apache/camel/component/http/interceptor/RequestBasicAuth.java
similarity index 52%
rename from components/camel-http/src/main/java/org/apache/camel/component/http/HttpGetWithBodyMethod.java
rename to components/camel-http/src/test/java/org/apache/camel/component/http/interceptor/RequestBasicAuth.java
index efa7cb57af1..c2d8ce2f00c 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpGetWithBodyMethod.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/interceptor/RequestBasicAuth.java
@@ -14,29 +14,26 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.component.http;
+package org.apache.camel.component.http.interceptor;
 
-import java.net.URI;
+import java.io.IOException;
 
-import org.apache.http.HttpEntity;
-import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
+import org.apache.hc.core5.http.EntityDetails;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpRequestInterceptor;
+import org.apache.hc.core5.http.protocol.HttpContext;
 
-public class HttpGetWithBodyMethod extends HttpEntityEnclosingRequestBase {
+public class RequestBasicAuth implements HttpRequestInterceptor {
 
-    public static final String METHOD_NAME = "GET";
+    private final BasicAuthTokenExtractor authTokenExtractor;
 
-    public HttpGetWithBodyMethod(String uri, HttpEntity entity) {
-        setURI(URI.create(uri));
-        setEntity(entity);
-    }
-
-    public HttpGetWithBodyMethod(URI uri, HttpEntity entity) {
-        setURI(uri);
-        setEntity(entity);
+    public RequestBasicAuth() {
+        this.authTokenExtractor = new BasicAuthTokenExtractor();
     }
 
     @Override
-    public String getMethod() {
-        return METHOD_NAME;
+    public void process(HttpRequest request, EntityDetails entity, HttpContext context) throws HttpException, IOException {
+        context.setAttribute("creds", this.authTokenExtractor.extract(request));
     }
 }
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/interceptor/RequestProxyBasicAuth.java b/components/camel-http/src/test/java/org/apache/camel/component/http/interceptor/RequestProxyBasicAuth.java
new file mode 100644
index 00000000000..db0f2f92e53
--- /dev/null
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/interceptor/RequestProxyBasicAuth.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.http.interceptor;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.nio.charset.StandardCharsets;
+import java.util.Base64;
+
+import org.apache.hc.core5.http.EntityDetails;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpHeaders;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpRequestInterceptor;
+import org.apache.hc.core5.http.ProtocolException;
+import org.apache.hc.core5.http.protocol.HttpContext;
+
+public class RequestProxyBasicAuth implements HttpRequestInterceptor {
+    @Override
+    public void process(final HttpRequest request, final EntityDetails entity, final HttpContext context)
+            throws HttpException, IOException {
+        String auth = null;
+
+        try {
+            String requestLine = request.getUri().toString();
+            // assert we set a write GET URI
+            if (requestLine.contains("http://localhost")) {
+                throw new HttpException("Get a wrong proxy GET url");
+            }
+        } catch (URISyntaxException e) {
+            throw new RuntimeException(e);
+        }
+        Header h = request.getFirstHeader(HttpHeaders.PROXY_AUTHORIZATION);
+        if (h != null) {
+            String s = h.getValue();
+            if (s != null) {
+                auth = s.trim();
+            }
+        }
+
+        if (auth != null) {
+            int i = auth.indexOf(' ');
+            if (i == -1) {
+                throw new ProtocolException("Invalid Authorization header: " + auth);
+            }
+            String authscheme = auth.substring(0, i);
+            if (authscheme.equalsIgnoreCase("basic")) {
+                String s = auth.substring(i + 1).trim();
+                byte[] credsRaw = s.getBytes(StandardCharsets.US_ASCII);
+                Base64.Decoder codec = Base64.getDecoder();
+                String creds = new String(codec.decode(credsRaw), StandardCharsets.US_ASCII);
+                context.setAttribute("proxy-creds", creds);
+            }
+        }
+    }
+}
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/handler/DrinkAuthValidationHandler.java b/components/camel-http/src/test/java/org/apache/camel/component/http/interceptor/ResponseBasicUnauthorized.java
similarity index 50%
copy from components/camel-http/src/test/java/org/apache/camel/component/http/handler/DrinkAuthValidationHandler.java
copy to components/camel-http/src/test/java/org/apache/camel/component/http/interceptor/ResponseBasicUnauthorized.java
index 590ee5a60cb..9a723b811dc 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/handler/DrinkAuthValidationHandler.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/interceptor/ResponseBasicUnauthorized.java
@@ -14,26 +14,25 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.component.http.handler;
+package org.apache.camel.component.http.interceptor;
 
 import java.io.IOException;
 
-import org.apache.http.HttpException;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.protocol.HttpContext;
-import org.junit.jupiter.api.Assertions;
-
-public class DrinkAuthValidationHandler extends DrinkValidationHandler {
-
-    public DrinkAuthValidationHandler(String expectedMethod, String expectedQuery, Object expectedContent, String header) {
-        super(expectedMethod, expectedQuery, expectedContent, header);
-    }
+import org.apache.hc.core5.http.EntityDetails;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpHeaders;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpResponseInterceptor;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.protocol.HttpContext;
 
+public class ResponseBasicUnauthorized implements HttpResponseInterceptor {
     @Override
-    public void handle(HttpRequest request, HttpResponse response, HttpContext context) throws HttpException, IOException {
-        String auth = request.getFirstHeader("Authorization").getValue();
-        Assertions.assertTrue(auth.startsWith("Basic"));
-        super.handle(request, response, context);
+    public void process(HttpResponse response, EntityDetails details, HttpContext context) throws HttpException, IOException {
+        if (response.getCode() == HttpStatus.SC_UNAUTHORIZED) {
+            if (!response.containsHeader(HttpHeaders.WWW_AUTHENTICATE)) {
+                response.addHeader(HttpHeaders.WWW_AUTHENTICATE, "Basic realm=\"test realm\"");
+            }
+        }
     }
 }
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/handler/DrinkAuthValidationHandler.java b/components/camel-http/src/test/java/org/apache/camel/component/http/interceptor/ResponseProxyBasicUnauthorized.java
similarity index 50%
copy from components/camel-http/src/test/java/org/apache/camel/component/http/handler/DrinkAuthValidationHandler.java
copy to components/camel-http/src/test/java/org/apache/camel/component/http/interceptor/ResponseProxyBasicUnauthorized.java
index 590ee5a60cb..2ba6ff48b8f 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/handler/DrinkAuthValidationHandler.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/interceptor/ResponseProxyBasicUnauthorized.java
@@ -14,26 +14,24 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.component.http.handler;
+package org.apache.camel.component.http.interceptor;
 
 import java.io.IOException;
 
-import org.apache.http.HttpException;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.protocol.HttpContext;
-import org.junit.jupiter.api.Assertions;
-
-public class DrinkAuthValidationHandler extends DrinkValidationHandler {
-
-    public DrinkAuthValidationHandler(String expectedMethod, String expectedQuery, Object expectedContent, String header) {
-        super(expectedMethod, expectedQuery, expectedContent, header);
-    }
+import org.apache.hc.core5.http.EntityDetails;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpHeaders;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpResponseInterceptor;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.protocol.HttpContext;
 
+public class ResponseProxyBasicUnauthorized implements HttpResponseInterceptor {
     @Override
-    public void handle(HttpRequest request, HttpResponse response, HttpContext context) throws HttpException, IOException {
-        String auth = request.getFirstHeader("Authorization").getValue();
-        Assertions.assertTrue(auth.startsWith("Basic"));
-        super.handle(request, response, context);
+    public void process(final HttpResponse response, final EntityDetails entity, final HttpContext context)
+            throws HttpException, IOException {
+        if (response.getCode() == HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED) {
+            response.addHeader(HttpHeaders.PROXY_AUTHENTICATE, "Basic realm=\"test realm\"");
+        }
     }
 }
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/rest/RestCamelComponentVerifierTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/rest/RestCamelComponentVerifierTest.java
index 98b846e5125..3dd49fcc119 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/rest/RestCamelComponentVerifierTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/rest/RestCamelComponentVerifierTest.java
@@ -24,14 +24,14 @@ import java.util.Map;
 import org.apache.camel.component.extension.ComponentVerifierExtension;
 import org.apache.camel.component.http.BaseHttpTest;
 import org.apache.camel.component.http.handler.BasicValidationHandler;
+import org.apache.camel.component.http.interceptor.RequestBasicAuth;
+import org.apache.camel.component.http.interceptor.ResponseBasicUnauthorized;
 import org.apache.camel.component.rest.RestComponent;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
-import org.apache.http.localserver.RequestBasicAuth;
-import org.apache.http.localserver.ResponseBasicUnauthorized;
-import org.apache.http.protocol.HttpProcessor;
-import org.apache.http.protocol.ImmutableHttpProcessor;
-import org.apache.http.protocol.ResponseContent;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.protocol.DefaultHttpProcessor;
+import org.apache.hc.core5.http.protocol.HttpProcessor;
+import org.apache.hc.core5.http.protocol.ResponseContent;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -53,7 +53,7 @@ public class RestCamelComponentVerifierTest extends BaseHttpTest {
 
         localServer = ServerBootstrap.bootstrap()
                 .setHttpProcessor(getHttpProcessor())
-                .registerHandler("/verify", new BasicValidationHandler(GET.name(), null, null, getExpectedContent()))
+                .register("/verify", new BasicValidationHandler(GET.name(), null, null, getExpectedContent()))
                 .create();
 
         localServer.start();
@@ -83,7 +83,7 @@ public class RestCamelComponentVerifierTest extends BaseHttpTest {
     }
 
     private HttpProcessor getHttpProcessor() {
-        return new ImmutableHttpProcessor(
+        return new DefaultHttpProcessor(
                 Collections.singletonList(
                         new RequestBasicAuth()),
                 Arrays.asList(
@@ -97,9 +97,7 @@ public class RestCamelComponentVerifierTest extends BaseHttpTest {
 
     @SuppressWarnings("unused")
     protected String getLocalServerUri(String contextPath) {
-        return "http://"
-               + localServer.getInetAddress().getHostName()
-               + ":"
+        return "http://localhost:"
                + localServer.getLocalPort()
                + (contextPath != null
                        ? contextPath.startsWith("/") ? contextPath : "/" + contextPath


[camel] 14/15: CAMEL-18995: camel-cxf - Upgrade to HttpComponents 5.x

Posted by nf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

nfilotto pushed a commit to branch CAMEL-18995/upgrade-httpcomponents-5
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 2d49cc30a536bee6a6f2866ae6ac60dc693fa9ee
Author: Nicolas Filotto <nf...@talend.com>
AuthorDate: Fri Mar 17 12:38:12 2023 +0100

    CAMEL-18995: camel-cxf - Upgrade to HttpComponents 5.x
---
 components/camel-cxf/camel-cxf-rest/pom.xml        | 13 +--
 .../cxf/jaxrs/CxfRsConsumerWithBeanTest.java       | 25 +++---
 .../cxf/jaxrs/CxfRsConvertBodyToTest.java          | 25 +++---
 .../cxf/jaxrs/CxfRsResponseWithHeadersTest.java    | 25 +++---
 .../component/cxf/jaxrs/CxfRsStreamCacheTest.java  | 27 +++---
 .../CxfRsConsumerSimpleBindingImplTest.java        | 20 ++---
 .../CxfRsConsumerSimpleBindingTest.java            | 79 +++++++++---------
 components/camel-cxf/camel-cxf-soap/pom.xml        |  6 +-
 ...t.java => CxfConsumerNamespacePayLoadTest.java} | 27 +++---
 components/camel-cxf/camel-cxf-spring-rest/pom.xml | 13 +--
 .../component/cxf/jaxrs/CxfRsConsumerTest.java     | 39 ++++-----
 .../cxf/jaxrs/CxfRsEndpointWithPropertiesTest.java | 18 ++--
 .../camel/component/cxf/jaxrs/CxfRsRouterTest.java | 95 ++++++++--------------
 .../cxf/jaxrs/CxfRsSpringConsumerTest.java         | 19 ++---
 .../CxfRsConsumerSimpleBindingImplTest.java        | 20 ++---
 .../CxfRsConsumerSimpleBindingTest.java            | 79 +++++++++---------
 components/camel-cxf/camel-cxf-spring-soap/pom.xml |  6 +-
 .../cxf/CxfPayloadRouterContentLengthTest.java     | 48 +++++------
 18 files changed, 255 insertions(+), 329 deletions(-)

diff --git a/components/camel-cxf/camel-cxf-rest/pom.xml b/components/camel-cxf/camel-cxf-rest/pom.xml
index c971930c34a..fb7de2bfb62 100644
--- a/components/camel-cxf/camel-cxf-rest/pom.xml
+++ b/components/camel-cxf/camel-cxf-rest/pom.xml
@@ -163,16 +163,9 @@
 
 
         <dependency>
-            <groupId>org.apache.httpcomponents</groupId>
-            <artifactId>httpclient</artifactId>
-            <version>${httpclient4-version}</version>
-            <scope>test</scope>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.httpcomponents</groupId>
-            <artifactId>httpmime</artifactId>
-            <version>${httpclient4-version}</version>
+            <groupId>org.apache.httpcomponents.client5</groupId>
+            <artifactId>httpclient5</artifactId>
+            <version>${httpclient-version}</version>
             <scope>test</scope>
         </dependency>
 
diff --git a/components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConsumerWithBeanTest.java b/components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConsumerWithBeanTest.java
index 6a2ef98bb3e..8b067475d97 100644
--- a/components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConsumerWithBeanTest.java
+++ b/components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConsumerWithBeanTest.java
@@ -21,12 +21,13 @@ import org.apache.camel.component.cxf.common.CXFTestSupport;
 import org.apache.camel.component.cxf.jaxrs.testbean.ServiceUtil;
 import org.apache.camel.spi.Registry;
 import org.apache.camel.test.junit5.CamelTestSupport;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpPut;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClientBuilder;
-import org.apache.http.util.EntityUtils;
+import org.apache.hc.client5.http.classic.methods.HttpPut;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
+import org.apache.hc.core5.http.ContentType;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
+import org.apache.hc.core5.http.io.entity.StringEntity;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -63,17 +64,13 @@ public class CxfRsConsumerWithBeanTest extends CamelTestSupport {
 
     private void sendPutRequest(String uri) throws Exception {
         HttpPut put = new HttpPut(uri);
-        StringEntity entity = new StringEntity("string");
-        entity.setContentType("text/plain");
+        StringEntity entity = new StringEntity("string", ContentType.TEXT_PLAIN);
         put.setEntity(entity);
-        CloseableHttpClient httpclient = HttpClientBuilder.create().build();
 
-        try {
-            HttpResponse response = httpclient.execute(put);
-            assertEquals(200, response.getStatusLine().getStatusCode());
+        try (CloseableHttpClient httpclient = HttpClientBuilder.create().build();
+             CloseableHttpResponse response = httpclient.execute(put)) {
+            assertEquals(200, response.getCode());
             assertEquals("c20string", EntityUtils.toString(response.getEntity()));
-        } finally {
-            httpclient.close();
         }
     }
 }
diff --git a/components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConvertBodyToTest.java b/components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConvertBodyToTest.java
index da32417f645..8f9814124fd 100644
--- a/components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConvertBodyToTest.java
+++ b/components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConvertBodyToTest.java
@@ -23,12 +23,13 @@ import org.apache.camel.component.cxf.common.CXFTestSupport;
 import org.apache.camel.component.cxf.jaxrs.testbean.Customer;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.test.junit5.CamelTestSupport;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpPut;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClientBuilder;
-import org.apache.http.util.EntityUtils;
+import org.apache.hc.client5.http.classic.methods.HttpPut;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
+import org.apache.hc.core5.http.ContentType;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
+import org.apache.hc.core5.http.io.entity.StringEntity;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -63,18 +64,14 @@ public class CxfRsConvertBodyToTest extends CamelTestSupport {
         mock.message(0).body().isInstanceOf(Customer.class);
 
         HttpPut put = new HttpPut("http://localhost:" + CXT + "/rest/customerservice/customers");
-        StringEntity entity = new StringEntity(PUT_REQUEST, "ISO-8859-1");
-        entity.setContentType("text/xml; charset=ISO-8859-1");
+        StringEntity entity = new StringEntity(PUT_REQUEST, ContentType.parse("text/xml; charset=ISO-8859-1"));
         put.addHeader("test", "header1;header2");
         put.setEntity(entity);
-        CloseableHttpClient httpclient = HttpClientBuilder.create().build();
 
-        try {
-            HttpResponse response = httpclient.execute(put);
-            assertEquals(200, response.getStatusLine().getStatusCode());
+        try (CloseableHttpClient httpclient = HttpClientBuilder.create().build();
+             CloseableHttpResponse response = httpclient.execute(put)) {
+            assertEquals(200, response.getCode());
             assertEquals("", EntityUtils.toString(response.getEntity()));
-        } finally {
-            httpclient.close();
         }
     }
 
diff --git a/components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsResponseWithHeadersTest.java b/components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsResponseWithHeadersTest.java
index 80cec6ae71d..818646360da 100644
--- a/components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsResponseWithHeadersTest.java
+++ b/components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsResponseWithHeadersTest.java
@@ -20,12 +20,13 @@ import org.apache.camel.Exchange;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.cxf.common.CXFTestSupport;
 import org.apache.camel.test.junit5.CamelTestSupport;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpPut;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClientBuilder;
-import org.apache.http.util.EntityUtils;
+import org.apache.hc.client5.http.classic.methods.HttpPut;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
+import org.apache.hc.core5.http.ContentType;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
+import org.apache.hc.core5.http.io.entity.StringEntity;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -54,17 +55,13 @@ public class CxfRsResponseWithHeadersTest extends CamelTestSupport {
     @Test
     public void testPutConsumer() throws Exception {
         HttpPut put = new HttpPut("http://localhost:" + CXT + "/rest/customerservice/customers");
-        StringEntity entity = new StringEntity(PUT_REQUEST, "ISO-8859-1");
-        entity.setContentType("text/xml; charset=ISO-8859-1");
+        StringEntity entity = new StringEntity(PUT_REQUEST, ContentType.parse("text/xml; charset=ISO-8859-1"));
         put.setEntity(entity);
-        CloseableHttpClient httpclient = HttpClientBuilder.create().build();
 
-        try {
-            HttpResponse response = httpclient.execute(put);
-            assertEquals(404, response.getStatusLine().getStatusCode());
+        try (CloseableHttpClient httpclient = HttpClientBuilder.create().build();
+             CloseableHttpResponse response = httpclient.execute(put)) {
+            assertEquals(404, response.getCode());
             assertEquals("Cannot find customer", EntityUtils.toString(response.getEntity()));
-        } finally {
-            httpclient.close();
         }
     }
 
diff --git a/components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsStreamCacheTest.java b/components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsStreamCacheTest.java
index a7829a3af0f..3070a4fb98d 100644
--- a/components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsStreamCacheTest.java
+++ b/components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsStreamCacheTest.java
@@ -24,12 +24,13 @@ import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.converter.stream.CachedOutputStream;
 import org.apache.camel.spi.Synchronization;
 import org.apache.camel.test.junit5.CamelTestSupport;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpPut;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClientBuilder;
-import org.apache.http.util.EntityUtils;
+import org.apache.hc.client5.http.classic.methods.HttpPut;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
+import org.apache.hc.core5.http.ContentType;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
+import org.apache.hc.core5.http.io.entity.StringEntity;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -40,8 +41,8 @@ public class CxfRsStreamCacheTest extends CamelTestSupport {
     private static final String CXT = CXFTestSupport.getPort1() + CONTEXT;
     private static final String RESPONSE = "<pong xmlns=\"test/service\"/>";
 
-    private String cxfRsEndpointUri = "cxfrs://http://localhost:" + CXT + "/rest?synchronous=" + isSynchronous()
-                                      + "&dataFormat=PAYLOAD&resourceClasses=org.apache.camel.component.cxf.jaxrs.testbean.CustomerService";
+    private final String cxfRsEndpointUri = "cxfrs://http://localhost:" + CXT + "/rest?synchronous=" + isSynchronous()
+                                            + "&dataFormat=PAYLOAD&resourceClasses=org.apache.camel.component.cxf.jaxrs.testbean.CustomerService";
 
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
@@ -91,18 +92,14 @@ public class CxfRsStreamCacheTest extends CamelTestSupport {
         onComplete.expectedMessageCount(1);
 
         HttpPut put = new HttpPut("http://localhost:" + CXT + "/rest/customerservice/customers");
-        StringEntity entity = new StringEntity(PUT_REQUEST, "ISO-8859-1");
-        entity.setContentType("text/xml; charset=ISO-8859-1");
+        StringEntity entity = new StringEntity(PUT_REQUEST, ContentType.parse("text/xml; charset=ISO-8859-1"));
         put.addHeader("test", "header1;header2");
         put.setEntity(entity);
         CloseableHttpClient httpclient = HttpClientBuilder.create().build();
 
-        try {
-            HttpResponse response = httpclient.execute(put);
-            assertEquals(200, response.getStatusLine().getStatusCode());
+        try (CloseableHttpResponse response = httpclient.execute(put)) {
+            assertEquals(200, response.getCode());
             assertEquals(RESPONSE, EntityUtils.toString(response.getEntity()));
-        } finally {
-            httpclient.close();
         }
 
         mock.assertIsSatisfied();
diff --git a/components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/CxfRsConsumerSimpleBindingImplTest.java b/components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/CxfRsConsumerSimpleBindingImplTest.java
index 3e1fd441704..87e8f660d3a 100644
--- a/components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/CxfRsConsumerSimpleBindingImplTest.java
+++ b/components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/CxfRsConsumerSimpleBindingImplTest.java
@@ -29,12 +29,12 @@ import org.apache.camel.component.cxf.jaxrs.simplebinding.testbean.CustomerList;
 import org.apache.camel.component.cxf.jaxrs.simplebinding.testbean.Order;
 import org.apache.camel.component.cxf.jaxrs.simplebinding.testbean.Product;
 import org.apache.camel.test.junit5.CamelTestSupport;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.hc.client5.http.classic.methods.HttpGet;
+import org.apache.hc.client5.http.classic.methods.HttpPost;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
+import org.apache.hc.core5.http.io.entity.StringEntity;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -103,8 +103,8 @@ public class CxfRsConsumerSimpleBindingImplTest extends CamelTestSupport {
     public void testGetCustomerOnlyHeaders() throws Exception {
         HttpGet get = new HttpGet("http://localhost:" + PORT_PATH + "/rest/customerservice/customers/123");
         get.addHeader("Accept", "text/xml");
-        HttpResponse response = httpclient.execute(get);
-        assertEquals(200, response.getStatusLine().getStatusCode());
+        CloseableHttpResponse response = httpclient.execute(get);
+        assertEquals(200, response.getCode());
         Customer entity = (Customer) jaxb.createUnmarshaller().unmarshal(response.getEntity().getContent());
         assertEquals(123, entity.getId());
     }
@@ -117,7 +117,7 @@ public class CxfRsConsumerSimpleBindingImplTest extends CamelTestSupport {
         post.setEntity(new StringEntity(sw.toString()));
         post.addHeader("Content-Type", "text/xml");
         post.addHeader("Accept", "text/xml");
-        HttpResponse response = httpclient.execute(post);
-        assertEquals(200, response.getStatusLine().getStatusCode());
+        CloseableHttpResponse response = httpclient.execute(post);
+        assertEquals(200, response.getCode());
     }
 }
diff --git a/components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/CxfRsConsumerSimpleBindingTest.java b/components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/CxfRsConsumerSimpleBindingTest.java
index 767019c9498..f9fcca8c087 100644
--- a/components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/CxfRsConsumerSimpleBindingTest.java
+++ b/components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/CxfRsConsumerSimpleBindingTest.java
@@ -37,20 +37,19 @@ import org.apache.camel.component.cxf.jaxrs.simplebinding.testbean.Order;
 import org.apache.camel.component.cxf.jaxrs.simplebinding.testbean.Product;
 import org.apache.camel.test.junit5.CamelTestSupport;
 import org.apache.cxf.message.MessageContentsList;
-import org.apache.http.Consts;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpDelete;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.client.methods.HttpPut;
-import org.apache.http.entity.ContentType;
-import org.apache.http.entity.InputStreamEntity;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.entity.mime.HttpMultipartMode;
-import org.apache.http.entity.mime.MultipartEntityBuilder;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClientBuilder;
-import org.apache.http.util.EntityUtils;
+import org.apache.hc.client5.http.classic.methods.HttpDelete;
+import org.apache.hc.client5.http.classic.methods.HttpGet;
+import org.apache.hc.client5.http.classic.methods.HttpPost;
+import org.apache.hc.client5.http.classic.methods.HttpPut;
+import org.apache.hc.client5.http.entity.mime.HttpMultipartMode;
+import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
+import org.apache.hc.core5.http.ContentType;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
+import org.apache.hc.core5.http.io.entity.InputStreamEntity;
+import org.apache.hc.core5.http.io.entity.StringEntity;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -213,8 +212,8 @@ public class CxfRsConsumerSimpleBindingTest extends CamelTestSupport {
     public void testGetCustomerOnlyHeaders() throws Exception {
         HttpGet get = new HttpGet("http://localhost:" + PORT_PATH + "/rest/customerservice/customers/123");
         get.addHeader("Accept", "text/xml");
-        HttpResponse response = httpclient.execute(get);
-        assertEquals(200, response.getStatusLine().getStatusCode());
+        CloseableHttpResponse response = httpclient.execute(get);
+        assertEquals(200, response.getCode());
         Customer entity = (Customer) jaxb.createUnmarshaller().unmarshal(response.getEntity().getContent());
         assertEquals(123, entity.getId());
     }
@@ -223,8 +222,8 @@ public class CxfRsConsumerSimpleBindingTest extends CamelTestSupport {
     public void testGetCustomerHttp404CustomStatus() throws Exception {
         HttpGet get = new HttpGet("http://localhost:" + PORT_PATH + "/rest/customerservice/customers/456");
         get.addHeader("Accept", "text/xml");
-        HttpResponse response = httpclient.execute(get);
-        assertEquals(404, response.getStatusLine().getStatusCode());
+        CloseableHttpResponse response = httpclient.execute(get);
+        assertEquals(404, response.getCode());
     }
 
     @Test
@@ -235,8 +234,8 @@ public class CxfRsConsumerSimpleBindingTest extends CamelTestSupport {
         put.setEntity(new StringEntity(sw.toString()));
         put.addHeader("Content-Type", "text/xml");
         put.addHeader("Accept", "text/xml");
-        HttpResponse response = httpclient.execute(put);
-        assertEquals(200, response.getStatusLine().getStatusCode());
+        CloseableHttpResponse response = httpclient.execute(put);
+        assertEquals(200, response.getCode());
     }
 
     @Test
@@ -247,8 +246,8 @@ public class CxfRsConsumerSimpleBindingTest extends CamelTestSupport {
         post.setEntity(new StringEntity(sw.toString()));
         post.addHeader("Content-Type", "text/xml");
         post.addHeader("Accept", "text/xml");
-        HttpResponse response = httpclient.execute(post);
-        assertEquals(200, response.getStatusLine().getStatusCode());
+        CloseableHttpResponse response = httpclient.execute(post);
+        assertEquals(200, response.getCode());
     }
 
     @Test
@@ -256,8 +255,8 @@ public class CxfRsConsumerSimpleBindingTest extends CamelTestSupport {
         HttpGet get = new HttpGet("http://localhost:" + PORT_PATH + "/rest/customerservice/customers/vip/gold");
         get.addHeader("Content-Type", "text/xml");
         get.addHeader("Accept", "text/xml");
-        HttpResponse response = httpclient.execute(get);
-        assertEquals(200, response.getStatusLine().getStatusCode());
+        CloseableHttpResponse response = httpclient.execute(get);
+        assertEquals(200, response.getCode());
         CustomerList cl = (CustomerList) jaxb.createUnmarshaller()
                 .unmarshal(new StringReader(EntityUtils.toString(response.getEntity())));
         List<Customer> vips = cl.getCustomers();
@@ -274,16 +273,16 @@ public class CxfRsConsumerSimpleBindingTest extends CamelTestSupport {
         put.setEntity(new StringEntity(sw.toString()));
         put.addHeader("Content-Type", "text/xml");
         put.addHeader("Accept", "text/xml");
-        HttpResponse response = httpclient.execute(put);
-        assertEquals(200, response.getStatusLine().getStatusCode());
+        CloseableHttpResponse response = httpclient.execute(put);
+        assertEquals(200, response.getCode());
     }
 
     @Test
     public void testDeleteVipCustomer() throws Exception {
         HttpDelete delete = new HttpDelete("http://localhost:" + PORT_PATH + "/rest/customerservice/customers/vip/gold/123");
         delete.addHeader("Accept", "text/xml");
-        HttpResponse response = httpclient.execute(delete);
-        assertEquals(200, response.getStatusLine().getStatusCode());
+        CloseableHttpResponse response = httpclient.execute(delete);
+        assertEquals(200, response.getCode());
     }
 
     @Test
@@ -291,9 +290,9 @@ public class CxfRsConsumerSimpleBindingTest extends CamelTestSupport {
         HttpPost post = new HttpPost("http://localhost:" + PORT_PATH + "/rest/customerservice/customers/123/image_inputstream");
         post.addHeader("Content-Type", "image/jpeg");
         post.addHeader("Accept", "text/xml");
-        post.setEntity(new InputStreamEntity(this.getClass().getClassLoader().getResourceAsStream("java.jpg"), 100));
-        HttpResponse response = httpclient.execute(post);
-        assertEquals(200, response.getStatusLine().getStatusCode());
+        post.setEntity(new InputStreamEntity(this.getClass().getClassLoader().getResourceAsStream("java.jpg"), 100, null));
+        CloseableHttpResponse response = httpclient.execute(post);
+        assertEquals(200, response.getCode());
     }
 
     @Test
@@ -301,9 +300,9 @@ public class CxfRsConsumerSimpleBindingTest extends CamelTestSupport {
         HttpPost post = new HttpPost("http://localhost:" + PORT_PATH + "/rest/customerservice/customers/123/image_datahandler");
         post.addHeader("Content-Type", "image/jpeg");
         post.addHeader("Accept", "text/xml");
-        post.setEntity(new InputStreamEntity(this.getClass().getClassLoader().getResourceAsStream("java.jpg"), 100));
-        HttpResponse response = httpclient.execute(post);
-        assertEquals(200, response.getStatusLine().getStatusCode());
+        post.setEntity(new InputStreamEntity(this.getClass().getClassLoader().getResourceAsStream("java.jpg"), 100, null));
+        CloseableHttpResponse response = httpclient.execute(post);
+        assertEquals(200, response.getCode());
     }
 
     @Test
@@ -317,10 +316,10 @@ public class CxfRsConsumerSimpleBindingTest extends CamelTestSupport {
                 ContentType.create("image/jpeg"), "java.jpg");
         StringWriter sw = new StringWriter();
         jaxb.createMarshaller().marshal(new Customer(123, "Raul"), sw);
-        builder.addTextBody("body", sw.toString(), ContentType.create("text/xml", Consts.UTF_8));
+        builder.addTextBody("body", sw.toString(), ContentType.TEXT_XML);
         post.setEntity(builder.build());
-        HttpResponse response = httpclient.execute(post);
-        assertEquals(200, response.getStatusLine().getStatusCode());
+        CloseableHttpResponse response = httpclient.execute(post);
+        assertEquals(200, response.getCode());
     }
 
     @Test
@@ -334,10 +333,10 @@ public class CxfRsConsumerSimpleBindingTest extends CamelTestSupport {
                 ContentType.create("image/jpeg"), "java.jpg");
         StringWriter sw = new StringWriter();
         jaxb.createMarshaller().marshal(new Customer(123, "Raul"), sw);
-        builder.addTextBody("body", sw.toString(), ContentType.create("text/xml", Consts.UTF_8));
+        builder.addTextBody("body", sw.toString(), ContentType.TEXT_XML);
         post.setEntity(builder.build());
-        HttpResponse response = httpclient.execute(post);
-        assertEquals(200, response.getStatusLine().getStatusCode());
+        CloseableHttpResponse response = httpclient.execute(post);
+        assertEquals(200, response.getCode());
     }
 
 }
diff --git a/components/camel-cxf/camel-cxf-soap/pom.xml b/components/camel-cxf/camel-cxf-soap/pom.xml
index 019935364ce..c3538ae0101 100644
--- a/components/camel-cxf/camel-cxf-soap/pom.xml
+++ b/components/camel-cxf/camel-cxf-soap/pom.xml
@@ -180,9 +180,9 @@
         </dependency>
 
         <dependency>
-            <groupId>org.apache.httpcomponents</groupId>
-            <artifactId>httpclient</artifactId>
-            <version>${httpclient4-version}</version>
+            <groupId>org.apache.httpcomponents.client5</groupId>
+            <artifactId>httpclient5</artifactId>
+            <version>${httpclient-version}</version>
             <scope>test</scope>
         </dependency>
 
diff --git a/components/camel-cxf/camel-cxf-soap/src/test/java/org/apache/camel/component/cxf/jaxws/CxfConusmerNamespacePayLoadTest.java b/components/camel-cxf/camel-cxf-soap/src/test/java/org/apache/camel/component/cxf/jaxws/CxfConsumerNamespacePayLoadTest.java
similarity index 79%
rename from components/camel-cxf/camel-cxf-soap/src/test/java/org/apache/camel/component/cxf/jaxws/CxfConusmerNamespacePayLoadTest.java
rename to components/camel-cxf/camel-cxf-soap/src/test/java/org/apache/camel/component/cxf/jaxws/CxfConsumerNamespacePayLoadTest.java
index 1fe8edf649f..a11b332011f 100644
--- a/components/camel-cxf/camel-cxf-soap/src/test/java/org/apache/camel/component/cxf/jaxws/CxfConusmerNamespacePayLoadTest.java
+++ b/components/camel-cxf/camel-cxf-soap/src/test/java/org/apache/camel/component/cxf/jaxws/CxfConsumerNamespacePayLoadTest.java
@@ -16,19 +16,19 @@
  */
 package org.apache.camel.component.cxf.jaxws;
 
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.ContentType;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClientBuilder;
-import org.apache.http.util.EntityUtils;
+import org.apache.hc.client5.http.classic.methods.HttpPost;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
+import org.apache.hc.core5.http.ContentType;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
+import org.apache.hc.core5.http.io.entity.StringEntity;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
-public class CxfConusmerNamespacePayLoadTest extends CxfConsumerPayloadTest {
+public class CxfConsumerNamespacePayLoadTest extends CxfConsumerPayloadTest {
     private static final String ECHO_RESPONSE = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"
                                                 + "<soap:Body><ns1:echoResponse xmlns:ns1=\"http://jaxws.cxf.component.camel.apache.org/\">"
                                                 + "<return xmlns=\"http://jaxws.cxf.component.camel.apache.org/\">echo Hello World!</return>"
@@ -43,7 +43,7 @@ public class CxfConusmerNamespacePayLoadTest extends CxfConsumerPayloadTest {
     protected void checkRequest(String expect, String request) {
         if (expect.equals(ECHO_REQUEST)) {
             // just check the namespace of xsd
-            assertTrue(request.indexOf("xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"") > 0, "Expect to find the namesapce");
+            assertTrue(request.indexOf("xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"") > 0, "Expect to find the namespace");
         }
     }
 
@@ -56,16 +56,13 @@ public class CxfConusmerNamespacePayLoadTest extends CxfConsumerPayloadTest {
 
         StringEntity entity = new StringEntity(ECHO_REQUEST, ContentType.create("text/xml", "ISO-8859-1"));
         post.setEntity(entity);
-        CloseableHttpClient httpclient = HttpClientBuilder.create().build();
 
-        try {
-            HttpResponse response = httpclient.execute(post);
-            assertEquals(200, response.getStatusLine().getStatusCode());
+        try (CloseableHttpClient httpclient = HttpClientBuilder.create().build();
+             CloseableHttpResponse response = httpclient.execute(post)) {
+            assertEquals(200, response.getCode());
             String responseBody = EntityUtils.toString(response.getEntity());
 
             assertEquals(ECHO_RESPONSE, responseBody, "Get a wrong response");
-        } finally {
-            httpclient.close();
         }
 
     }
diff --git a/components/camel-cxf/camel-cxf-spring-rest/pom.xml b/components/camel-cxf/camel-cxf-spring-rest/pom.xml
index 3172a6b8d02..012d4df4ceb 100644
--- a/components/camel-cxf/camel-cxf-spring-rest/pom.xml
+++ b/components/camel-cxf/camel-cxf-spring-rest/pom.xml
@@ -157,16 +157,9 @@
 
 
         <dependency>
-            <groupId>org.apache.httpcomponents</groupId>
-            <artifactId>httpclient</artifactId>
-            <version>${httpclient4-version}</version>
-            <scope>test</scope>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.httpcomponents</groupId>
-            <artifactId>httpmime</artifactId>
-            <version>${httpclient4-version}</version>
+            <groupId>org.apache.httpcomponents.client5</groupId>
+            <artifactId>httpclient5</artifactId>
+            <version>${httpclient-version}</version>
             <scope>test</scope>
         </dependency>
 
diff --git a/components/camel-cxf/camel-cxf-spring-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConsumerTest.java b/components/camel-cxf/camel-cxf-spring-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConsumerTest.java
index 6f1d58acb8b..ac356a95696 100644
--- a/components/camel-cxf/camel-cxf-spring-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConsumerTest.java
+++ b/components/camel-cxf/camel-cxf-spring-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConsumerTest.java
@@ -45,13 +45,14 @@ import org.apache.camel.component.cxf.jaxrs.testbean.Customer;
 import org.apache.camel.component.cxf.jaxrs.testbean.CustomerService;
 import org.apache.camel.spi.Registry;
 import org.apache.camel.test.junit5.CamelTestSupport;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpPut;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClientBuilder;
-import org.apache.http.util.EntityUtils;
+import org.apache.hc.client5.http.classic.methods.HttpGet;
+import org.apache.hc.client5.http.classic.methods.HttpPut;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
+import org.apache.hc.core5.http.ContentType;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
+import org.apache.hc.core5.http.io.entity.StringEntity;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -106,15 +107,11 @@ public class CxfRsConsumerTest extends CamelTestSupport {
     private void invokeGetCustomer(String uri, String expect) throws Exception {
         HttpGet get = new HttpGet(uri);
         get.addHeader("Accept", "application/json");
-        CloseableHttpClient httpclient = HttpClientBuilder.create().build();
 
-        try {
-            HttpResponse response = httpclient.execute(get);
-            assertEquals(200, response.getStatusLine().getStatusCode());
-            assertEquals(expect,
-                    EntityUtils.toString(response.getEntity()));
-        } finally {
-            httpclient.close();
+        try (CloseableHttpClient httpclient = HttpClientBuilder.create().build();
+             CloseableHttpResponse response = httpclient.execute(get)) {
+            assertEquals(200, response.getCode());
+            assertEquals(expect, EntityUtils.toString(response.getEntity()));
         }
     }
 
@@ -209,18 +206,14 @@ public class CxfRsConsumerTest extends CamelTestSupport {
     @Test
     public void testPutConsumer() throws Exception {
         HttpPut put = new HttpPut("http://localhost:" + CXT + "/rest/customerservice/customers");
-        StringEntity entity = new StringEntity(PUT_REQUEST, "ISO-8859-1");
-        entity.setContentType("text/xml; charset=ISO-8859-1");
+        StringEntity entity = new StringEntity(PUT_REQUEST, ContentType.parse("text/xml; charset=ISO-8859-1"));
         put.addHeader("test", "header1;header2");
         put.setEntity(entity);
-        CloseableHttpClient httpclient = HttpClientBuilder.create().build();
 
-        try {
-            HttpResponse response = httpclient.execute(put);
-            assertEquals(200, response.getStatusLine().getStatusCode());
+        try (CloseableHttpClient httpclient = HttpClientBuilder.create().build();
+             CloseableHttpResponse response = httpclient.execute(put)) {
+            assertEquals(200, response.getCode());
             assertEquals("", EntityUtils.toString(response.getEntity()));
-        } finally {
-            httpclient.close();
         }
     }
 
diff --git a/components/camel-cxf/camel-cxf-spring-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpointWithPropertiesTest.java b/components/camel-cxf/camel-cxf-spring-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpointWithPropertiesTest.java
index 5f425439f16..cdc4040f1ce 100644
--- a/components/camel-cxf/camel-cxf-spring-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpointWithPropertiesTest.java
+++ b/components/camel-cxf/camel-cxf-spring-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpointWithPropertiesTest.java
@@ -22,10 +22,10 @@ import java.util.Map;
 import org.apache.camel.CamelContext;
 import org.apache.camel.component.cxf.spring.AbstractSpringBeanTestSupport;
 import org.apache.cxf.feature.Feature;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.hc.client5.http.classic.methods.HttpGet;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -52,12 +52,10 @@ public class CxfRsEndpointWithPropertiesTest extends AbstractSpringBeanTestSuppo
         assertEquals("aValue", endpointProps.get("aKey"), "Wrong property value");
 
         HttpGet get = new HttpGet(testEndpoint.getAddress());
-        CloseableHttpClient httpclient = HttpClientBuilder.create().build();
-        try {
-            HttpResponse response = httpclient.execute(get);
-            assertEquals(404, response.getStatusLine().getStatusCode());
-        } finally {
-            httpclient.close();
+
+        try (CloseableHttpClient httpclient = HttpClientBuilder.create().build();
+             CloseableHttpResponse response = httpclient.execute(get)) {
+            assertEquals(404, response.getCode());
         }
     }
 
diff --git a/components/camel-cxf/camel-cxf-spring-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsRouterTest.java b/components/camel-cxf/camel-cxf-spring-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsRouterTest.java
index 31904e7e7cd..45fa5ea6531 100644
--- a/components/camel-cxf/camel-cxf-spring-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsRouterTest.java
+++ b/components/camel-cxf/camel-cxf-spring-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsRouterTest.java
@@ -18,15 +18,16 @@ package org.apache.camel.component.cxf.jaxrs;
 
 import org.apache.camel.component.cxf.common.CXFTestSupport;
 import org.apache.camel.test.spring.junit5.CamelSpringTestSupport;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpDelete;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.client.methods.HttpPut;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClientBuilder;
-import org.apache.http.util.EntityUtils;
+import org.apache.hc.client5.http.classic.methods.HttpDelete;
+import org.apache.hc.client5.http.classic.methods.HttpGet;
+import org.apache.hc.client5.http.classic.methods.HttpPost;
+import org.apache.hc.client5.http.classic.methods.HttpPut;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
+import org.apache.hc.core5.http.ContentType;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
+import org.apache.hc.core5.http.io.entity.StringEntity;
 import org.junit.jupiter.api.Test;
 import org.springframework.context.support.AbstractXmlApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -64,15 +65,12 @@ public class CxfRsRouterTest extends CamelSpringTestSupport {
     public void testGetCustomer() throws Exception {
         HttpGet get = new HttpGet("http://localhost:" + getPort() + "/CxfRsRouterTest/route/customerservice/customers/123");
         get.addHeader("Accept", "application/json");
-        CloseableHttpClient httpclient = HttpClientBuilder.create().build();
 
-        try {
-            HttpResponse response = httpclient.execute(get);
-            assertEquals(200, response.getStatusLine().getStatusCode());
+        try (CloseableHttpClient httpclient = HttpClientBuilder.create().build();
+             CloseableHttpResponse response = httpclient.execute(get)) {
+            assertEquals(200, response.getCode());
             assertEquals("{\"Customer\":{\"id\":123,\"name\":\"John\"}}",
                     EntityUtils.toString(response.getEntity()));
-        } finally {
-            httpclient.close();
         }
     }
 
@@ -80,15 +78,12 @@ public class CxfRsRouterTest extends CamelSpringTestSupport {
     public void testGetCustomerWithQuery() throws Exception {
         HttpGet get = new HttpGet("http://localhost:" + getPort() + "/CxfRsRouterTest/route/customerservice/customers?id=123");
         get.addHeader("Accept", "application/json");
-        CloseableHttpClient httpclient = HttpClientBuilder.create().build();
 
-        try {
-            HttpResponse response = httpclient.execute(get);
-            assertEquals(200, response.getStatusLine().getStatusCode());
+        try (CloseableHttpClient httpclient = HttpClientBuilder.create().build();
+             CloseableHttpResponse response = httpclient.execute(get)) {
+            assertEquals(200, response.getCode());
             assertEquals("{\"Customer\":{\"id\":123,\"name\":\"John\"}}",
                     EntityUtils.toString(response.getEntity()));
-        } finally {
-            httpclient.close();
         }
     }
 
@@ -96,11 +91,10 @@ public class CxfRsRouterTest extends CamelSpringTestSupport {
     public void testGetCustomers() throws Exception {
         HttpGet get = new HttpGet("http://localhost:" + getPort() + "/CxfRsRouterTest/route/customerservice/customers/");
         get.addHeader("Accept", "application/xml");
-        CloseableHttpClient httpclient = HttpClientBuilder.create().build();
 
-        try {
-            HttpResponse response = httpclient.execute(get);
-            assertEquals(200, response.getStatusLine().getStatusCode());
+        try (CloseableHttpClient httpclient = HttpClientBuilder.create().build();
+             CloseableHttpResponse response = httpclient.execute(get)) {
+            assertEquals(200, response.getCode());
             // order returned can differ on OS so match for both orders
             String s = EntityUtils.toString(response.getEntity());
             assertNotNull(s);
@@ -112,8 +106,6 @@ public class CxfRsRouterTest extends CamelSpringTestSupport {
             if (!m1 && !m2) {
                 fail("Not expected body returned: " + s);
             }
-        } finally {
-            httpclient.close();
         }
     }
 
@@ -122,32 +114,25 @@ public class CxfRsRouterTest extends CamelSpringTestSupport {
         HttpGet get = new HttpGet(
                 "http://localhost:" + getPort() + "/CxfRsRouterTest/route/customerservice/orders/223/products/323");
         get.addHeader("Accept", "application/json");
-        CloseableHttpClient httpclient = HttpClientBuilder.create().build();
 
-        try {
-            HttpResponse response = httpclient.execute(get);
-            assertEquals(200, response.getStatusLine().getStatusCode());
+        try (CloseableHttpClient httpclient = HttpClientBuilder.create().build();
+             CloseableHttpResponse response = httpclient.execute(get)) {
+            assertEquals(200, response.getCode());
             assertEquals("{\"Product\":{\"description\":\"product 323\",\"id\":323}}",
                     EntityUtils.toString(response.getEntity()));
-        } finally {
-            httpclient.close();
         }
     }
 
     @Test
     public void testPutConsumer() throws Exception {
         HttpPut put = new HttpPut("http://localhost:" + getPort() + "/CxfRsRouterTest/route/customerservice/customers");
-        StringEntity entity = new StringEntity(PUT_REQUEST, "ISO-8859-1");
-        entity.setContentType("text/xml; charset=ISO-8859-1");
+        StringEntity entity = new StringEntity(PUT_REQUEST, ContentType.parse("text/xml; charset=ISO-8859-1"));
         put.setEntity(entity);
-        CloseableHttpClient httpclient = HttpClientBuilder.create().build();
 
-        try {
-            HttpResponse response = httpclient.execute(put);
-            assertEquals(200, response.getStatusLine().getStatusCode());
+        try (CloseableHttpClient httpclient = HttpClientBuilder.create().build();
+             CloseableHttpResponse response = httpclient.execute(put)) {
+            assertEquals(200, response.getCode());
             assertEquals("", EntityUtils.toString(response.getEntity()));
-        } finally {
-            httpclient.close();
         }
     }
 
@@ -155,14 +140,12 @@ public class CxfRsRouterTest extends CamelSpringTestSupport {
     public void testPostConsumer() throws Exception {
         HttpPost post = new HttpPost("http://localhost:" + getPort() + "/CxfRsRouterTest/route/customerservice/customers");
         post.addHeader("Accept", "text/xml");
-        StringEntity entity = new StringEntity(POST_REQUEST, "ISO-8859-1");
-        entity.setContentType("text/xml; charset=ISO-8859-1");
+        StringEntity entity = new StringEntity(POST_REQUEST, ContentType.parse("text/xml; charset=ISO-8859-1"));
         post.setEntity(entity);
-        CloseableHttpClient httpclient = HttpClientBuilder.create().build();
 
-        try {
-            HttpResponse response = httpclient.execute(post);
-            assertEquals(200, response.getStatusLine().getStatusCode());
+        try (CloseableHttpClient httpclient = HttpClientBuilder.create().build()) {
+            CloseableHttpResponse response = httpclient.execute(post);
+            assertEquals(200, response.getCode());
             assertEquals(
                     "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Customer><id>124</id><name>Jack</name></Customer>",
                     EntityUtils.toString(response.getEntity()));
@@ -171,9 +154,7 @@ public class CxfRsRouterTest extends CamelSpringTestSupport {
                     = new HttpDelete("http://localhost:" + getPort() + "/CxfRsRouterTest/route/customerservice/customers/124/");
             response = httpclient.execute(del);
             // need to check the response of delete method
-            assertEquals(200, response.getStatusLine().getStatusCode());
-        } finally {
-            httpclient.close();
+            assertEquals(200, response.getCode());
         }
 
     }
@@ -183,14 +164,12 @@ public class CxfRsRouterTest extends CamelSpringTestSupport {
         HttpPost post = new HttpPost(
                 "http://localhost:" + getPort() + "/CxfRsRouterTest/route/customerservice/customersUniqueResponseCode");
         post.addHeader("Accept", "text/xml");
-        StringEntity entity = new StringEntity(POST_REQUEST, "ISO-8859-1");
-        entity.setContentType("text/xml; charset=ISO-8859-1");
+        StringEntity entity = new StringEntity(POST_REQUEST, ContentType.parse("text/xml; charset=ISO-8859-1"));
         post.setEntity(entity);
-        CloseableHttpClient httpclient = HttpClientBuilder.create().build();
 
-        try {
-            HttpResponse response = httpclient.execute(post);
-            assertEquals(201, response.getStatusLine().getStatusCode());
+        try (CloseableHttpClient httpclient = HttpClientBuilder.create().build()) {
+            CloseableHttpResponse response = httpclient.execute(post);
+            assertEquals(201, response.getCode());
             assertEquals(
                     "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Customer><id>124</id><name>Jack</name></Customer>",
                     EntityUtils.toString(response.getEntity()));
@@ -199,9 +178,7 @@ public class CxfRsRouterTest extends CamelSpringTestSupport {
                     = new HttpDelete("http://localhost:" + getPort() + "/CxfRsRouterTest/route/customerservice/customers/124/");
             response = httpclient.execute(del);
             // need to check the response of delete method
-            assertEquals(200, response.getStatusLine().getStatusCode());
-        } finally {
-            httpclient.close();
+            assertEquals(200, response.getCode());
         }
     }
 }
diff --git a/components/camel-cxf/camel-cxf-spring-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsSpringConsumerTest.java b/components/camel-cxf/camel-cxf-spring-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsSpringConsumerTest.java
index c01274b90b7..780fdd807f6 100644
--- a/components/camel-cxf/camel-cxf-spring-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsSpringConsumerTest.java
+++ b/components/camel-cxf/camel-cxf-spring-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsSpringConsumerTest.java
@@ -25,10 +25,10 @@ import org.apache.camel.component.cxf.jaxrs.testbean.CustomException;
 import org.apache.camel.component.cxf.jaxrs.testbean.Customer;
 import org.apache.camel.test.spring.junit5.CamelSpringTestSupport;
 import org.apache.cxf.jaxrs.client.WebClient;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.hc.client5.http.classic.methods.HttpGet;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
 import org.junit.jupiter.api.Test;
 import org.springframework.context.support.AbstractApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -92,15 +92,12 @@ public class CxfRsSpringConsumerTest extends CamelSpringTestSupport {
     private void doTestMappingException(String address) throws Exception {
         HttpGet get = new HttpGet(address);
         get.addHeader("Accept", "application/json");
-        CloseableHttpClient httpclient = HttpClientBuilder.create().build();
 
-        try {
-            HttpResponse response = httpclient.execute(get);
-            assertEquals(500, response.getStatusLine().getStatusCode(), "Get a wrong status code");
+        try (CloseableHttpClient httpclient = HttpClientBuilder.create().build();
+             CloseableHttpResponse response = httpclient.execute(get)) {
+            assertEquals(500, response.getCode(), "Get a wrong status code");
             assertEquals("exception: Here is the exception", response.getHeaders("exception")[0].toString(),
-                    "Get a worng message header");
-        } finally {
-            httpclient.close();
+                    "Get a wrong message header");
         }
     }
 
diff --git a/components/camel-cxf/camel-cxf-spring-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/CxfRsConsumerSimpleBindingImplTest.java b/components/camel-cxf/camel-cxf-spring-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/CxfRsConsumerSimpleBindingImplTest.java
index 3e1fd441704..87e8f660d3a 100644
--- a/components/camel-cxf/camel-cxf-spring-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/CxfRsConsumerSimpleBindingImplTest.java
+++ b/components/camel-cxf/camel-cxf-spring-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/CxfRsConsumerSimpleBindingImplTest.java
@@ -29,12 +29,12 @@ import org.apache.camel.component.cxf.jaxrs.simplebinding.testbean.CustomerList;
 import org.apache.camel.component.cxf.jaxrs.simplebinding.testbean.Order;
 import org.apache.camel.component.cxf.jaxrs.simplebinding.testbean.Product;
 import org.apache.camel.test.junit5.CamelTestSupport;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.hc.client5.http.classic.methods.HttpGet;
+import org.apache.hc.client5.http.classic.methods.HttpPost;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
+import org.apache.hc.core5.http.io.entity.StringEntity;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -103,8 +103,8 @@ public class CxfRsConsumerSimpleBindingImplTest extends CamelTestSupport {
     public void testGetCustomerOnlyHeaders() throws Exception {
         HttpGet get = new HttpGet("http://localhost:" + PORT_PATH + "/rest/customerservice/customers/123");
         get.addHeader("Accept", "text/xml");
-        HttpResponse response = httpclient.execute(get);
-        assertEquals(200, response.getStatusLine().getStatusCode());
+        CloseableHttpResponse response = httpclient.execute(get);
+        assertEquals(200, response.getCode());
         Customer entity = (Customer) jaxb.createUnmarshaller().unmarshal(response.getEntity().getContent());
         assertEquals(123, entity.getId());
     }
@@ -117,7 +117,7 @@ public class CxfRsConsumerSimpleBindingImplTest extends CamelTestSupport {
         post.setEntity(new StringEntity(sw.toString()));
         post.addHeader("Content-Type", "text/xml");
         post.addHeader("Accept", "text/xml");
-        HttpResponse response = httpclient.execute(post);
-        assertEquals(200, response.getStatusLine().getStatusCode());
+        CloseableHttpResponse response = httpclient.execute(post);
+        assertEquals(200, response.getCode());
     }
 }
diff --git a/components/camel-cxf/camel-cxf-spring-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/CxfRsConsumerSimpleBindingTest.java b/components/camel-cxf/camel-cxf-spring-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/CxfRsConsumerSimpleBindingTest.java
index 767019c9498..f9fcca8c087 100644
--- a/components/camel-cxf/camel-cxf-spring-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/CxfRsConsumerSimpleBindingTest.java
+++ b/components/camel-cxf/camel-cxf-spring-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/CxfRsConsumerSimpleBindingTest.java
@@ -37,20 +37,19 @@ import org.apache.camel.component.cxf.jaxrs.simplebinding.testbean.Order;
 import org.apache.camel.component.cxf.jaxrs.simplebinding.testbean.Product;
 import org.apache.camel.test.junit5.CamelTestSupport;
 import org.apache.cxf.message.MessageContentsList;
-import org.apache.http.Consts;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpDelete;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.client.methods.HttpPut;
-import org.apache.http.entity.ContentType;
-import org.apache.http.entity.InputStreamEntity;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.entity.mime.HttpMultipartMode;
-import org.apache.http.entity.mime.MultipartEntityBuilder;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClientBuilder;
-import org.apache.http.util.EntityUtils;
+import org.apache.hc.client5.http.classic.methods.HttpDelete;
+import org.apache.hc.client5.http.classic.methods.HttpGet;
+import org.apache.hc.client5.http.classic.methods.HttpPost;
+import org.apache.hc.client5.http.classic.methods.HttpPut;
+import org.apache.hc.client5.http.entity.mime.HttpMultipartMode;
+import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
+import org.apache.hc.core5.http.ContentType;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
+import org.apache.hc.core5.http.io.entity.InputStreamEntity;
+import org.apache.hc.core5.http.io.entity.StringEntity;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -213,8 +212,8 @@ public class CxfRsConsumerSimpleBindingTest extends CamelTestSupport {
     public void testGetCustomerOnlyHeaders() throws Exception {
         HttpGet get = new HttpGet("http://localhost:" + PORT_PATH + "/rest/customerservice/customers/123");
         get.addHeader("Accept", "text/xml");
-        HttpResponse response = httpclient.execute(get);
-        assertEquals(200, response.getStatusLine().getStatusCode());
+        CloseableHttpResponse response = httpclient.execute(get);
+        assertEquals(200, response.getCode());
         Customer entity = (Customer) jaxb.createUnmarshaller().unmarshal(response.getEntity().getContent());
         assertEquals(123, entity.getId());
     }
@@ -223,8 +222,8 @@ public class CxfRsConsumerSimpleBindingTest extends CamelTestSupport {
     public void testGetCustomerHttp404CustomStatus() throws Exception {
         HttpGet get = new HttpGet("http://localhost:" + PORT_PATH + "/rest/customerservice/customers/456");
         get.addHeader("Accept", "text/xml");
-        HttpResponse response = httpclient.execute(get);
-        assertEquals(404, response.getStatusLine().getStatusCode());
+        CloseableHttpResponse response = httpclient.execute(get);
+        assertEquals(404, response.getCode());
     }
 
     @Test
@@ -235,8 +234,8 @@ public class CxfRsConsumerSimpleBindingTest extends CamelTestSupport {
         put.setEntity(new StringEntity(sw.toString()));
         put.addHeader("Content-Type", "text/xml");
         put.addHeader("Accept", "text/xml");
-        HttpResponse response = httpclient.execute(put);
-        assertEquals(200, response.getStatusLine().getStatusCode());
+        CloseableHttpResponse response = httpclient.execute(put);
+        assertEquals(200, response.getCode());
     }
 
     @Test
@@ -247,8 +246,8 @@ public class CxfRsConsumerSimpleBindingTest extends CamelTestSupport {
         post.setEntity(new StringEntity(sw.toString()));
         post.addHeader("Content-Type", "text/xml");
         post.addHeader("Accept", "text/xml");
-        HttpResponse response = httpclient.execute(post);
-        assertEquals(200, response.getStatusLine().getStatusCode());
+        CloseableHttpResponse response = httpclient.execute(post);
+        assertEquals(200, response.getCode());
     }
 
     @Test
@@ -256,8 +255,8 @@ public class CxfRsConsumerSimpleBindingTest extends CamelTestSupport {
         HttpGet get = new HttpGet("http://localhost:" + PORT_PATH + "/rest/customerservice/customers/vip/gold");
         get.addHeader("Content-Type", "text/xml");
         get.addHeader("Accept", "text/xml");
-        HttpResponse response = httpclient.execute(get);
-        assertEquals(200, response.getStatusLine().getStatusCode());
+        CloseableHttpResponse response = httpclient.execute(get);
+        assertEquals(200, response.getCode());
         CustomerList cl = (CustomerList) jaxb.createUnmarshaller()
                 .unmarshal(new StringReader(EntityUtils.toString(response.getEntity())));
         List<Customer> vips = cl.getCustomers();
@@ -274,16 +273,16 @@ public class CxfRsConsumerSimpleBindingTest extends CamelTestSupport {
         put.setEntity(new StringEntity(sw.toString()));
         put.addHeader("Content-Type", "text/xml");
         put.addHeader("Accept", "text/xml");
-        HttpResponse response = httpclient.execute(put);
-        assertEquals(200, response.getStatusLine().getStatusCode());
+        CloseableHttpResponse response = httpclient.execute(put);
+        assertEquals(200, response.getCode());
     }
 
     @Test
     public void testDeleteVipCustomer() throws Exception {
         HttpDelete delete = new HttpDelete("http://localhost:" + PORT_PATH + "/rest/customerservice/customers/vip/gold/123");
         delete.addHeader("Accept", "text/xml");
-        HttpResponse response = httpclient.execute(delete);
-        assertEquals(200, response.getStatusLine().getStatusCode());
+        CloseableHttpResponse response = httpclient.execute(delete);
+        assertEquals(200, response.getCode());
     }
 
     @Test
@@ -291,9 +290,9 @@ public class CxfRsConsumerSimpleBindingTest extends CamelTestSupport {
         HttpPost post = new HttpPost("http://localhost:" + PORT_PATH + "/rest/customerservice/customers/123/image_inputstream");
         post.addHeader("Content-Type", "image/jpeg");
         post.addHeader("Accept", "text/xml");
-        post.setEntity(new InputStreamEntity(this.getClass().getClassLoader().getResourceAsStream("java.jpg"), 100));
-        HttpResponse response = httpclient.execute(post);
-        assertEquals(200, response.getStatusLine().getStatusCode());
+        post.setEntity(new InputStreamEntity(this.getClass().getClassLoader().getResourceAsStream("java.jpg"), 100, null));
+        CloseableHttpResponse response = httpclient.execute(post);
+        assertEquals(200, response.getCode());
     }
 
     @Test
@@ -301,9 +300,9 @@ public class CxfRsConsumerSimpleBindingTest extends CamelTestSupport {
         HttpPost post = new HttpPost("http://localhost:" + PORT_PATH + "/rest/customerservice/customers/123/image_datahandler");
         post.addHeader("Content-Type", "image/jpeg");
         post.addHeader("Accept", "text/xml");
-        post.setEntity(new InputStreamEntity(this.getClass().getClassLoader().getResourceAsStream("java.jpg"), 100));
-        HttpResponse response = httpclient.execute(post);
-        assertEquals(200, response.getStatusLine().getStatusCode());
+        post.setEntity(new InputStreamEntity(this.getClass().getClassLoader().getResourceAsStream("java.jpg"), 100, null));
+        CloseableHttpResponse response = httpclient.execute(post);
+        assertEquals(200, response.getCode());
     }
 
     @Test
@@ -317,10 +316,10 @@ public class CxfRsConsumerSimpleBindingTest extends CamelTestSupport {
                 ContentType.create("image/jpeg"), "java.jpg");
         StringWriter sw = new StringWriter();
         jaxb.createMarshaller().marshal(new Customer(123, "Raul"), sw);
-        builder.addTextBody("body", sw.toString(), ContentType.create("text/xml", Consts.UTF_8));
+        builder.addTextBody("body", sw.toString(), ContentType.TEXT_XML);
         post.setEntity(builder.build());
-        HttpResponse response = httpclient.execute(post);
-        assertEquals(200, response.getStatusLine().getStatusCode());
+        CloseableHttpResponse response = httpclient.execute(post);
+        assertEquals(200, response.getCode());
     }
 
     @Test
@@ -334,10 +333,10 @@ public class CxfRsConsumerSimpleBindingTest extends CamelTestSupport {
                 ContentType.create("image/jpeg"), "java.jpg");
         StringWriter sw = new StringWriter();
         jaxb.createMarshaller().marshal(new Customer(123, "Raul"), sw);
-        builder.addTextBody("body", sw.toString(), ContentType.create("text/xml", Consts.UTF_8));
+        builder.addTextBody("body", sw.toString(), ContentType.TEXT_XML);
         post.setEntity(builder.build());
-        HttpResponse response = httpclient.execute(post);
-        assertEquals(200, response.getStatusLine().getStatusCode());
+        CloseableHttpResponse response = httpclient.execute(post);
+        assertEquals(200, response.getCode());
     }
 
 }
diff --git a/components/camel-cxf/camel-cxf-spring-soap/pom.xml b/components/camel-cxf/camel-cxf-spring-soap/pom.xml
index 1e607f1acce..3099abc7220 100644
--- a/components/camel-cxf/camel-cxf-spring-soap/pom.xml
+++ b/components/camel-cxf/camel-cxf-spring-soap/pom.xml
@@ -164,9 +164,9 @@
         </dependency>
 
         <dependency>
-            <groupId>org.apache.httpcomponents</groupId>
-            <artifactId>httpclient</artifactId>
-            <version>${httpclient4-version}</version>
+            <groupId>org.apache.httpcomponents.client5</groupId>
+            <artifactId>httpclient5</artifactId>
+            <version>${httpclient-version}</version>
             <scope>test</scope>
         </dependency>
 
diff --git a/components/camel-cxf/camel-cxf-spring-soap/src/test/java/org/apache/camel/component/cxf/CxfPayloadRouterContentLengthTest.java b/components/camel-cxf/camel-cxf-spring-soap/src/test/java/org/apache/camel/component/cxf/CxfPayloadRouterContentLengthTest.java
index a3146e15948..e6be92b431a 100644
--- a/components/camel-cxf/camel-cxf-spring-soap/src/test/java/org/apache/camel/component/cxf/CxfPayloadRouterContentLengthTest.java
+++ b/components/camel-cxf/camel-cxf-spring-soap/src/test/java/org/apache/camel/component/cxf/CxfPayloadRouterContentLengthTest.java
@@ -28,14 +28,14 @@ import org.apache.camel.component.cxf.common.CXFTestSupport;
 import org.apache.camel.test.AvailablePortFinder;
 import org.apache.camel.test.spring.junit5.CamelSpringTestSupport;
 import org.apache.camel.util.IOHelper;
-import org.apache.http.HttpEntity;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.ContentType;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.util.EntityUtils;
+import org.apache.hc.client5.http.classic.methods.HttpPost;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.classic.HttpClients;
+import org.apache.hc.core5.http.ContentType;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
+import org.apache.hc.core5.http.io.entity.StringEntity;
 import org.eclipse.jetty.server.HttpConfiguration;
 import org.eclipse.jetty.server.HttpConnectionFactory;
 import org.eclipse.jetty.server.Request;
@@ -91,7 +91,7 @@ public class CxfPayloadRouterContentLengthTest extends CamelSpringTestSupport {
     public void setUp() throws Exception {
         /*
          * We start a Jetty for the service in order to have better control over
-         * the response The response must contain only a Content-Type and a
+         * the response. The response must contain only a Content-Type and a
          * Content-Length but no other header
          */
         LOG.info("Starting jetty server at port {}", JETTY_PORT);
@@ -149,28 +149,20 @@ public class CxfPayloadRouterContentLengthTest extends CamelSpringTestSupport {
     }
 
     @Test
-    public void testInvokeRouter() throws IOException {
+    public void testInvokeRouter() throws Exception {
         CloseableHttpClient httpclient = HttpClients.createDefault();
         long contentLength = 0;
         boolean isChunked = false;
         String receivedContent = null;
-        try {
-            HttpPost httppost = new HttpPost("http://localhost:" + CXFTestSupport.getPort1() + "/TEST/PROXY");
-            StringEntity reqEntity = new StringEntity(REQUEST_MESSAGE, ContentType.TEXT_XML);
-            reqEntity.setChunked(false);
-            httppost.setEntity(reqEntity);
-            CloseableHttpResponse response = httpclient.execute(httppost);
-            try {
-                HttpEntity respEntity = response.getEntity();
-                contentLength = respEntity.getContentLength();
-                isChunked = respEntity.isChunked();
-                receivedContent = EntityUtils.toString(respEntity);
-                EntityUtils.consume(response.getEntity());
-            } finally {
-                response.close();
-            }
-        } finally {
-            httpclient.close();
+        HttpPost httppost = new HttpPost("http://localhost:" + CXFTestSupport.getPort1() + "/TEST/PROXY");
+        StringEntity reqEntity = new StringEntity(REQUEST_MESSAGE, ContentType.TEXT_XML, false);
+        httppost.setEntity(reqEntity);
+        try (httpclient; CloseableHttpResponse response = httpclient.execute(httppost)) {
+            HttpEntity respEntity = response.getEntity();
+            contentLength = respEntity.getContentLength();
+            isChunked = respEntity.isChunked();
+            receivedContent = EntityUtils.toString(respEntity);
+            EntityUtils.consume(response.getEntity());
         }
         assertNotNull(receivedContent);
         // chunked encoding is fine, we don't need to check the content length
@@ -181,7 +173,7 @@ public class CxfPayloadRouterContentLengthTest extends CamelSpringTestSupport {
                 "[" + receivedContent + "] does not contain [" + RESPONSE_STRING + "]");
         // check whether the response was cut off by the client because the
         // Content-Length was wrong
-        assertTrue(receivedContent.matches(".*\\</.*:Envelope\\>"),
+        assertTrue(receivedContent.matches(".*</.*:Envelope>"),
                 "[" + receivedContent + "] does not contain the closing Envelope tag.");
     }
 


[camel] 15/15: CAMEL-18995: camel-box - Upgrade to HttpComponents 5.x

Posted by nf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

nfilotto pushed a commit to branch CAMEL-18995/upgrade-httpcomponents-5
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 78d2264be7a71dbb840469124d05ce7172f04319
Author: Nicolas Filotto <nf...@talend.com>
AuthorDate: Fri Mar 17 12:38:43 2023 +0100

    CAMEL-18995: camel-box - Upgrade to HttpComponents 5.x
---
 components/camel-box/camel-box-component/pom.xml                    | 6 +++---
 .../apache/camel/component/box/internal/BoxConnectionHelper.java    | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/components/camel-box/camel-box-component/pom.xml b/components/camel-box/camel-box-component/pom.xml
index 4af3857ca8c..22a32d2bbcf 100644
--- a/components/camel-box/camel-box-component/pom.xml
+++ b/components/camel-box/camel-box-component/pom.xml
@@ -58,9 +58,9 @@
         </dependency>
 
         <dependency>
-            <groupId>org.apache.httpcomponents</groupId>
-            <artifactId>httpclient</artifactId>
-            <version>${httpclient4-version}</version>
+            <groupId>org.apache.httpcomponents.client5</groupId>
+            <artifactId>httpclient5</artifactId>
+            <version>${httpclient-version}</version>
         </dependency>
 
 
diff --git a/components/camel-box/camel-box-component/src/main/java/org/apache/camel/component/box/internal/BoxConnectionHelper.java b/components/camel-box/camel-box-component/src/main/java/org/apache/camel/component/box/internal/BoxConnectionHelper.java
index b7ad7ee3b5e..d39129e0e67 100644
--- a/components/camel-box/camel-box-component/src/main/java/org/apache/camel/component/box/internal/BoxConnectionHelper.java
+++ b/components/camel-box/camel-box-component/src/main/java/org/apache/camel/component/box/internal/BoxConnectionHelper.java
@@ -36,7 +36,7 @@ import com.box.sdk.InMemoryLRUAccessTokenCache;
 import com.box.sdk.JWTEncryptionPreferences;
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.component.box.BoxConfiguration;
-import org.apache.http.HttpHost;
+import org.apache.hc.core5.http.HttpHost;
 import org.jsoup.Connection;
 import org.jsoup.Jsoup;
 import org.jsoup.nodes.Document;


[camel] 04/15: CAMEL-18995: camel-cm-sms - Upgrade to HttpComponents 5.x

Posted by nf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

nfilotto pushed a commit to branch CAMEL-18995/upgrade-httpcomponents-5
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 615d951f2698edbac38954d50c56640083444126
Author: Nicolas Filotto <nf...@talend.com>
AuthorDate: Fri Mar 17 12:26:22 2023 +0100

    CAMEL-18995: camel-cm-sms - Upgrade to HttpComponents 5.x
---
 components/camel-cm-sms/pom.xml                    |   6 +-
 .../org/apache/camel/component/cm/CMComponent.java |   2 +-
 .../org/apache/camel/component/cm/CMEndpoint.java  |  15 ++-
 .../org/apache/camel/component/cm/CMMessage.java   |   6 +-
 .../org/apache/camel/component/cm/CMProducer.java  |  11 +-
 .../camel/component/cm/CMSenderOneMessageImpl.java | 134 +++++++++++----------
 6 files changed, 96 insertions(+), 78 deletions(-)

diff --git a/components/camel-cm-sms/pom.xml b/components/camel-cm-sms/pom.xml
index 9c73d41f053..7e851a00ad7 100644
--- a/components/camel-cm-sms/pom.xml
+++ b/components/camel-cm-sms/pom.xml
@@ -46,9 +46,9 @@
         </dependency>
 
         <dependency>
-            <groupId>org.apache.httpcomponents</groupId>
-            <artifactId>httpclient</artifactId>
-            <version>${httpclient4-version}</version>
+            <groupId>org.apache.httpcomponents.client5</groupId>
+            <artifactId>httpclient5</artifactId>
+            <version>${httpclient-version}</version>
         </dependency>
 
         <dependency>
diff --git a/components/camel-cm-sms/src/main/java/org/apache/camel/component/cm/CMComponent.java b/components/camel-cm-sms/src/main/java/org/apache/camel/component/cm/CMComponent.java
index f13cdb8728f..9cb9b468891 100644
--- a/components/camel-cm-sms/src/main/java/org/apache/camel/component/cm/CMComponent.java
+++ b/components/camel-cm-sms/src/main/java/org/apache/camel/component/cm/CMComponent.java
@@ -56,7 +56,7 @@ public class CMComponent extends DefaultComponent {
         final Set<ConstraintViolation<CMConfiguration>> constraintViolations
                 = getValidator().validate(endpoint.getConfiguration());
         if (!constraintViolations.isEmpty()) {
-            final StringBuffer msg = new StringBuffer();
+            final StringBuilder msg = new StringBuilder();
             for (final ConstraintViolation<CMConfiguration> cv : constraintViolations) {
                 msg.append(String.format("- Invalid value for %s: %s",
                         cv.getPropertyPath().toString(),
diff --git a/components/camel-cm-sms/src/main/java/org/apache/camel/component/cm/CMEndpoint.java b/components/camel-cm-sms/src/main/java/org/apache/camel/component/cm/CMEndpoint.java
index c8158af8ab4..49d5fde056c 100644
--- a/components/camel-cm-sms/src/main/java/org/apache/camel/component/cm/CMEndpoint.java
+++ b/components/camel-cm-sms/src/main/java/org/apache/camel/component/cm/CMEndpoint.java
@@ -28,6 +28,9 @@ import org.apache.camel.spi.UriParam;
 import org.apache.camel.spi.UriPath;
 import org.apache.camel.support.DefaultEndpoint;
 import org.apache.camel.util.StringHelper;
+import org.apache.hc.client5.http.classic.HttpClient;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
 
 /**
  * Send SMS messages via <a href="https://www.cmtelecom.com/">CM SMS Gateway</a>.
@@ -41,6 +44,7 @@ public class CMEndpoint extends DefaultEndpoint {
     private String host;
     @UriParam
     private CMConfiguration configuration = new CMConfiguration();
+    private final CloseableHttpClient httpClient = HttpClientBuilder.create().build();
 
     public CMEndpoint(final String uri, final CMComponent component) {
         super(uri, component);
@@ -70,7 +74,7 @@ public class CMEndpoint extends DefaultEndpoint {
         StringHelper.notEmpty(token, "productToken");
 
         UUID uuid = UUID.fromString(token);
-        return new CMProducer(this, new CMSenderOneMessageImpl(getCMUrl(), uuid));
+        return new CMProducer(this, new CMSenderOneMessageImpl(httpClient, getCMUrl(), uuid));
     }
 
     @Override
@@ -95,6 +99,15 @@ public class CMEndpoint extends DefaultEndpoint {
         return (CMComponent) super.getComponent();
     }
 
+    @Override
+    protected void doStop() throws Exception {
+        httpClient.close();
+    }
+
+    public HttpClient getHttpClient() {
+        return httpClient;
+    }
+
     public String getHost() {
         return host;
     }
diff --git a/components/camel-cm-sms/src/main/java/org/apache/camel/component/cm/CMMessage.java b/components/camel-cm-sms/src/main/java/org/apache/camel/component/cm/CMMessage.java
index 74f94979fa3..d3b52126558 100644
--- a/components/camel-cm-sms/src/main/java/org/apache/camel/component/cm/CMMessage.java
+++ b/components/camel-cm-sms/src/main/java/org/apache/camel/component/cm/CMMessage.java
@@ -144,11 +144,11 @@ public class CMMessage {
     @Override
     public String toString() {
 
-        StringBuffer sb = new StringBuffer(
+        StringBuilder sb = new StringBuilder(
                 " {phoneNumber: " + phoneNumber + ", message: " + message + ", sender=" + sender + ", unicode: " + unicode
-                                           + ", multipart: " + multipart);
+                                             + ", multipart: " + multipart);
         if (idAsString != null && !idAsString.isEmpty()) {
-            sb.append(", idAsString=" + idAsString);
+            sb.append(", idAsString=").append(idAsString);
         }
         sb.append(" }");
         return sb.toString();
diff --git a/components/camel-cm-sms/src/main/java/org/apache/camel/component/cm/CMProducer.java b/components/camel-cm-sms/src/main/java/org/apache/camel/component/cm/CMProducer.java
index 9a28f0572cd..53ba01ed62a 100644
--- a/components/camel-cm-sms/src/main/java/org/apache/camel/component/cm/CMProducer.java
+++ b/components/camel-cm-sms/src/main/java/org/apache/camel/component/cm/CMProducer.java
@@ -26,8 +26,8 @@ import org.apache.camel.InvalidPayloadRuntimeException;
 import org.apache.camel.component.cm.client.SMSMessage;
 import org.apache.camel.component.cm.exceptions.HostUnavailableException;
 import org.apache.camel.support.DefaultProducer;
-import org.apache.http.client.methods.HttpHead;
-import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.hc.client5.http.classic.HttpClient;
+import org.apache.hc.client5.http.classic.methods.HttpHead;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -44,9 +44,12 @@ public class CMProducer extends DefaultProducer {
      */
     private CMSender sender;
 
+    private final HttpClient client;
+
     public CMProducer(final CMEndpoint endpoint, final CMSender sender) {
         super(endpoint);
         this.sender = sender;
+        this.client = endpoint.getHttpClient();
     }
 
     /**
@@ -64,7 +67,7 @@ public class CMProducer extends DefaultProducer {
         LOG.trace("Validating SMSMessage instance provided: {}", smsMessage);
         final Set<ConstraintViolation<SMSMessage>> constraintViolations = getValidator().validate(smsMessage);
         if (!constraintViolations.isEmpty()) {
-            final StringBuffer msg = new StringBuffer();
+            final StringBuilder msg = new StringBuilder();
             for (final ConstraintViolation<SMSMessage> cv : constraintViolations) {
                 msg.append(String.format("- Invalid value for %s: %s", cv.getPropertyPath().toString(), cv.getMessage()));
             }
@@ -112,7 +115,7 @@ public class CMProducer extends DefaultProducer {
         if (configuration.isTestConnectionOnStartup()) {
             try {
                 LOG.debug("Checking connection - {}", getEndpoint().getCMUrl());
-                HttpClientBuilder.create().build().execute(new HttpHead(getEndpoint().getCMUrl()));
+                client.execute(new HttpHead(getEndpoint().getCMUrl()), res -> null);
                 LOG.debug("Connection to {}: OK", getEndpoint().getCMUrl());
             } catch (final Exception e) {
                 throw new HostUnavailableException(
diff --git a/components/camel-cm-sms/src/main/java/org/apache/camel/component/cm/CMSenderOneMessageImpl.java b/components/camel-cm-sms/src/main/java/org/apache/camel/component/cm/CMSenderOneMessageImpl.java
index a2a49835286..c6404bbfda4 100644
--- a/components/camel-cm-sms/src/main/java/org/apache/camel/component/cm/CMSenderOneMessageImpl.java
+++ b/components/camel-cm-sms/src/main/java/org/apache/camel/component/cm/CMSenderOneMessageImpl.java
@@ -49,11 +49,9 @@ import org.apache.camel.component.cm.exceptions.cmresponse.InvalidProductTokenEx
 import org.apache.camel.component.cm.exceptions.cmresponse.NoAccountFoundForProductTokenException;
 import org.apache.camel.component.cm.exceptions.cmresponse.UnknownErrorException;
 import org.apache.camel.component.cm.exceptions.cmresponse.UnroutableMessageException;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.hc.client5.http.classic.HttpClient;
+import org.apache.hc.client5.http.classic.methods.HttpPost;
+import org.apache.hc.core5.http.io.entity.StringEntity;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -63,10 +61,12 @@ public class CMSenderOneMessageImpl implements CMSender {
 
     private final String url;
     private final UUID productToken;
+    private final HttpClient client;
 
-    public CMSenderOneMessageImpl(final String url, final UUID productToken) {
+    public CMSenderOneMessageImpl(final HttpClient client, final String url, final UUID productToken) {
         this.url = url;
         this.productToken = productToken;
+        this.client = client;
     }
 
     /**
@@ -178,71 +178,73 @@ public class CMSenderOneMessageImpl implements CMSender {
 
     private void doHttpPost(final String urlString, final String requestString) {
 
-        final HttpClient client = HttpClientBuilder.create().build();
         final HttpPost post = new HttpPost(urlString);
         post.setEntity(new StringEntity(requestString, StandardCharsets.UTF_8));
 
         try {
+            client.execute(post,
+                    response -> {
+                        final int statusCode = response.getCode();
+
+                        LOG.debug("Response Code : {}", statusCode);
+
+                        if (statusCode == 400) {
+                            throw new CMDirectException(
+                                    "CM Component and CM API show some kind of inconsistency. "
+                                                        + "CM is complaining about not using a post method for the request. And this component only uses POST requests. What happens?");
+                        }
+
+                        if (statusCode != 200) {
+                            throw new CMDirectException(
+                                    "CM Component and CM API show some kind of inconsistency. The component expects the status code to be 200 or 400. New api released? ");
+                        }
+
+                        // So we have 200 status code...
+
+                        // The response type is 'text/plain' and contains the actual
+                        // result of the request processing.
+
+                        // We obtain the result text
+                        try (BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()))) {
+                            final StringBuilder result = new StringBuilder();
+                            String line;
+                            while ((line = rd.readLine()) != null) {
+                                result.append(line);
+                            }
+
+                            // ... and process it
+
+                            line = result.toString();
+                            if (!line.isEmpty()) {
+
+                                // Line is not empty = error
+                                LOG.debug("Result of the request processing: FAILED\n{}", line);
+
+                                // The response text contains the error description. We will
+                                // throw a custom exception for each.
+
+                                if (line.contains(CMConstants.ERROR_UNKNOWN)) {
+                                    throw new UnknownErrorException();
+                                } else if (line.contains(CMConstants.ERROR_NO_ACCOUNT)
+                                        || line.contains(CMConstants.ERROR_NO_USER)) {
+                                    throw new NoAccountFoundForProductTokenException();
+                                } else if (line.contains(CMConstants.ERROR_INSUFICIENT_BALANCE)) {
+                                    throw new InsufficientBalanceException();
+                                } else if (line.contains(CMConstants.ERROR_UNROUTABLE_MESSAGE)) {
+                                    throw new UnroutableMessageException();
+                                } else if (line.contains(CMConstants.ERROR_INVALID_PRODUCT_TOKEN)) {
+                                    throw new InvalidProductTokenException();
+                                } else {
+                                    throw new CMResponseException(line);
+                                }
+                            }
+
+                            // Ok. Line is EMPTY - successfully submitted
+                            LOG.debug("Result of the request processing: Successfully submitted");
+                        }
+                        return null;
+                    });
 
-            final HttpResponse response = client.execute(post);
-
-            final int statusCode = response.getStatusLine().getStatusCode();
-
-            LOG.debug("Response Code : {}", statusCode);
-
-            if (statusCode == 400) {
-                throw new CMDirectException(
-                        "CM Component and CM API show some kind of inconsistency. "
-                                            + "CM is complaining about not using a post method for the request. And this component only uses POST requests. What happens?");
-            }
-
-            if (statusCode != 200) {
-                throw new CMDirectException(
-                        "CM Component and CM API show some kind of inconsistency. The component expects the status code to be 200 or 400. New api released? ");
-            }
-
-            // So we have 200 status code...
-
-            // The response type is 'text/plain' and contains the actual
-            // result of the request processing.
-
-            // We obtaing the result text
-            try (BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()))) {
-                final StringBuffer result = new StringBuffer();
-                String line = null;
-                while ((line = rd.readLine()) != null) {
-                    result.append(line);
-                }
-
-                // ... and process it
-
-                line = result.toString();
-                if (!line.isEmpty()) {
-
-                    // Line is not empty = error
-                    LOG.debug("Result of the request processing: FAILED\n{}", line);
-
-                    // The response text contains the error description. We will
-                    // throw a custom exception for each.
-
-                    if (line.contains(CMConstants.ERROR_UNKNOWN)) {
-                        throw new UnknownErrorException();
-                    } else if (line.contains(CMConstants.ERROR_NO_ACCOUNT) || line.contains(CMConstants.ERROR_NO_USER)) {
-                        throw new NoAccountFoundForProductTokenException();
-                    } else if (line.contains(CMConstants.ERROR_INSUFICIENT_BALANCE)) {
-                        throw new InsufficientBalanceException();
-                    } else if (line.contains(CMConstants.ERROR_UNROUTABLE_MESSAGE)) {
-                        throw new UnroutableMessageException();
-                    } else if (line.contains(CMConstants.ERROR_INVALID_PRODUCT_TOKEN)) {
-                        throw new InvalidProductTokenException();
-                    } else {
-                        throw new CMResponseException(line);
-                    }
-                }
-
-                // Ok. Line is EMPTY - successfully submitted
-                LOG.debug("Result of the request processing: Successfully submitted");
-            }
         } catch (final IOException io) {
             throw new CMDirectException(io);
         } catch (Exception t) {


[camel] 07/15: CAMEL-18995: camel-oaipmh - Upgrade to HttpComponents 5.x

Posted by nf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

nfilotto pushed a commit to branch CAMEL-18995/upgrade-httpcomponents-5
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 56ce8e2780b59f24e3df9b0e70e5c8b1e1bd8c61
Author: Nicolas Filotto <nf...@talend.com>
AuthorDate: Fri Mar 17 12:30:39 2023 +0100

    CAMEL-18995: camel-oaipmh - Upgrade to HttpComponents 5.x
---
 components/camel-oaipmh/pom.xml                    | 12 ++++--
 .../camel/oaipmh/utils/OAIPMHHttpClient.java       | 48 ++++++++++++----------
 2 files changed, 35 insertions(+), 25 deletions(-)

diff --git a/components/camel-oaipmh/pom.xml b/components/camel-oaipmh/pom.xml
index 494c9d3500d..33645594d32 100644
--- a/components/camel-oaipmh/pom.xml
+++ b/components/camel-oaipmh/pom.xml
@@ -44,9 +44,9 @@
             <version>${jodatime2-version}</version>
         </dependency>
         <dependency>
-            <groupId>org.apache.httpcomponents</groupId>
-            <artifactId>httpclient</artifactId>
-            <version>${httpclient4-version}</version>
+            <groupId>org.apache.httpcomponents.client5</groupId>
+            <artifactId>httpclient5</artifactId>
+            <version>${httpclient-version}</version>
         </dependency>
         <dependency>
             <groupId>org.jsoup</groupId>
@@ -85,6 +85,12 @@
             <version>${commons-io-version}</version>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>commons-codec</groupId>
+            <artifactId>commons-codec</artifactId>
+            <version>${commons-codec-version}</version>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
 </project>
diff --git a/components/camel-oaipmh/src/main/java/org/apache/camel/oaipmh/utils/OAIPMHHttpClient.java b/components/camel-oaipmh/src/main/java/org/apache/camel/oaipmh/utils/OAIPMHHttpClient.java
index d809eb1d694..1854b511a1b 100644
--- a/components/camel-oaipmh/src/main/java/org/apache/camel/oaipmh/utils/OAIPMHHttpClient.java
+++ b/components/camel-oaipmh/src/main/java/org/apache/camel/oaipmh/utils/OAIPMHHttpClient.java
@@ -25,20 +25,23 @@ import java.security.KeyManagementException;
 import java.security.KeyStoreException;
 import java.security.NoSuchAlgorithmException;
 
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.RequestLine;
-import org.apache.http.client.ClientProtocolException;
-import org.apache.http.client.ResponseHandler;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.utils.URIBuilder;
-import org.apache.http.client.utils.URLEncodedUtils;
-import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
-import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.ssl.SSLContextBuilder;
-import org.apache.http.util.EntityUtils;
+import org.apache.hc.client5.http.ClientProtocolException;
+import org.apache.hc.client5.http.classic.methods.HttpGet;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.HttpClients;
+import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager;
+import org.apache.hc.client5.http.socket.ConnectionSocketFactory;
+import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory;
+import org.apache.hc.client5.http.ssl.TrustSelfSignedStrategy;
+import org.apache.hc.core5.http.ClassicHttpResponse;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.config.RegistryBuilder;
+import org.apache.hc.core5.http.io.HttpClientResponseHandler;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
+import org.apache.hc.core5.net.URIBuilder;
+import org.apache.hc.core5.net.URLEncodedUtils;
+import org.apache.hc.core5.ssl.SSLContextBuilder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -85,16 +88,14 @@ public class OAIPMHHttpClient {
 
             HttpGet httpget = new HttpGet(builder.build());
 
-            RequestLine requestLine = httpget.getRequestLine();
-
-            LOG.info("Executing request: {} ", requestLine);
+            LOG.info("Executing request: {} ", httpget);
 
             // Create a custom response handler
-            ResponseHandler<String> responseHandler = new ResponseHandler<String>() {
+            HttpClientResponseHandler<String> responseHandler = new HttpClientResponseHandler<String>() {
 
                 @Override
-                public String handleResponse(final HttpResponse response) throws IOException {
-                    int status = response.getStatusLine().getStatusCode();
+                public String handleResponse(final ClassicHttpResponse response) throws HttpException, IOException {
+                    int status = response.getCode();
                     if (status >= 200 && status < 300) {
                         HttpEntity entity = response.getEntity();
                         if (entity == null) {
@@ -122,8 +123,11 @@ public class OAIPMHHttpClient {
                 builder.loadTrustMaterial(null, new TrustSelfSignedStrategy());
                 SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(
                         builder.build());
-                return HttpClients.custom().setSSLSocketFactory(
-                        sslsf).build();
+                RegistryBuilder<ConnectionSocketFactory> registryBuilder = RegistryBuilder.create();
+                registryBuilder.register("https", sslsf);
+                return HttpClients.custom()
+                        .setConnectionManager(new PoolingHttpClientConnectionManager(registryBuilder.build()))
+                        .build();
             } catch (KeyManagementException | KeyStoreException | NoSuchAlgorithmException ex) {
                 throw new IOException("The HTTP Client could not be started", ex);
             }


[camel] 12/15: CAMEL-18995: camel-http-base - Upgrade to HttpComponents 5.x

Posted by nf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

nfilotto pushed a commit to branch CAMEL-18995/upgrade-httpcomponents-5
in repository https://gitbox.apache.org/repos/asf/camel.git

commit b3495fcc026f207f7432178287a0dce702915104
Author: Nicolas Filotto <nf...@talend.com>
AuthorDate: Fri Mar 17 12:37:15 2023 +0100

    CAMEL-18995: camel-http-base - Upgrade to HttpComponents 5.x
---
 .../java/org/apache/camel/http/base/cookie/ExchangeCookieHandler.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/components/camel-http-base/src/main/java/org/apache/camel/http/base/cookie/ExchangeCookieHandler.java b/components/camel-http-base/src/main/java/org/apache/camel/http/base/cookie/ExchangeCookieHandler.java
index 19c47b72555..0816913b6f7 100644
--- a/components/camel-http-base/src/main/java/org/apache/camel/http/base/cookie/ExchangeCookieHandler.java
+++ b/components/camel-http-base/src/main/java/org/apache/camel/http/base/cookie/ExchangeCookieHandler.java
@@ -32,8 +32,8 @@ public class ExchangeCookieHandler extends BaseCookieHandler {
     @Override
     protected CookieManager getCookieManager(Exchange exchange) {
         Object handlerObj = exchange.getProperty(Exchange.COOKIE_HANDLER);
-        if (handlerObj instanceof java.net.CookieManager) {
-            return (CookieManager) handlerObj;
+        if (handlerObj instanceof java.net.CookieManager manager) {
+            return manager;
         } else {
             CookieManager handler = new CookieManager();
             handler.setCookiePolicy(cookiePolicy);