List of usage examples for io.vertx.core.http HttpClientOptions HttpClientOptions
public HttpClientOptions()
From source file:com.cyngn.vertx.bosun.BosunReporter.java
License:Apache License
/** * Setup our client connections/*from www . java 2s . c om*/ * * @param startedResult the startup callback for loading the module */ private void initializeConnections(Future<Void> startedResult) { try { for (int i = 0; i < hosts.size(); i++) { JsonObject jsonHost = hosts.getJsonObject(i); connections.add( vertx.createHttpClient(new HttpClientOptions().setDefaultHost(jsonHost.getString("host")) .setDefaultPort(jsonHost.getInteger("port")).setKeepAlive(true).setTcpNoDelay(true) .setConnectTimeout(timeout).setTryUseCompression(true))); } } catch (Exception ex) { startedResult.fail(ex.getLocalizedMessage()); return; } // all connections added startedResult.complete(); }
From source file:examples.HTTP2Examples.java
License:Open Source License
public void example7(Vertx vertx) { HttpClientOptions options = new HttpClientOptions().setProtocolVersion(HttpVersion.HTTP_2).setSsl(true) .setUseAlpn(true).setTrustAll(true); HttpClient client = vertx.createHttpClient(options); }
From source file:examples.HTTP2Examples.java
License:Open Source License
public void example8(Vertx vertx) { HttpClientOptions options = new HttpClientOptions().setProtocolVersion(HttpVersion.HTTP_2); HttpClient client = vertx.createHttpClient(options); }
From source file:examples.HTTP2Examples.java
License:Open Source License
public void useMaxStreams(Vertx vertx) { HttpClientOptions clientOptions = new HttpClientOptions().setHttp2MultiplexingLimit(10) .setHttp2MaxPoolSize(3);/*w w w. j av a 2 s.com*/ // Uses up to 3 connections and up to 10 streams per connection HttpClient client = vertx.createHttpClient(clientOptions); }
From source file:examples.HTTPExamples.java
License:Open Source License
public void example29(Vertx vertx) { HttpClientOptions options = new HttpClientOptions().setKeepAlive(false); HttpClient client = vertx.createHttpClient(options); }
From source file:examples.HTTPExamples.java
License:Open Source License
public void exampleClientLogging(Vertx vertx) { HttpClientOptions options = new HttpClientOptions().setLogActivity(true); HttpClient client = vertx.createHttpClient(options); }
From source file:examples.HTTPExamples.java
License:Open Source License
public void example30(Vertx vertx) { // Set the default host HttpClientOptions options = new HttpClientOptions().setDefaultHost("wibble.com"); // Can also set default port if you want... HttpClient client = vertx.createHttpClient(options); client.getNow("/some-uri", response -> { System.out.println("Received response with status code " + response.statusCode()); });//from ww w . j a v a2 s. c o m }
From source file:examples.HTTPExamples.java
License:Open Source License
public void exampleFollowRedirect02(Vertx vertx) { HttpClient client = vertx.createHttpClient(new HttpClientOptions().setMaxRedirects(32)); client.get("some-uri", response -> { System.out.println("Received response with status code " + response.statusCode()); }).setFollowRedirects(true).end();/* w w w.jav a2 s . co m*/ }
From source file:examples.HTTPExamples.java
License:Open Source License
public void example58(Vertx vertx) { HttpClientOptions options = new HttpClientOptions() .setProxyOptions(new ProxyOptions().setType(ProxyType.HTTP).setHost("localhost").setPort(3128) .setUsername("username").setPassword("secret")); HttpClient client = vertx.createHttpClient(options); }
From source file:examples.HTTPExamples.java
License:Open Source License
public void example59(Vertx vertx) { HttpClientOptions options = new HttpClientOptions() .setProxyOptions(new ProxyOptions().setType(ProxyType.SOCKS5).setHost("localhost").setPort(1080) .setUsername("username").setPassword("secret")); HttpClient client = vertx.createHttpClient(options); }