HttpClientConfig extends ClientConfig { public Set<HttpHost> getPreemptiveAuthTargetHosts() { return preemptiveAuthTargetHosts; } HttpClientConfig(Builder builder); Map<HttpRoute, Integer> getMaxTotalConnectionPerRoute(); Integer getMaxTotalConnection(); Integer getDefaultMaxTotalConnectionPerRoute(); CredentialsProvider getCredentialsProvider(); LayeredConnectionSocketFactory getSslSocketFactory(); ConnectionSocketFactory getPlainSocketFactory(); HttpRoutePlanner getHttpRoutePlanner(); AuthenticationStrategy getProxyAuthenticationStrategy(); SchemeIOSessionStrategy getHttpIOSessionStrategy(); SchemeIOSessionStrategy getHttpsIOSessionStrategy(); Set<HttpHost> getPreemptiveAuthTargetHosts(); ElasticsearchVersion getElasticsearchVersion();  }
@Test public void preemptiveAuth() { String hostName = "targetHost"; int port = 80; HttpHost targetHost = new HttpHost(hostName, port, "http"); HttpClientConfig httpClientConfig = new HttpClientConfig.Builder("localhost") .defaultCredentials("someUser", "somePassword") .setPreemptiveAuth(targetHost) .build(); assertThat(httpClientConfig.getPreemptiveAuthTargetHosts(), hasItem(targetHost)); }
@Test public void preemptiveAuthWithMultipleTargetHosts() { final Set<HttpHost> targetHosts = new HashSet<HttpHost>(Arrays.asList( new HttpHost("host1", 80, "http"), new HttpHost("host2", 81, "https") )); HttpClientConfig httpClientConfig = new HttpClientConfig.Builder("localhost") .defaultCredentials("someUser", "somePassword") .preemptiveAuthTargetHosts(new HashSet<HttpHost>(targetHosts)) .build(); assertThat(httpClientConfig.getPreemptiveAuthTargetHosts(), is(targetHosts)); }