case "defaultHost": if (member.getValue() instanceof String) { obj.setDefaultHost((String)member.getValue());
@Test public void testMaxWaitQueueSizeIsRespected() throws Exception { client.close(); client = vertx.createHttpClient(new HttpClientOptions().setDefaultHost(DEFAULT_HTTP_HOST).setDefaultPort(DEFAULT_HTTP_PORT) .setPipelining(false).setMaxWaitQueueSize(0).setMaxPoolSize(2)); waitFor(3); Set<String> expected = new HashSet<>(Arrays.asList("/1", "/2")); server.requestHandler(req -> { assertTrue(expected.contains(req.path())); complete(); }); startServer(); HttpClientRequest req1 = client.get("/1", onFailure(err -> { })); HttpClientRequest req2 = client.get("/2", onFailure(resp -> { })); HttpClientRequest req3 = client.get("/3", onFailure(t -> { assertTrue("Incorrect exception: " + t.getClass().getName(), t instanceof ConnectionPoolTooBusyException); complete(); })); req1.end(); req2.end(); req3.end(); await(); }
.setDefaultHost("localhost") .setDefaultPort(8080) .setKeepAlive(true)
.setProtocolVersion(HttpVersion.HTTP_2) .setDefaultPort(8080) .setDefaultHost("localhost")); client.get("/somepath", onSuccess(resp1 -> { resp1.exceptionHandler(this::fail);
case "defaultHost": if (member.getValue() instanceof String) { obj.setDefaultHost((String)member.getValue());
@Override public RestClientOptions setDefaultHost(String defaultHost) { super.setDefaultHost(defaultHost); return this; }
private void connect(final Runnable runnable) { final HttpClientOptions httpClientOptions = new HttpClientOptions(); final JksOptions jksOptions = new JksOptions(); jksOptions.setPath(trustStorePath).setPassword(trustStorePassword); httpClientOptions.setDefaultHost(host).setDefaultPort(port) .setConnectTimeout(timeOutInMilliseconds) .setMaxPoolSize(poolSize) .setKeepAlive(keepAlive) .setPipelining(pipeline) .setSoLinger(soLinger) .setTcpNoDelay(tcpNoDelay) .setTryUseCompression(tryUseCompression) .setSsl(ssl) .setTrustAll(trustAll) .setVerifyHost(verifyHost) .setMaxWebsocketFrameSize(maxWebSocketFrameSize) .setUsePooledBuffers(true); httpClient = vertx.createHttpClient(httpClientOptions); if (debug) logger.debug("HTTP CLIENT: connect:: \nhost {} \nport {}\n", host, port); closed.set(false); Sys.sleep(100); if (runnable != null) runnable.run(); }
.setDefaultHost("localhost") .setDefaultPort(8080) .setKeepAlive(true)
@Test public void testMaxWaitQueueSizeIsRespected() throws Exception { client.close(); client = vertx.createHttpClient(new HttpClientOptions().setDefaultHost(DEFAULT_HTTP_HOST).setDefaultPort(DEFAULT_HTTP_PORT) .setPipelining(false).setMaxWaitQueueSize(0).setMaxPoolSize(2)); waitFor(3); Set<String> expected = new HashSet<>(Arrays.asList("/1", "/2")); server.requestHandler(req -> { assertTrue(expected.contains(req.path())); complete(); }); startServer(); HttpClientRequest req1 = client.get("/1", resp -> { fail("Should not be called."); }); HttpClientRequest req2 = client.get("/2", resp -> { fail("Should not be called."); }); HttpClientRequest req3 = client.get("/3", resp -> { fail("Should not be called."); }); req3.exceptionHandler(t -> { assertTrue("Incorrect exception: " + t.getClass().getName(), t instanceof ConnectionPoolTooBusyException); complete(); }); req1.end(); req2.end(); req3.end(); await(); }
/** * Create an HttpClient for the given host * @param u the host * @return the HttpClient */ private HttpClient createClient(URI u) { HttpClientOptions clientOptions = new HttpClientOptions(defaultOptions) .setDefaultHost(u.getHost()) .setDefaultPort(u.getPort()); return vertx.createHttpClient(clientOptions); }
.setProtocolVersion(HttpVersion.HTTP_2) .setDefaultPort(8080) .setDefaultHost("localhost")); client.get("/somepath", resp1 -> { resp1.exceptionHandler(this::fail);
public DefaultClient(Integer port, String host) { HttpClientOptions options = new HttpClientOptions(); options.setDefaultHost(host); options.setDefaultPort(port); options.setProtocolVersion(HttpVersion.HTTP_1_1); httpClient = Vertx.vertx().createHttpClient(options); }
public AbstractMeshRestHttpClient(String host, int port, boolean ssl, Vertx vertx) { HttpClientOptions options = new HttpClientOptions(); options.setDefaultHost(host); options.setTryUseCompression(true); options.setDefaultPort(port); options.setSsl(ssl); this.clientOptions = options; this.vertx = vertx; }
/** * Create a client connecting to GeoRocket running on the * specified host and port * @param host the GeoRocket host * @param port the GeoRocket port * @param vertx a Vert.x instance used to create a HTTP client */ public GeoRocketClient(String host, int port, Vertx vertx) { this(vertx.createHttpClient(new HttpClientOptions() .setDefaultHost(host) .setDefaultPort(port) .setTryUseCompression(true))); }
public HttpResourceStorage(Vertx vertx, String host, int port) { this.host = host; this.port = port; this.client = vertx.createHttpClient(new HttpClientOptions() .setDefaultHost(host) .setDefaultPort(port) .setMaxPoolSize(500) .setReuseAddress(true) .setKeepAlive(true) .setPipelining(false)); }
private HonoHttpDevice() { final HttpClientOptions options = new HttpClientOptions(); options.setDefaultHost(HONO_HTTP_ADAPTER_HOST); options.setDefaultPort(HONO_HTTP_ADAPTER_PORT); httpClient = VERTX.createHttpClient(options); standardRequestHeaders = MultiMap.caseInsensitiveMultiMap() .add(HttpHeaders.AUTHORIZATION, getBasicAuth(TENANT_ID, DEVICE_AUTH_ID, DEVICE_PASSWORD)) .add(HttpHeaders.ORIGIN, ORIGIN_URI); }
private WebClient buildPlainWebClient() { HttpClient vc = vertx.createHttpClient(new HttpClientOptions().setDefaultPort(PORT).setDefaultHost("localhost")); return WebClient.wrap(vc); }
@Override public void setUp() throws Exception { super.setUp(); super.client = vertx.createHttpClient(new HttpClientOptions().setDefaultPort(8080).setDefaultHost("localhost")); client = (WebClientInternal) WebClient.wrap(super.client); server.close(); server = vertx.createHttpServer(new HttpServerOptions().setPort(DEFAULT_HTTP_PORT).setHost(DEFAULT_HTTP_HOST)); }
/** * Creates a HttpClient to do requests against the server. No SSL is used. * @return a client that's preconfigured for requests to the server. */ private static HttpClient createHttpClient() { HttpClientOptions options = new HttpClientOptions() .setDefaultHost(vertx.getOrCreateContext().config().getString(ConfigConstants.HOST)) .setDefaultPort(vertx.getOrCreateContext().config().getInteger(ConfigConstants.PORT)) .setSsl(false); return vertxCore.createHttpClient(options); }
@Override public void setUp() throws Exception { super.setUp(); super.client = vertx.createHttpClient(new HttpClientOptions().setDefaultPort(8080).setDefaultHost("localhost")); client = WebClient.wrap(super.client); server.close(); server = vertx.createHttpServer(new HttpServerOptions().setPort(DEFAULT_HTTP_PORT).setHost(DEFAULT_HTTP_HOST)); testFile = testFolder.newFile("test.txt"); }