use of io.vertx.core.http.HttpVersion in project vert.x by eclipse.
the class HttpMetricsTest method testServerConnectionClosed.
private void testServerConnectionClosed(HttpVersion protocol) throws Exception {
server.close();
server = vertx.createHttpServer(new HttpServerOptions().setPort(DEFAULT_HTTP_PORT).setHost(DEFAULT_HTTP_HOST).setIdleTimeout(2));
server.requestHandler(req -> {
FakeHttpServerMetrics metrics = FakeMetricsBase.getMetrics(server);
HttpServerMetric metric = metrics.getMetric(req);
assertNotNull(metric);
assertFalse(metric.failed.get());
req.response().closeHandler(v -> {
assertNull(metrics.getMetric(req));
assertTrue(metric.failed.get());
testComplete();
});
});
startServer();
client = vertx.createHttpClient(new HttpClientOptions().setProtocolVersion(protocol));
HttpClientRequest req = client.get(DEFAULT_HTTP_PORT, DEFAULT_HTTP_HOST, "/somepath");
req.handler(resp -> {
}).end();
await();
}
use of io.vertx.core.http.HttpVersion in project java-chassis by ServiceComb.
the class HttpClientPool 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 client protocol version is HTTP/2");
httpClientOptions.setHttp2ClearTextUpgrade(false);
}
if (ServiceRegistryConfig.INSTANCE.isSsl()) {
LOGGER.debug("service center client performs requests over TLS");
buildSecureClientOptions(httpClientOptions);
}
return httpClientOptions;
}
Aggregations