Updated H2 example apps that use nghttp2.org as their target server

This commit is contained in:
Oleg Kalnichevski 2024-11-24 12:11:22 +01:00
parent 27bb5a0821
commit 7250fe0f3d
2 changed files with 14 additions and 2 deletions

View File

@ -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<String> responseConsumer = new BasicResponseConsumer<>(

View File

@ -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<Void> future = client.execute(