From 7250fe0f3d5ee7efba848b4e9b4c725649e7ac41 Mon Sep 17 00:00:00 2001 From: Oleg Kalnichevski Date: Sun, 24 Nov 2024 12:11:22 +0100 Subject: [PATCH] Updated H2 example apps that use nghttp2.org as their target server --- .../http/examples/AsyncClientH2FullDuplexExchange.java | 8 +++++++- .../hc/client5/http/examples/AsyncClientH2ServerPush.java | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientH2FullDuplexExchange.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientH2FullDuplexExchange.java index b6309de7b..dd4fd4dd1 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientH2FullDuplexExchange.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientH2FullDuplexExchange.java @@ -40,6 +40,7 @@ import org.apache.hc.core5.http.ContentType; 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.HttpHost; import org.apache.hc.core5.http.HttpResponse; import org.apache.hc.core5.http.config.Http1Config; import org.apache.hc.core5.http.message.BasicHttpRequest; @@ -78,7 +79,12 @@ public class AsyncClientH2FullDuplexExchange { client.start(); - final BasicHttpRequest request = BasicRequestBuilder.post("https://nghttp2.org/httpbin/post").build(); + final HttpHost target = new HttpHost("https", "nghttp2.org"); + + final BasicHttpRequest request = BasicRequestBuilder.post() + .setHttpHost(target) + .setPath("/httpbin/post") + .build(); final BasicRequestProducer requestProducer = new BasicRequestProducer(request, new BasicAsyncEntityProducer("stuff", ContentType.TEXT_PLAIN)); final BasicResponseConsumer responseConsumer = new BasicResponseConsumer<>( diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientH2ServerPush.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientH2ServerPush.java index 676aed477..0843af5b7 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientH2ServerPush.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientH2ServerPush.java @@ -38,6 +38,7 @@ import org.apache.hc.client5.http.impl.async.HttpAsyncClients; import org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManagerBuilder; import org.apache.hc.core5.function.Supplier; import org.apache.hc.core5.http.ContentType; +import org.apache.hc.core5.http.HttpHost; import org.apache.hc.core5.http.HttpRequest; import org.apache.hc.core5.http.HttpResponse; import org.apache.hc.core5.http.impl.routing.RequestRouter; @@ -109,7 +110,12 @@ public class AsyncClientH2ServerPush { }) .build(); - final BasicHttpRequest request = BasicRequestBuilder.get("https://nghttp2.org/httpbin/").build(); + final HttpHost target = new HttpHost("https", "nghttp2.org"); + + final BasicHttpRequest request = BasicRequestBuilder.get() + .setHttpHost(target) + .setPath("/httpbin/") + .build(); System.out.println("Executing request " + request); final Future future = client.execute(