org.apache.commons.httpclient.HostConfiguration.getHost()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(105)

本文整理了Java中org.apache.commons.httpclient.HostConfiguration.getHost()方法的一些代码示例,展示了HostConfiguration.getHost()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HostConfiguration.getHost()方法的具体详情如下:
包路径:org.apache.commons.httpclient.HostConfiguration
类名称:HostConfiguration
方法名:getHost

HostConfiguration.getHost介绍

[英]Returns the host.
[中]返回主机。

代码示例

代码示例来源:origin: commons-httpclient/commons-httpclient

/**
 * Returns the default host. 
 *
 * @return The default host.
 * 
 * @deprecated use #getHostConfiguration()
 */
 public String getHost() {
   return hostConfiguration.getHost();
 }

代码示例来源:origin: commons-httpclient/commons-httpclient

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 "/";
  }
}

代码示例来源:origin: commons-httpclient/commons-httpclient

/**
 * 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;
  }
}

代码示例来源:origin: commons-httpclient/commons-httpclient

/**
 * 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();
}

代码示例来源:origin: commons-httpclient/commons-httpclient

throw new IllegalStateException("proxy host must be configured");
if (hostconf.getHost() == null) {
  throw new IllegalStateException("destination host must be configured");

代码示例来源:origin: commons-httpclient/commons-httpclient

httpConnection.setHost(hostConfiguration.getHost());
httpConnection.setPort(hostConfiguration.getPort());
httpConnection.setProtocol(hostConfiguration.getProtocol());

代码示例来源:origin: apache/cloudstack

/**
 * @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));
  }
}

代码示例来源:origin: org.apache.commons/httpclient

/**
 * Returns the default host. 
 *
 * @return The default host.
 * 
 * @deprecated use #getHostConfiguration()
 */
 public String getHost() {
   return hostConfiguration.getHost();
 }

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-httpclient

/**
 * Returns the default host. 
 *
 * @return The default host.
 * 
 * @deprecated use #getHostConfiguration()
 */
 public String getHost() {
   return hostConfiguration.getHost();
 }

代码示例来源:origin: org.wso2.commons-httpclient/commons-httpclient

/**
 * Returns the default host. 
 *
 * @return The default host.
 * 
 * @deprecated use #getHostConfiguration()
 */
 public String getHost() {
   return hostConfiguration.getHost();
 }

代码示例来源:origin: org.apache.commons/com.springsource.org.apache.commons.httpclient

/**
 * Returns the default host. 
 *
 * @return The default host.
 * 
 * @deprecated use #getHostConfiguration()
 */
 public String getHost() {
   return hostConfiguration.getHost();
 }

代码示例来源:origin: apache/cloudstack

/**
 * @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()));
    }
  }
}

代码示例来源:origin: mguessan/davmail

protected String getEmailSuffixFromHostname() {
  String domain = httpClient.getHostConfiguration().getHost();
  int start = domain.lastIndexOf('.', domain.lastIndexOf('.') - 1);
  if (start >= 0) {
    return '@' + domain.substring(start + 1);
  } else {
    return '@' + domain;
  }
}

代码示例来源:origin: org.alfresco/alfresco-repository

public String getHost()
{
  return httpClient.getHostConfiguration().getHost();
}

代码示例来源:origin: org.mule.transports/mule-transport-http

/**
 * 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();
}

代码示例来源:origin: org.apache.commons/com.springsource.org.apache.commons.httpclient

/**
 * 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();
}

代码示例来源:origin: org.wso2.commons-httpclient/commons-httpclient

/**
 * 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();
}

代码示例来源:origin: smartrics/RestFixture

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());
  }
}

代码示例来源:origin: Alfresco/alfresco-repository

@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());
}

代码示例来源:origin: Alfresco/alfresco-repository

@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());
}

相关文章