Skip to content

Commit

Permalink
Updated H2 example apps that use nghttp2.org as their target server
Browse files Browse the repository at this point in the history
  • Loading branch information
ok2c committed Nov 27, 2024
1 parent 27bb5a0 commit 7250fe0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
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;
Expand Down Expand Up @@ -78,7 +79,12 @@ public static void main(final String[] args) throws Exception {

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<>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
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;
Expand Down Expand Up @@ -109,7 +110,12 @@ public void releaseResources() {
})
.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(
Expand Down

0 comments on commit 7250fe0

Please sign in to comment.