use of io.vertx.core.http.HttpServerOptions in project vert.x by eclipse.
the class HTTP2Examples method example0.
public void example0(Vertx vertx) {
HttpServerOptions options = new HttpServerOptions().setUseAlpn(true).setSsl(true).setKeyStoreOptions(new JksOptions().setPath("/path/to/my/keystore"));
HttpServer server = vertx.createHttpServer(options);
}
use of io.vertx.core.http.HttpServerOptions in project vert.x by eclipse.
the class HttpTest method testListenInvalidPort.
@Test
public void testListenInvalidPort() throws Exception {
/* Port 7 is free for use by any application in Windows, so this test fails. */
Assume.assumeFalse(System.getProperty("os.name").startsWith("Windows"));
server.close();
server = vertx.createHttpServer(new HttpServerOptions().setPort(7));
server.requestHandler(noOpHandler()).listen(onFailure(server -> testComplete()));
await();
}
use of io.vertx.core.http.HttpServerOptions in project vert.x by eclipse.
the class Http2Test method testServerOpenSSL.
@Test
public void testServerOpenSSL() throws Exception {
HttpServerOptions opts = new HttpServerOptions().setPort(DEFAULT_HTTPS_PORT).setHost(DEFAULT_HTTPS_HOST).setUseAlpn(true).setSsl(true).addEnabledCipherSuite(// Non Diffie-helman -> debuggable in wireshark
"TLS_RSA_WITH_AES_128_CBC_SHA").setPemKeyCertOptions(Cert.SERVER_PEM.get()).setSslEngineOptions(new OpenSSLEngineOptions());
server.close();
client.close();
client = vertx.createHttpClient(createBaseClientOptions());
server = vertx.createHttpServer(opts);
server.requestHandler(req -> {
req.response().end();
});
CountDownLatch latch = new CountDownLatch(1);
System.out.println("starting");
try {
server.listen(onSuccess(v -> latch.countDown()));
} catch (Throwable e) {
e.printStackTrace();
}
System.out.println("listening");
awaitLatch(latch);
client.get(DEFAULT_HTTPS_PORT, DEFAULT_HTTPS_HOST, "/somepath", resp -> {
assertEquals(200, resp.statusCode());
testComplete();
}).exceptionHandler(this::fail).end();
await();
}
use of io.vertx.core.http.HttpServerOptions in project vert.x by eclipse.
the class HttpTest method testUseInMultithreadedWorker.
@Test
public void testUseInMultithreadedWorker() throws Exception {
class MyVerticle extends AbstractVerticle {
@Override
public void start() {
assertIllegalStateException(() -> server = vertx.createHttpServer(new HttpServerOptions()));
assertIllegalStateException(() -> client = vertx.createHttpClient(new HttpClientOptions()));
testComplete();
}
}
MyVerticle verticle = new MyVerticle();
vertx.deployVerticle(verticle, new DeploymentOptions().setWorker(true).setMultiThreaded(true));
await();
}
use of io.vertx.core.http.HttpServerOptions 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();
}
Aggregations