/** * Set the default port to be used by this client in requests if none is provided when making the request. * * @return a reference to this, so the API can be used fluently */ @Override public ConsulClientOptions setDefaultPort(int defaultPort) { return (ConsulClientOptions) super.setDefaultPort(defaultPort); }
/** * Creates an instance of {@link SlimVaultClient}. * * @param vertx the vert.x instance * @param configuration the configuration. This configuration can contain the underlying Web Client configuration. */ public SlimVaultClient(Vertx vertx, JsonObject configuration) { String host = configuration.getString("host"); Integer port = configuration.getInteger("port", 8200); Objects.requireNonNull(host, "The Vault host must be set"); client = WebClient.create(vertx, new WebClientOptions(configuration) .setDefaultPort(port).setDefaultHost(host) ); setToken(configuration.getString("token")); }
.setUsePooledBuffers(true) .setDefaultHost(elasticEdpt.getHost()) .setDefaultPort(elasticEdpt.getPort() != -1 ? elasticEdpt.getPort() : (HTTPS_SCHEME.equals(elasticEdpt.getScheme()) ? 443 : 80));
.setSsl(configuration.getBoolean("ssl", true)) .setDefaultHost(host) .setDefaultPort(port) .setFollowRedirects(true) );
.setSsl(conf.getBoolean("ssl", true)) .setDefaultHost(host) .setDefaultPort(port) .setFollowRedirects(true) );
@Test public void testToJson() { WebClientOptions options = new WebClientOptions() .setDefaultPort(4848) .setMaxPoolSize(50) .setUserAgentEnabled(false); JsonObject json = options.toJson(); assertEquals(4848, (int) json.getInteger("defaultPort")); assertEquals(50, (int) json.getInteger("maxPoolSize")); assertEquals(false, json.getBoolean("userAgentEnabled")); } }
private void testTLS(boolean clientSSL, boolean serverSSL, Function<WebClient, HttpRequest<Buffer>> requestProvider, Consumer<HttpServerRequest> serverAssertions) throws Exception { WebClientOptions clientOptions = new WebClientOptions() .setSsl(clientSSL) .setTrustAll(true) .setDefaultHost(DEFAULT_HTTPS_HOST) .setDefaultPort(DEFAULT_HTTPS_PORT); HttpServerOptions serverOptions = new HttpServerOptions() .setSsl(serverSSL) .setKeyStoreOptions(Cert.SERVER_JKS.get()) .setPort(DEFAULT_HTTPS_PORT) .setHost(DEFAULT_HTTPS_HOST); testTLS(clientOptions, serverOptions, requestProvider, serverAssertions); }
@Test public void testVirtualHostSNI() throws Exception { WebClientOptions clientOptions = new WebClientOptions() .setTrustAll(true) .setDefaultHost(DEFAULT_HTTPS_HOST) .setDefaultPort(DEFAULT_HTTPS_PORT); HttpServerOptions serverOptions = new HttpServerOptions() .setSsl(true) .setSni(true) .setKeyStoreOptions(Cert.SNI_JKS.get()) .setPort(DEFAULT_HTTPS_PORT) .setHost(DEFAULT_HTTPS_HOST); testTLS(clientOptions, serverOptions, req -> req.get("/").virtualHost("host2.com").ssl(true), req -> { assertEquals("host2.com", req.connection().indicatedServerName()); System.out.println(req.host()); }); }