Search in sources :

Example 11 with ProxyOptions

use of io.vertx.core.net.ProxyOptions in project vert.x by eclipse.

the class Http1xProxyTest method testWsHttpProxy.

@Test
public void testWsHttpProxy() throws Exception {
    startProxy(null, ProxyType.HTTP);
    testWebSocket(createBaseServerOptions(), new HttpClientOptions().setProxyOptions(new ProxyOptions().setType(ProxyType.HTTP).setHost(DEFAULT_HTTP_HOST).setPort(proxy.getPort())), true);
}
Also used : ProxyOptions(io.vertx.core.net.ProxyOptions) Test(org.junit.Test)

Example 12 with ProxyOptions

use of io.vertx.core.net.ProxyOptions in project vert.x by eclipse.

the class Http1xProxyTest method testWssHttpProxy.

@Test
public void testWssHttpProxy() throws Exception {
    startProxy(null, ProxyType.HTTP);
    testWebSocket(createBaseServerOptions().setSsl(true).setKeyCertOptions(Cert.SERVER_JKS.get()), new HttpClientOptions().setSsl(true).setTrustOptions(Cert.SERVER_JKS.get()).setProxyOptions(new ProxyOptions().setType(ProxyType.HTTP).setHost(DEFAULT_HTTP_HOST).setPort(proxy.getPort())), true);
}
Also used : ProxyOptions(io.vertx.core.net.ProxyOptions) Test(org.junit.Test)

Example 13 with ProxyOptions

use of io.vertx.core.net.ProxyOptions in project vert.x by eclipse.

the class Http1xProxyTest method testHttpProxyRequest2.

@Test
public void testHttpProxyRequest2() throws Exception {
    startProxy(null, ProxyType.HTTP);
    testHttpProxyRequest(() -> client.request(new RequestOptions().setProxyOptions(new ProxyOptions().setType(ProxyType.HTTP).setHost("localhost").setPort(proxy.getPort())).setHost(DEFAULT_HTTP_HOST).setPort(DEFAULT_HTTP_PORT).setURI("/")).compose(HttpClientRequest::send)).onComplete(onSuccess(v -> {
        assertProxiedRequest(DEFAULT_HTTP_HOST);
        testComplete();
    }));
    await();
}
Also used : ProxyOptions(io.vertx.core.net.ProxyOptions) HttpClientImpl(io.vertx.core.http.impl.HttpClientImpl) VertxOptions(io.vertx.core.VertxOptions) Set(java.util.Set) Test(org.junit.Test) Future(io.vertx.core.Future) Supplier(java.util.function.Supplier) HashSet(java.util.HashSet) List(java.util.List) Buffer(io.vertx.core.buffer.Buffer) ProxyType(io.vertx.core.net.ProxyType) Cert(io.vertx.test.tls.Cert) Collections(java.util.Collections) SocketAddress(io.vertx.core.net.SocketAddress) ProxyOptions(io.vertx.core.net.ProxyOptions) Test(org.junit.Test)

Example 14 with ProxyOptions

use of io.vertx.core.net.ProxyOptions in project java-chassis by ServiceComb.

the class DefaultMonitorDataPublisher method createHttpClientOptions.

private HttpClientOptions createHttpClientOptions() {
    HttpClientOptions httpClientOptions = new HttpClientOptions();
    if (MonitorConstant.isProxyEnable()) {
        ProxyOptions proxy = new ProxyOptions();
        proxy.setHost(MonitorConstant.getProxyHost());
        proxy.setPort(MonitorConstant.getProxyPort());
        proxy.setUsername(MonitorConstant.getProxyUsername());
        proxy.setPassword(MonitorConstant.getProxyPasswd());
        httpClientOptions.setProxyOptions(proxy);
    }
    httpClientOptions.setConnectTimeout(MonitorConstant.getConnectionTimeout());
    if (MonitorConstant.sslEnabled()) {
        SSLOptionFactory factory = SSLOptionFactory.createSSLOptionFactory(SSL_KEY, null);
        SSLOption sslOption;
        if (factory == null) {
            sslOption = SSLOption.buildFromYaml(SSL_KEY);
        } else {
            sslOption = factory.createSSLOption();
        }
        SSLCustom sslCustom = SSLCustom.createSSLCustom(sslOption.getSslCustomClass());
        VertxTLSBuilder.buildHttpClientOptions(sslOption, sslCustom, httpClientOptions);
    }
    return httpClientOptions;
}
Also used : ProxyOptions(io.vertx.core.net.ProxyOptions) SSLOptionFactory(org.apache.servicecomb.foundation.ssl.SSLOptionFactory) SSLOption(org.apache.servicecomb.foundation.ssl.SSLOption) SSLCustom(org.apache.servicecomb.foundation.ssl.SSLCustom) HttpClientOptions(io.vertx.core.http.HttpClientOptions)

Example 15 with ProxyOptions

use of io.vertx.core.net.ProxyOptions in project java-chassis by ServiceComb.

the class HttpClientOptionsSPI method createHttpClientOptions.

static HttpClientOptions createHttpClientOptions(HttpClientOptionsSPI spi) {
    HttpClientOptions httpClientOptions = new HttpClientOptions();
    httpClientOptions.setProtocolVersion(spi.getHttpVersion());
    httpClientOptions.setConnectTimeout(spi.getConnectTimeoutInMillis());
    httpClientOptions.setIdleTimeout(spi.getIdleTimeoutInSeconds());
    httpClientOptions.setTryUseCompression(spi.isTryUseCompression());
    httpClientOptions.setMaxWaitQueueSize(spi.getMaxWaitQueueSize());
    httpClientOptions.setMaxPoolSize(spi.getMaxPoolSize());
    httpClientOptions.setKeepAlive(spi.isKeepAlive());
    httpClientOptions.setMaxHeaderSize(spi.getMaxHeaderSize());
    httpClientOptions.setKeepAliveTimeout(spi.getKeepAliveTimeout());
    if (spi.isProxyEnable()) {
        ProxyOptions proxy = new ProxyOptions();
        proxy.setHost(spi.getProxyHost());
        proxy.setPort(spi.getProxyPort());
        proxy.setUsername(spi.getProxyUsername());
        proxy.setPassword(Encryptions.decode(spi.getProxyPassword(), spi.getConfigTag()));
        httpClientOptions.setProxyOptions(proxy);
    }
    if (spi.getHttpVersion() == HttpVersion.HTTP_2) {
        httpClientOptions.setHttp2ClearTextUpgrade(false);
        httpClientOptions.setUseAlpn(spi.isUseAlpn());
        httpClientOptions.setHttp2MultiplexingLimit(spi.getHttp2MultiplexingLimit());
        httpClientOptions.setHttp2MaxPoolSize(spi.getHttp2MaxPoolSize());
    }
    if (spi.isSsl()) {
        VertxTLSBuilder.buildHttpClientOptions(spi.getConfigTag(), httpClientOptions);
    }
    return httpClientOptions;
}
Also used : ProxyOptions(io.vertx.core.net.ProxyOptions) HttpClientOptions(io.vertx.core.http.HttpClientOptions)

Aggregations

ProxyOptions (io.vertx.core.net.ProxyOptions)28 Test (org.junit.Test)15 HttpClientOptions (io.vertx.core.http.HttpClientOptions)7 SocketAddress (io.vertx.core.net.SocketAddress)5 JsonObject (io.vertx.core.json.JsonObject)4 Handler (io.vertx.core.Handler)3 HttpClientRequest (io.vertx.core.http.HttpClientRequest)3 ProxyType (io.vertx.core.net.ProxyType)3 HttpClientSslOptions (io.gravitee.definition.model.HttpClientSslOptions)2 HttpProxy (io.gravitee.definition.model.HttpProxy)2 HttpClient (io.vertx.core.http.HttpClient)2 ContextInternal (io.vertx.core.impl.ContextInternal)2 Endpoint (io.vertx.core.net.impl.pool.Endpoint)2 SSLCustom (org.apache.servicecomb.foundation.ssl.SSLCustom)2 SSLOption (org.apache.servicecomb.foundation.ssl.SSLOption)2 SSLOptionFactory (org.apache.servicecomb.foundation.ssl.SSLOptionFactory)2 HttpHeaders (io.gravitee.common.http.HttpHeaders)1 HttpStatusCode (io.gravitee.common.http.HttpStatusCode)1 HttpEndpoint (io.gravitee.definition.model.endpoint.HttpEndpoint)1 EndpointRule (io.gravitee.gateway.services.healthcheck.EndpointRule)1