Search in sources :

Example 36 with HttpClientOptions

use of io.vertx.core.http.HttpClientOptions in project vert.x by eclipse.

the class SSLHelperTest method testUseJdkCiphersWhenNotSpecified.

@Test
public void testUseJdkCiphersWhenNotSpecified() throws Exception {
    SSLContext context = SSLContext.getInstance("TLS");
    context.init(null, null, null);
    SSLEngine engine = context.createSSLEngine();
    String[] expected = engine.getEnabledCipherSuites();
    SSLHelper helper = new SSLHelper(new HttpClientOptions(), Cert.CLIENT_JKS.get(), Trust.SERVER_JKS.get());
    SslContext ctx = helper.getContext((VertxInternal) vertx);
    assertEquals(new HashSet<>(Arrays.asList(expected)), new HashSet<>(ctx.cipherSuites()));
}
Also used : SSLHelper(io.vertx.core.net.impl.SSLHelper) SSLEngine(javax.net.ssl.SSLEngine) SSLContext(javax.net.ssl.SSLContext) HttpClientOptions(io.vertx.core.http.HttpClientOptions) SslContext(io.netty.handler.ssl.SslContext) Test(org.junit.Test)

Example 37 with HttpClientOptions

use of io.vertx.core.http.HttpClientOptions in project vert.x by eclipse.

the class SSLHelperTest method testUseOpenSSLCiphersWhenNotSpecified.

@Test
public void testUseOpenSSLCiphersWhenNotSpecified() throws Exception {
    Set<String> expected = OpenSsl.availableOpenSslCipherSuites();
    SSLHelper helper = new SSLHelper(new HttpClientOptions().setOpenSslEngineOptions(new OpenSSLEngineOptions()), Cert.CLIENT_PEM.get(), Trust.SERVER_PEM.get());
    SslContext ctx = helper.getContext((VertxInternal) vertx);
    assertEquals(expected, new HashSet<>(ctx.cipherSuites()));
}
Also used : SSLHelper(io.vertx.core.net.impl.SSLHelper) HttpClientOptions(io.vertx.core.http.HttpClientOptions) SslContext(io.netty.handler.ssl.SslContext) Test(org.junit.Test)

Example 38 with HttpClientOptions

use of io.vertx.core.http.HttpClientOptions in project vert.x by eclipse.

the class HTTP2Examples method useMaxStreams.

public void useMaxStreams(Vertx vertx) {
    HttpClientOptions clientOptions = new HttpClientOptions().setHttp2MultiplexingLimit(10).setHttp2MaxPoolSize(3);
    // Uses up to 3 connections and up to 10 streams per connection
    HttpClient client = vertx.createHttpClient(clientOptions);
}
Also used : HttpClient(io.vertx.core.http.HttpClient) HttpClientOptions(io.vertx.core.http.HttpClientOptions)

Example 39 with HttpClientOptions

use of io.vertx.core.http.HttpClientOptions in project vert.x by eclipse.

the class HTTP2Examples method example8.

public void example8(Vertx vertx) {
    HttpClientOptions options = new HttpClientOptions().setProtocolVersion(HttpVersion.HTTP_2);
    HttpClient client = vertx.createHttpClient(options);
}
Also used : HttpClient(io.vertx.core.http.HttpClient) HttpClientOptions(io.vertx.core.http.HttpClientOptions)

Example 40 with HttpClientOptions

use of io.vertx.core.http.HttpClientOptions in project vert.x by eclipse.

the class FileResolverTestBase method testSendFileFromClasspath.

@Test
public void testSendFileFromClasspath() {
    vertx.createHttpServer(new HttpServerOptions().setPort(8080)).requestHandler(res -> {
        res.response().sendFile("webroot/somefile.html");
    }).listen(onSuccess(res -> {
        vertx.createHttpClient(new HttpClientOptions()).request(HttpMethod.GET, 8080, "localhost", "/").compose(HttpClientRequest::send).onComplete(onSuccess(resp -> {
            resp.bodyHandler(buff -> {
                assertTrue(buff.toString().startsWith("<html><body>blah</body></html>"));
                testComplete();
            });
        }));
    }));
    await();
}
Also used : java.util(java.util) URL(java.net.URL) VertxTestBase(io.vertx.test.core.VertxTestBase) Function(java.util.function.Function) Utils(io.vertx.core.impl.Utils) HttpClientRequest(io.vertx.core.http.HttpClientRequest) PosixFilePermissions(java.nio.file.attribute.PosixFilePermissions) FileResolver(io.vertx.core.spi.file.FileResolver) Assume(org.junit.Assume) HttpClientOptions(io.vertx.core.http.HttpClientOptions) VertxInternal(io.vertx.core.impl.VertxInternal) Files(java.nio.file.Files) Vertx(io.vertx.core.Vertx) StandardOpenOption(java.nio.file.StandardOpenOption) VertxOptions(io.vertx.core.VertxOptions) Test(org.junit.Test) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) File(java.io.File) CountDownLatch(java.util.concurrent.CountDownLatch) Buffer(io.vertx.core.buffer.Buffer) HttpMethod(io.vertx.core.http.HttpMethod) FileResolverImpl(io.vertx.core.file.impl.FileResolverImpl) HttpServerOptions(io.vertx.core.http.HttpServerOptions) Assert(org.junit.Assert) HttpClientRequest(io.vertx.core.http.HttpClientRequest) HttpServerOptions(io.vertx.core.http.HttpServerOptions) HttpClientOptions(io.vertx.core.http.HttpClientOptions) Test(org.junit.Test)

Aggregations

HttpClientOptions (io.vertx.core.http.HttpClientOptions)101 Test (org.junit.Test)51 HttpClient (io.vertx.core.http.HttpClient)27 HttpClientRequest (io.vertx.core.http.HttpClientRequest)23 HttpServerOptions (io.vertx.core.http.HttpServerOptions)19 CountDownLatch (java.util.concurrent.CountDownLatch)15 HttpMethod (io.vertx.core.http.HttpMethod)14 SSLCustom (org.apache.servicecomb.foundation.ssl.SSLCustom)14 SSLOption (org.apache.servicecomb.foundation.ssl.SSLOption)14 HttpVersion (io.vertx.core.http.HttpVersion)13 AtomicReference (java.util.concurrent.atomic.AtomicReference)13 Vertx (io.vertx.core.Vertx)11 MockUp (mockit.MockUp)11 DeploymentOptions (io.vertx.core.DeploymentOptions)10 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)10 Buffer (io.vertx.core.buffer.Buffer)9 HttpServer (io.vertx.core.http.HttpServer)8 HttpServerResponse (io.vertx.core.http.HttpServerResponse)8 VertxOptions (io.vertx.core.VertxOptions)7 VertxInternal (io.vertx.core.impl.VertxInternal)7