You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2025/09/24 19:36:09 UTC
(httpcomponents-core) branch 5.3.x updated (2e0fc082a -> f8b1b4aa1)
This is an automated email from the ASF dual-hosted git repository.
olegk pushed a change to branch 5.3.x
in repository https://gitbox.apache.org/repos/asf/httpcomponents-core.git
from 2e0fc082a Upgraded HttpCore version to 5.3.7-SNAPSHOT
new 62bac1652 Set `localhost` as the canonical hostname for HTTP servers in integration tests. InetAddressUtils#getCanonicalLocalHostName() can be very slow in some environments
new f8b1b4aa1 HTTPCORE-785: Updated request execution example with Conscrypt as a security provider
The 2 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:
.../http2/examples/H2ConscriptRequestExecutionExample.java | 14 ++++++++++++--
.../testing/extension/classic/HttpServerResource.java | 1 +
.../core5/testing/extension/nio/H2AsyncServerResource.java | 1 +
.../testing/extension/nio/HttpAsyncServerResource.java | 1 +
.../apache/hc/core5/testing/nio/TLSIntegrationTest.java | 1 +
5 files changed, 16 insertions(+), 2 deletions(-)
(httpcomponents-core) 01/02: Set `localhost` as the canonical hostname for HTTP servers in integration tests. InetAddressUtils#getCanonicalLocalHostName() can be very slow in some environments
Posted by ol...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
olegk pushed a commit to branch 5.3.x
in repository https://gitbox.apache.org/repos/asf/httpcomponents-core.git
commit 62bac165287d97398b10a57e97d399adaa8527c5
Author: Oleg Kalnichevski <ol...@apache.org>
AuthorDate: Wed Sep 24 17:38:40 2025 +0200
Set `localhost` as the canonical hostname for HTTP servers in integration tests. InetAddressUtils#getCanonicalLocalHostName() can be very slow in some environments
---
.../apache/hc/core5/testing/extension/classic/HttpServerResource.java | 1 +
.../org/apache/hc/core5/testing/extension/nio/H2AsyncServerResource.java | 1 +
.../apache/hc/core5/testing/extension/nio/HttpAsyncServerResource.java | 1 +
.../test/java/org/apache/hc/core5/testing/nio/TLSIntegrationTest.java | 1 +
4 files changed, 4 insertions(+)
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/extension/classic/HttpServerResource.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/extension/classic/HttpServerResource.java
index ec961f104..c431cee52 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/extension/classic/HttpServerResource.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/extension/classic/HttpServerResource.java
@@ -63,6 +63,7 @@ public void beforeEach(final ExtensionContext extensionContext) throws Exception
LOG.debug("Starting up test server");
final ServerBootstrap bootstrap = ServerBootstrap.bootstrap()
+ .setCanonicalHostName("localhost")
.setSslContext(scheme == URIScheme.HTTPS ? SSLTestContexts.createServerSSLContext() : null)
.setExceptionListener(LoggingExceptionListener.INSTANCE)
.setStreamListener(LoggingHttp1StreamListener.INSTANCE);
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/extension/nio/H2AsyncServerResource.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/extension/nio/H2AsyncServerResource.java
index 2f86c01dd..bba2fd64f 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/extension/nio/H2AsyncServerResource.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/extension/nio/H2AsyncServerResource.java
@@ -63,6 +63,7 @@ public void beforeEach(final ExtensionContext extensionContext) throws Exception
LOG.debug("Starting up test server");
final H2ServerBootstrap bootstrap = H2ServerBootstrap.bootstrap()
+ .setCanonicalHostName("localhost")
.setTlsStrategy(new H2ServerTlsStrategy(SSLTestContexts.createServerSSLContext()))
.setStreamListener(LoggingHttp1StreamListener.INSTANCE_SERVER)
.setStreamListener(LoggingH2StreamListener.INSTANCE)
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/extension/nio/HttpAsyncServerResource.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/extension/nio/HttpAsyncServerResource.java
index 1d0dd8b32..18b8a8fe7 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/extension/nio/HttpAsyncServerResource.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/extension/nio/HttpAsyncServerResource.java
@@ -62,6 +62,7 @@ public void beforeEach(final ExtensionContext extensionContext) throws Exception
LOG.debug("Starting up test server");
final AsyncServerBootstrap bootstrap = AsyncServerBootstrap.bootstrap()
+ .setCanonicalHostName("localhost")
.setTlsStrategy(new BasicServerTlsStrategy(SSLTestContexts.createServerSSLContext()))
.setStreamListener(LoggingHttp1StreamListener.INSTANCE_SERVER)
.setIOSessionDecorator(LoggingIOSessionDecorator.INSTANCE)
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/TLSIntegrationTest.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/TLSIntegrationTest.java
index e0acd9685..c3d37ccc0 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/TLSIntegrationTest.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/TLSIntegrationTest.java
@@ -136,6 +136,7 @@ public void afterEach(final ExtensionContext context) throws Exception {
HttpAsyncServer createServer(final TlsStrategy tlsStrategy) {
return AsyncServerBootstrap.bootstrap()
+ .setCanonicalHostName("localhost")
.setIOReactorConfig(
IOReactorConfig.custom()
.setSoTimeout(TIMEOUT)
(httpcomponents-core) 02/02: HTTPCORE-785: Updated request execution example with Conscrypt as a security provider
Posted by ol...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
olegk pushed a commit to branch 5.3.x
in repository https://gitbox.apache.org/repos/asf/httpcomponents-core.git
commit f8b1b4aa1ec0e6aca3c34f123e722de9cadf2eda
Author: Oleg Kalnichevski <ol...@apache.org>
AuthorDate: Tue Sep 23 21:31:42 2025 +0200
HTTPCORE-785: Updated request execution example with Conscrypt as a security provider
---
.../http2/examples/H2ConscriptRequestExecutionExample.java | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/examples/H2ConscriptRequestExecutionExample.java b/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/examples/H2ConscriptRequestExecutionExample.java
index e33f4e248..1d182e2b8 100644
--- a/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/examples/H2ConscriptRequestExecutionExample.java
+++ b/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/examples/H2ConscriptRequestExecutionExample.java
@@ -26,6 +26,8 @@
*/
package org.apache.hc.core5.http2.examples;
+import java.security.Provider;
+import java.security.Security;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Future;
@@ -43,6 +45,7 @@
import org.apache.hc.core5.http.nio.entity.StringAsyncEntityConsumer;
import org.apache.hc.core5.http.nio.support.AsyncRequestBuilder;
import org.apache.hc.core5.http.nio.support.BasicResponseConsumer;
+import org.apache.hc.core5.http2.HttpVersionPolicy;
import org.apache.hc.core5.http2.config.H2Config;
import org.apache.hc.core5.http2.frame.RawFrame;
import org.apache.hc.core5.http2.impl.nio.H2StreamListener;
@@ -55,7 +58,7 @@
/**
* This example demonstrates how to execute HTTP/2 requests over TLS connections
- * with Java 1.7 or Java 1.8 and Conscrypt TLS library
+ * with Conscrypt TLS library.
*/
public class H2ConscriptRequestExecutionExample {
@@ -66,13 +69,20 @@ public static void main(final String[] args) throws Exception {
.setPushEnabled(false)
.build();
+ final Provider conscryptProvider = Conscrypt.newProviderBuilder()
+ .provideTrustManager(true)
+ .build();
+
+ Security.insertProviderAt(conscryptProvider, 1);
+
final SSLContext sslContext = SSLContexts.custom()
- .setProvider(Conscrypt.newProvider())
.build();
final HttpAsyncRequester requester = H2RequesterBootstrap.bootstrap()
.setH2Config(h2Config)
+ // For JRE versions 11 or newer the standard H2ClientTlsStrategy should be used instead
.setTlsStrategy(new ConscryptClientTlsStrategy(sslContext))
+ .setVersionPolicy(HttpVersionPolicy.NEGOTIATE)
.setStreamListener(new H2StreamListener() {
@Override