use of io.vertx.core.http.HttpClientOptions in project vert.x by eclipse.
the class HttpTest method testDumpManyRequestsOnQueue.
@Test
public void testDumpManyRequestsOnQueue() throws Exception {
int sendRequests = 10000;
AtomicInteger receivedRequests = new AtomicInteger();
vertx.createHttpServer(createBaseServerOptions()).requestHandler(r -> {
r.response().end();
if (receivedRequests.incrementAndGet() == sendRequests) {
testComplete();
}
}).listen(onSuccess(s -> {
HttpClientOptions ops = createBaseClientOptions().setDefaultPort(DEFAULT_HTTP_PORT).setPipelining(true).setKeepAlive(true);
HttpClient client = vertx.createHttpClient(ops);
IntStream.range(0, sendRequests).forEach(x -> client.getNow("/", r -> {
}));
}));
await();
}
use of io.vertx.core.http.HttpClientOptions in project java-chassis by ServiceComb.
the class TestRestTransportClient method testCreateHttpClientOptions.
@Test
public void testCreateHttpClientOptions() {
HttpClientOptions obj = (HttpClientOptions) Deencapsulation.invoke(instance, "createHttpClientOptions");
Assert.assertNotNull(obj);
}
use of io.vertx.core.http.HttpClientOptions in project java-chassis by ServiceComb.
the class RestTransportClient method createHttpClientOptions.
private HttpClientOptions createHttpClientOptions() {
HttpClientOptions httpClientOptions = new HttpClientOptions();
if (this.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;
}
use of io.vertx.core.http.HttpClientOptions in project java-chassis by ServiceComb.
the class TestVertxTLSBuilder method testbuildClientOptionsBaseFileNull.
@Test
public void testbuildClientOptionsBaseFileNull() {
SSLOption option = SSLOption.buildFromYaml("rest.consumer");
option.setKeyStore(null);
option.setTrustStore(null);
option.setCrl(null);
SSLCustom custom = SSLCustom.createSSLCustom(option.getSslCustomClass());
HttpClientOptions serverOptions = new HttpClientOptions();
VertxTLSBuilder.buildClientOptionsBase(option, custom, serverOptions);
Assert.assertEquals(serverOptions.getEnabledSecureTransportProtocols().toArray().length, 1);
Assert.assertEquals(serverOptions.isTrustAll(), true);
}
use of io.vertx.core.http.HttpClientOptions in project java-chassis by ServiceComb.
the class WebsocketClientPool method createHttpClientOptions.
@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 ws client protocol version is HTTP/2");
httpClientOptions.setHttp2ClearTextUpgrade(false);
}
if (ServiceRegistryConfig.INSTANCE.isSsl()) {
LOGGER.debug("service center ws client performs requests over TLS");
buildSecureClientOptions(httpClientOptions);
}
return httpClientOptions;
}
Aggregations