Example usage for io.vertx.core.http HttpVersion HTTP_2

List of usage examples for io.vertx.core.http HttpVersion HTTP_2

Introduction

In this page you can find the example usage for io.vertx.core.http HttpVersion HTTP_2.

Prototype

HttpVersion HTTP_2

To view the source code for io.vertx.core.http HttpVersion HTTP_2.

Click Source Link

Usage

From source file:examples.HTTP2Examples.java

License:Open Source License

public void example7(Vertx vertx) {

    HttpClientOptions options = new HttpClientOptions().setProtocolVersion(HttpVersion.HTTP_2).setSsl(true)
            .setUseAlpn(true).setTrustAll(true);

    HttpClient client = vertx.createHttpClient(options);
}

From source file:examples.HTTP2Examples.java

License:Open Source License

public void example8(Vertx vertx) {

    HttpClientOptions options = new HttpClientOptions().setProtocolVersion(HttpVersion.HTTP_2);

    HttpClient client = vertx.createHttpClient(options);
}

From source file:io.servicecomb.serviceregistry.client.http.HttpClientPool.java

License:Apache License

@Override
public HttpClientOptions createHttpClientOptions() {
    HttpVersion ver = ServiceRegistryConfig.INSTANCE.getHttpVersion();
    HttpClientOptions httpClientOptions = new HttpClientOptions();
    httpClientOptions.setProtocolVersion(ver);
    httpClientOptions.setConnectTimeout(ServiceRegistryConfig.INSTANCE.getConnectionTimeout());
    httpClientOptions.setIdleTimeout(ServiceRegistryConfig.INSTANCE.getIdleConnectionTimeout());
    if (ver == HttpVersion.HTTP_2) {
        LOGGER.debug("service center client protocol version is HTTP/2");
        httpClientOptions.setHttp2ClearTextUpgrade(false);
    }/*from  w ww  .  j ava2s. com*/
    if (ServiceRegistryConfig.INSTANCE.isSsl()) {
        LOGGER.debug("service center client performs requests over TLS");
        buildSecureClientOptions(httpClientOptions);
    }
    return httpClientOptions;
}

From source file:io.servicecomb.serviceregistry.client.http.WebsocketClientPool.java

License:Apache License

@Override
public HttpClientOptions createHttpClientOptions() {
    HttpVersion ver = ServiceRegistryConfig.INSTANCE.getHttpVersion();
    HttpClientOptions httpClientOptions = new HttpClientOptions();
    httpClientOptions.setProtocolVersion(ver);
    httpClientOptions.setConnectTimeout(ServiceRegistryConfig.INSTANCE.getConnectionTimeout());
    httpClientOptions.setIdleTimeout(ServiceRegistryConfig.INSTANCE.getIdleWatchTimeout());
    if (ver == HttpVersion.HTTP_2) {
        LOGGER.debug("service center ws client protocol version is HTTP/2");
        httpClientOptions.setHttp2ClearTextUpgrade(false);
    }// w w w . j a  va2 s.co  m
    if (ServiceRegistryConfig.INSTANCE.isSsl()) {
        LOGGER.debug("service center ws client performs requests over TLS");
        buildSecureClientOptions(httpClientOptions);
    }
    return httpClientOptions;
}

From source file:org.apache.servicecomb.serviceregistry.client.http.HttpClientPool.java

License:Apache License

@Override
public HttpClientOptions createHttpClientOptions() {
    HttpVersion ver = ServiceRegistryConfig.INSTANCE.getHttpVersion();
    HttpClientOptions httpClientOptions = new HttpClientOptions();
    httpClientOptions.setProtocolVersion(ver);
    httpClientOptions.setConnectTimeout(ServiceRegistryConfig.INSTANCE.getConnectionTimeout());
    httpClientOptions.setIdleTimeout(ServiceRegistryConfig.INSTANCE.getIdleConnectionTimeout());
    if (ServiceRegistryConfig.INSTANCE.isProxyEnable()) {
        ProxyOptions proxy = new ProxyOptions();
        proxy.setHost(ServiceRegistryConfig.INSTANCE.getProxyHost());
        proxy.setPort(ServiceRegistryConfig.INSTANCE.getProxyPort());
        proxy.setUsername(ServiceRegistryConfig.INSTANCE.getProxyUsername());
        proxy.setPassword(ServiceRegistryConfig.INSTANCE.getProxyPasswd());
        httpClientOptions.setProxyOptions(proxy);
    }//w ww  .j  a va2  s. c  o  m
    if (ver == HttpVersion.HTTP_2) {
        LOGGER.debug("service center client protocol version is HTTP/2");
        httpClientOptions.setHttp2ClearTextUpgrade(false);
    }
    if (ServiceRegistryConfig.INSTANCE.isSsl()) {
        LOGGER.debug("service center client performs requests over TLS");
        VertxTLSBuilder.buildHttpClientOptions(SSL_KEY, httpClientOptions);
    }
    return httpClientOptions;
}

From source file:org.apache.servicecomb.serviceregistry.client.http.WebsocketClientPool.java

License:Apache License

@Override
public HttpClientOptions createHttpClientOptions() {
    HttpVersion ver = ServiceRegistryConfig.INSTANCE.getHttpVersion();
    HttpClientOptions httpClientOptions = new HttpClientOptions();
    httpClientOptions.setProtocolVersion(ver);
    httpClientOptions.setConnectTimeout(ServiceRegistryConfig.INSTANCE.getConnectionTimeout());
    httpClientOptions.setIdleTimeout(ServiceRegistryConfig.INSTANCE.getIdleWatchTimeout());
    if (ver == HttpVersion.HTTP_2) {
        LOGGER.debug("service center ws client protocol version is HTTP/2");
        httpClientOptions.setHttp2ClearTextUpgrade(false);
    }/*from www . ja v  a 2 s . c  o m*/
    if (ServiceRegistryConfig.INSTANCE.isSsl()) {
        LOGGER.debug("service center ws client performs requests over TLS");
        VertxTLSBuilder.buildHttpClientOptions(SSL_KEY, httpClientOptions);
    }
    return httpClientOptions;
}

From source file:org.apache.servicecomb.transport.rest.client.RestTransportClient.java

License:Apache License

private static HttpClientOptions createHttp2ClientOptions() {
    HttpClientOptions httpClientOptions = new HttpClientOptions();
    httpClientOptions.setUseAlpn(TransportClientConfig.getUseAlpn()).setHttp2ClearTextUpgrade(false)
            .setProtocolVersion(HttpVersion.HTTP_2)
            .setIdleTimeout(TransportClientConfig.getHttp2ConnectionIdleTimeoutInSeconds())
            .setHttp2MultiplexingLimit(TransportClientConfig.getHttp2MultiplexingLimit())
            .setHttp2MaxPoolSize(TransportClientConfig.getHttp2ConnectionMaxPoolSize())
            .setTryUseCompression(TransportClientConfig.getConnectionCompression());

    VertxTLSBuilder.buildHttpClientOptions(SSL_KEY, httpClientOptions);
    return httpClientOptions;
}