/** * Sets the Web Client user agent header. Defaults to Vert.x-WebClient/<version>. * * @param userAgent user agent header value * @return a reference to this, so the API can be used fluently */ @Override public ConsulClientOptions setUserAgent(String userAgent) { return (ConsulClientOptions) super.setUserAgent(userAgent); }
@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.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.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); } }
.setUserAgent("vert-x3")); String clientId = session.get("github_client_id"); String clientSecret = session.get("github_client_secret");
.setUserAgent("vert-x3")); String clientId = session.get("github_client_id"); String clientSecret = session.get("github_client_secret");
.setUserAgent("vert-x3")); HttpResponse<JsonObject> response = await(webClient.post(443, "api.github.com", "/gists") .putHeader("Accept", "application/vnd.github.v3+json")
.setUserAgent("vert-x3")); HttpResponse<JsonObject> response = await(webClient.post(443, "api.github.com", "/gists") .putHeader("Accept", "application/vnd.github.v3+json")
@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))); }
private WebClientOptions initWebClientOptions(Request request) { WebClientOptions options = new WebClientOptions(); options.setKeepAlive(true).setReuseAddress(true).setFollowRedirects(true); if (Preconditions.isNotBlank(request.getUserAgent())) { options.setUserAgent(request.getUserAgent()); } if (Preconditions.isNotBlank(request.getProxy())) { ProxyOptions proxyOptions = new ProxyOptions(); proxyOptions.setHost(request.getProxy().getIp()); proxyOptions.setPort(request.getProxy().getPort()); options.setProxyOptions(proxyOptions); } if (Preconditions.isNotBlank(request.getHeader())) { header = request.getHeader(); } return options; }