/** * Returns the default port. * * @return The default port. * * @deprecated use #getHostConfiguration() */ public int getPort() { return hostConfiguration.getPort(); }
public String getPath() { if (this.targethost != null) { StringBuffer buffer = new StringBuffer(); buffer.append(this.targethost.getHost()); int port = this.targethost.getPort(); if (port == -1) { port = this.targethost.getProtocol().getDefaultPort(); } buffer.append(':'); buffer.append(port); return buffer.toString(); } else { return "/"; } }
/** * Sets the {@link HostConfiguration host configuration}. * * @param hostconfig The hostConfiguration to set * * @deprecated no longer applicable */ public void setHostConfiguration(final HostConfiguration hostconfig) { if (hostconfig != null) { this.httphost = new HttpHost( hostconfig.getHost(), hostconfig.getPort(), hostconfig.getProtocol()); } else { this.httphost = null; } }
/** * Creates a new HTTP connection for the given host configuration. * * @param hostConfiguration the host/proxy/protocol to use */ public HttpConnection(HostConfiguration hostConfiguration) { this(hostConfiguration.getProxyHost(), hostConfiguration.getProxyPort(), hostConfiguration.getHost(), hostConfiguration.getPort(), hostConfiguration.getProtocol()); this.localAddress = hostConfiguration.getLocalAddress(); }
httpConnection.setPort(hostConfiguration.getPort()); httpConnection.setProtocol(hostConfiguration.getProtocol()); httpConnection.setLocalAddress(hostConfiguration.getLocalAddress());
/** * @param username * @param password * @param httpClient */ public static void setCredentials(String username, String password, HttpClient httpClient) { if (username != null && password != null && httpClient != null) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Setting credentials with username " + username + " for host " + httpClient.getHostConfiguration().getHost() + ":" + httpClient.getHostConfiguration().getPort()); } httpClient.getParams().setAuthenticationPreemptive(true); httpClient.getState().setCredentials( new AuthScope(httpClient.getHostConfiguration().getHost(), httpClient.getHostConfiguration().getPort(), AuthScope.ANY_REALM), new UsernamePasswordCredentials(username, password)); } }
/** * Returns the default port. * * @return The default port. * * @deprecated use #getHostConfiguration() */ public int getPort() { return hostConfiguration.getPort(); }
/** * Returns the default port. * * @return The default port. * * @deprecated use #getHostConfiguration() */ public int getPort() { return hostConfiguration.getPort(); }
/** * Returns the default port. * * @return The default port. * * @deprecated use #getHostConfiguration() */ public int getPort() { return hostConfiguration.getPort(); }
/** * Returns the default port. * * @return The default port. * * @deprecated use #getHostConfiguration() */ public int getPort() { return hostConfiguration.getPort(); }
/** * @param proxy * @param httpClient */ public static void setProxy(Proxy proxy, HttpClient httpClient) { if (proxy != null && httpClient != null) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Setting proxy with host " + proxy.getHost() + " and port " + proxy.getPort() + " for host " + httpClient.getHostConfiguration().getHost() + ":" + httpClient.getHostConfiguration().getPort()); } httpClient.getHostConfiguration().setProxy(proxy.getHost(), proxy.getPort()); if (proxy.getUserName() != null && proxy.getPassword() != null) { httpClient.getState().setProxyCredentials(AuthScope.ANY, new UsernamePasswordCredentials(proxy.getUserName(), proxy.getPassword())); } } }
public int getPort() { return httpClient.getHostConfiguration().getPort(); }
/** * Creates a new HTTP connection for the given host configuration. * * @param hostConfiguration the host/proxy/protocol to use */ public HttpConnection(HostConfiguration hostConfiguration) { this(hostConfiguration.getProxyHost(), hostConfiguration.getProxyPort(), hostConfiguration.getHost(), hostConfiguration.getPort(), hostConfiguration.getProtocol()); this.localAddress = hostConfiguration.getLocalAddress(); }
/** * Creates a new HTTP connection for the given host configuration. * * @param hostConfiguration the host/proxy/protocol to use */ public HttpConnection(HostConfiguration hostConfiguration) { this(hostConfiguration.getProxyHost(), hostConfiguration.getProxyPort(), hostConfiguration.getHost(), hostConfiguration.getPort(), hostConfiguration.getProtocol()); this.localAddress = hostConfiguration.getLocalAddress(); }
/** * Creates a new HTTP connection for the given host configuration. * * @param hostConfiguration the host/proxy/protocol to use */ public HttpConnection(HostConfiguration hostConfiguration) { this(hostConfiguration.getProxyHost(), hostConfiguration.getProxyPort(), hostConfiguration.getHost(), hostConfiguration.getPort(), hostConfiguration.getProtocol()); this.localAddress = hostConfiguration.getLocalAddress(); }
/** * Creates a new HTTP connection for the given host configuration. * * @param hostConfiguration the host/proxy/protocol to use */ public HttpConnection(HostConfiguration hostConfiguration) { this(hostConfiguration.getProxyHost(), hostConfiguration.getProxyPort(), hostConfiguration.getHost(), hostConfiguration.getPort(), hostConfiguration.getProtocol()); this.localAddress = hostConfiguration.getLocalAddress(); }
/** * Creates a new HTTP connection for the given host configuration. * * @param hostConfiguration the host/proxy/protocol to use */ public HttpConnection(HostConfiguration hostConfiguration) { this(hostConfiguration.getProxyHost(), hostConfiguration.getProxyPort(), hostConfiguration.getHost(), hostConfiguration.getPort(), hostConfiguration.getProtocol()); this.localAddress = hostConfiguration.getLocalAddress(); }
public static URI newURI(HttpMethod m, HostConfiguration conf) throws URIException { String scheme = conf.getProtocol().getScheme(); String host = conf.getHost(); int port = conf.getPort(); return new URIBuilder().getURI(scheme, host, port, m.getPath(), m.getQueryString(), m.getParams()); } }
@Test public void testDistribution() { // default seed gives /woof Pair<HttpClient, String> distributor = wrapper.getHttpClientAndBaseUrl(); assertNotNull(distributor); assertEquals("/woof-14", distributor.getSecond()); assertEquals("common", distributor.getFirst().getHostConfiguration().getHost()); assertEquals(999, distributor.getFirst().getHostConfiguration().getPort()); }
@Test public void testUnsharded() { assertTrue(unshardedWrapper.isSharded() == false); Pair<HttpClient, String> distributor = unshardedWrapper.getHttpClientAndBaseUrl(); assertNotNull(distributor); assertEquals("/solr4", distributor.getSecond()); assertEquals("common", distributor.getFirst().getHostConfiguration().getHost()); assertEquals(999, distributor.getFirst().getHostConfiguration().getPort()); }