@Override public void start() throws Exception { // Create the web client and enable SSL/TLS with a trust store WebClient client = WebClient.create(vertx, new WebClientOptions() .setSsl(true) .setTrustStoreOptions(new JksOptions() .setPath("client-truststore.jks") .setPassword("wibble") ) ); client.get(8443, "localhost", "/") .send(ar -> { if (ar.succeeded()) { HttpResponse<Buffer> response = ar.result(); System.out.println("Got HTTP response with status " + response.statusCode()); } else { ar.cause().printStackTrace(); } }); } }
private void init() { address = DEFAULT_ADDRESS; clientOptions = new WebClientOptions(); services = new ArrayList<>(); customHttpHeader = null; }
private void init() { address = DEFAULT_ADDRESS; clientOptions = new WebClientOptions(); services = new ArrayList<>(); customHttpHeader = null; }
private void init() { address = DEFAULT_ADDRESS; clientOptions = new WebClientOptions(); services = new ArrayList<>(); customHttpHeader = null; }
/** * Copy constructor * * @param other the instance to copy */ public HttpDataSourceAdapterOptions(HttpDataSourceAdapterOptions other) { this.address = other.address; this.clientOptions = new WebClientOptions(other.clientOptions); this.services = new ArrayList<>(other.services); this.customHttpHeader = new CustomHttpHeader(other.customHttpHeader); }
/** * Copy constructor * * @param other the instance to copy */ public HttpFormsAdapterOptions( HttpFormsAdapterOptions other) { this.address = other.address; this.clientOptions = new WebClientOptions(other.clientOptions); this.services = new ArrayList<>(other.services); this.customHttpHeader = new CustomHttpHeader(other.customHttpHeader); }
/** * Copy constructor * * @param other the instance to copy */ public ServiceAdapterOptions(ServiceAdapterOptions other) { this.address = other.address; this.clientOptions = new WebClientOptions(other.clientOptions); this.services = new ArrayList<>(other.services); this.customHttpHeader = new CustomHttpHeader(other.customHttpHeader); }
@Bean public WebClient webClient() { WebClientOptions options = new WebClientOptions() .setConnectTimeout(Integer.valueOf(properties.getProperty("oidc.http.connectionTimeout", DEFAULT_CONNECTION_TIMEOUT)) * 1000) .setMaxPoolSize(Integer.valueOf(properties.getProperty("oidc.http.pool.maxTotalConnection", DEFAULT_MAX_TOTAL_CONNECTION))) .setTrustAll(Boolean.valueOf(properties.getProperty("oidc.http.client.trustAll", "true"))); return WebClient.create(vertx,options); } }
@Bean public WebClient httpClient() { WebClientOptions httpClientOptions = new WebClientOptions(); httpClientOptions .setUserAgent(DEFAULT_USER_AGENT) .setConnectTimeout(Integer.valueOf(properties.getProperty("identities.oauth2.http.connectionTimeout", DEFAULT_CONNECTION_TIMEOUT)) * 1000) .setMaxPoolSize(Integer.valueOf(properties.getProperty("identities.oauth2.http.pool.maxTotalConnection", DEFAULT_MAX_TOTAL_CONNECTION))); return WebClient.create(vertx, httpClientOptions); } }
@Bean public WebClient httpClient() { WebClientOptions httpClientOptions = new WebClientOptions(); httpClientOptions .setUserAgent(DEFAULT_USER_AGENT) .setConnectTimeout(Integer.valueOf(properties.getProperty("identities.github.http.connectionTimeout", DEFAULT_CONNECTION_TIMEOUT)) * 1000) .setMaxPoolSize(Integer.valueOf(properties.getProperty("identities.github.http.pool.maxTotalConnection", DEFAULT_MAX_TOTAL_CONNECTION))); return WebClient.create(vertx, httpClientOptions); } }
@Bean public WebClient httpClient() { WebClientOptions httpClientOptions = new WebClientOptions(); httpClientOptions .setUserAgent(DEFAULT_USER_AGENT) .setConnectTimeout(Integer.valueOf(properties.getProperty("identities.oauth2.http.connectionTimeout", DEFAULT_CONNECTION_TIMEOUT)) * 1000) .setMaxPoolSize(Integer.valueOf(properties.getProperty("identities.oauth2.http.pool.maxTotalConnection", DEFAULT_MAX_TOTAL_CONNECTION))); return WebClient.create(vertx, httpClientOptions); } }
public static io.vertx.ext.web.client.WebClient create(io.vertx.ext.web.client.WebClient j_receiver, io.vertx.core.Vertx vertx, java.util.Map<String, Object> options) { return io.vertx.core.impl.ConversionHelper.fromObject(io.vertx.ext.web.client.WebClient.create(vertx, options != null ? new io.vertx.ext.web.client.WebClientOptions(io.vertx.core.impl.ConversionHelper.toJsonObject(options)) : null)); } public static io.vertx.ext.web.client.WebClient wrap(io.vertx.ext.web.client.WebClient j_receiver, io.vertx.core.http.HttpClient httpClient, java.util.Map<String, Object> options) {
public static io.vertx.ext.web.client.WebClient wrap(io.vertx.ext.web.client.WebClient j_receiver, io.vertx.core.http.HttpClient httpClient, java.util.Map<String, Object> options) { return io.vertx.core.impl.ConversionHelper.fromObject(io.vertx.ext.web.client.WebClient.wrap(httpClient, options != null ? new io.vertx.ext.web.client.WebClientOptions(io.vertx.core.impl.ConversionHelper.toJsonObject(options)) : null)); } }
private WebClient getWebClient(Vertx vertx, HttpAdapterConfiguration configuration) { JsonObject clientOptions = configuration.getClientOptions(); return clientOptions.isEmpty() ? WebClient.create(vertx) : WebClient.create(vertx, new WebClientOptions(clientOptions)); }
protected void connect() { this.client = WebClient.create(vertx, new WebClientOptions() .setSsl(true) // TODO: Fetch CA and use .setTrustAll(true) .setVerifyHost(false)); }
@Override protected void connect() { this.client = WebClient.create(vertx, new WebClientOptions() .setSsl(false) .setTrustAll(true) .setVerifyHost(false)); }
@Test public void testFromJson() { JsonObject json = new JsonObject() .put("defaultPort", 4848) .put("userAgentEnabled", false) .put("maxPoolSize", 50); WebClientOptions options = new WebClientOptions(json); assertEquals(4848, options.getDefaultPort()); assertFalse(options.isUserAgentEnabled()); assertEquals("Vert.x-WebClient/" + VersionCommand.getVersion(), options.getUserAgent()); assertEquals(50, options.getMaxPoolSize()); }
@Test public void testCustomUserAgent() throws Exception { client = WebClient.wrap(super.client, new WebClientOptions().setUserAgent("smith")); testRequest(client -> client.get("somehost", "somepath"), req -> assertEquals(Collections.singletonList("smith"), req.headers().getAll(HttpHeaders.USER_AGENT))); }
@Test public void testUserAgentDisabled() throws Exception { client = WebClient.wrap(super.client, new WebClientOptions().setUserAgentEnabled(false)); testRequest(client -> client.get("somehost", "somepath"), req -> assertEquals(Collections.emptyList(), req.headers().getAll(HttpHeaders.USER_AGENT))); }
@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")); } }