HTTPCORE-524: updated examples to use nghttp2.org instead of no longer functional http2bin.org
This commit is contained in:
parent
e3cdb72de7
commit
a6a29892fa
|
@ -70,7 +70,7 @@ public class AsyncClientHttp2FullDuplexExchange {
|
|||
|
||||
client.start();
|
||||
|
||||
final URI requestUri = new URI("http://http2bin.org/post");
|
||||
final URI requestUri = new URI("http://nghttp2.org/httpbin/post");
|
||||
final BasicRequestProducer requestProducer = new BasicRequestProducer(
|
||||
"POST", requestUri, new BasicAsyncEntityProducer("stuff", ContentType.TEXT_PLAIN));
|
||||
final BasicResponseConsumer<String> responseConsumer = new BasicResponseConsumer<>(
|
||||
|
|
|
@ -62,11 +62,11 @@ public class AsyncClientHttp2Multiplexing {
|
|||
|
||||
client.start();
|
||||
|
||||
final HttpHost target = new HttpHost("http2bin.org");
|
||||
final HttpHost target = new HttpHost("nghttp2.org");
|
||||
final Future<AsyncClientEndpoint> leaseFuture = client.lease(target, null);
|
||||
final AsyncClientEndpoint endpoint = leaseFuture.get(30, TimeUnit.SECONDS);
|
||||
try {
|
||||
final String[] requestUris = new String[] {"/", "/ip", "/user-agent", "/headers"};
|
||||
final String[] requestUris = new String[] {"/httpbin/ip", "/httpbin/user-agent", "/httpbin/headers"};
|
||||
|
||||
final CountDownLatch latch = new CountDownLatch(requestUris.length);
|
||||
for (final String requestUri: requestUris) {
|
||||
|
|
|
@ -114,8 +114,8 @@ public class AsyncClientHttp2ServerPush {
|
|||
|
||||
});
|
||||
|
||||
final HttpHost target = new HttpHost("http2bin.org");
|
||||
final String requestURI = "/";
|
||||
final HttpHost target = new HttpHost("nghttp2.org");
|
||||
final String requestURI = "/httpbin/";
|
||||
final Future<Void> future = client.execute(
|
||||
AsyncRequestBuilder.get(target, requestURI).build(),
|
||||
new AbstractCharResponseConsumer<Void>() {
|
||||
|
|
|
@ -26,11 +26,8 @@
|
|||
*/
|
||||
package org.apache.hc.client5.http.examples;
|
||||
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.SSLSession;
|
||||
|
||||
import org.apache.hc.client5.http.async.methods.SimpleHttpRequest;
|
||||
|
@ -49,7 +46,6 @@ import org.apache.hc.core5.http.nio.ssl.TlsStrategy;
|
|||
import org.apache.hc.core5.http2.HttpVersionPolicy;
|
||||
import org.apache.hc.core5.io.ShutdownType;
|
||||
import org.apache.hc.core5.ssl.SSLContexts;
|
||||
import org.apache.hc.core5.ssl.TrustStrategy;
|
||||
|
||||
/**
|
||||
* This example demonstrates how to avoid the illegal reflective access operation warning
|
||||
|
@ -58,22 +54,8 @@ import org.apache.hc.core5.ssl.TrustStrategy;
|
|||
public class AsyncClientTlsAlpn {
|
||||
|
||||
public final static void main(final String[] args) throws Exception {
|
||||
// Trust standard CA and those trusted by our custom strategy
|
||||
final SSLContext sslcontext = SSLContexts.custom()
|
||||
.loadTrustMaterial(new TrustStrategy() {
|
||||
|
||||
@Override
|
||||
public boolean isTrusted(
|
||||
final X509Certificate[] chain,
|
||||
final String authType) throws CertificateException {
|
||||
final X509Certificate cert = chain[0];
|
||||
return "CN=http2bin.org".equalsIgnoreCase(cert.getSubjectDN().getName());
|
||||
}
|
||||
|
||||
})
|
||||
.build();
|
||||
final TlsStrategy tlsStrategy = new H2TlsStrategy(
|
||||
sslcontext,
|
||||
SSLContexts.createSystemDefault(),
|
||||
H2TlsStrategy.getDefaultHostnameVerifier()) {
|
||||
|
||||
// IMPORTANT uncomment the following method when running Java 9 or older
|
||||
|
@ -94,8 +76,8 @@ public class AsyncClientTlsAlpn {
|
|||
|
||||
client.start();
|
||||
|
||||
final HttpHost target = new HttpHost("http2bin.org", 443, "https");
|
||||
final String requestUri = "/";
|
||||
final HttpHost target = new HttpHost("nghttp2.org", 443, "https");
|
||||
final String requestUri = "/httpbin/";
|
||||
final HttpClientContext clientContext = HttpClientContext.create();
|
||||
|
||||
final SimpleHttpRequest request = SimpleHttpRequest.get(target, requestUri);
|
||||
|
|
Loading…
Reference in New Issue