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

x33g5p2x  于2022-01-31 转载在 其他  
字(6.5k)|赞(0)|评价(0)|浏览(133)

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

URI.getHost介绍

[英]Get the host.

host          = hostname | IPv4address | IPv6reference

[中]找主持人。

host          = hostname | IPv4address | IPv6reference

代码示例

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

/**
 * URI constructor for HttpHost.
 *   
 * @param uri the URI.
 */
public  HttpHost(final URI uri) throws URIException {
  this(uri.getHost(), uri.getPort(), Protocol.getProtocol(uri.getScheme()));
}

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

/**
 * Sets the protocol, host and port from the given URI.
 * @param uri the URI.
 */
public synchronized void setHost(final URI uri) {
  try {
    setHost(uri.getHost(), uri.getPort(), uri.getScheme());
  } catch (URIException e) {
    throw new IllegalArgumentException(e.toString());
  }
}

代码示例来源:origin: apache/incubator-pinot

getMethod = completionService.take().get();
URI uri = getMethod.getURI();
String instance = endpointsToServers.get(uri.getHost() + ":" + uri.getPort());
if (getMethod.getStatusCode() >= 300) {
 LOGGER.error("Server: {} returned error: {}", instance, getMethod.getStatusCode());

代码示例来源:origin: geotools/geotools

/**
 * @param method
 * @return the http status code of the execution
 * @throws IOException
 * @throws HttpException
 */
private int executeMethod(HttpMethod method) throws IOException, HttpException {
  String host = method.getURI().getHost();
  if (host != null && nonProxyHosts.contains(host.toLowerCase())) {
    if (LOGGER.isLoggable(Level.FINE)) {
      LOGGER.fine(
          "Bypassing proxy config due to nonProxyHosts for "
              + method.getURI().toString());
    }
    return client.executeMethod(hostConfigNoProxy, method);
  }
  return client.executeMethod(method);
}

代码示例来源:origin: org.zaproxy/zap

/**
 * Get the host name in this request header.
 *
 * @return Host name.
 */
public String getHostName() {
  String hostName = mHostName;
  try {
    // ZAP: fixed cases, where host name is null
    hostName = ((mUri.getHost() != null) ? mUri.getHost() : mHostName);
    
  } catch (URIException e) {
    if (log.isDebugEnabled()) {
      log.warn(e);
    }
  }
  
  return hostName;
}

代码示例来源:origin: org.zaproxy/zap

public static String getHostName(URI uri) throws URIException {
  StringBuilder host = new StringBuilder(); 				
  
  String scheme = uri.getScheme().toLowerCase();
  host.append(scheme).append("://").append(uri.getHost());
  
  int port = uri.getPort();		
  if (port != -1 &&
      ((port == 80 && !"http".equals(scheme)) ||
      (port == 443 && !"https".equals(scheme) ||
      (port != 80 && port != 443)))) {
    host.append(":").append(port);
  }
  
  return host.toString();
}

代码示例来源:origin: org.zaproxy/zap

private static String createBaseUri(org.apache.commons.httpclient.URI uri) throws URIException {
  StringBuilder baseUriBuilder = new StringBuilder();
  baseUriBuilder.append(uri.getScheme()).append("://").append(uri.getHost());
  if (uri.getPort() != -1) {
    baseUriBuilder.append(':').append(uri.getPort());
  }
  return baseUriBuilder.toString();
}

代码示例来源:origin: org.restlet/org.restlet.ext.httpclient

/**
 * Returns the response address.<br>
 * Corresponds to the IP address of the responding server.
 * 
 * @return The response address.
 */
@Override
public String getServerAddress() {
  try {
    return getHttpMethod().getURI().getHost();
  } catch (URIException e) {
    return null;
  }
}

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

/**
 * URI constructor for HttpHost.
 *   
 * @param uri the URI.
 */
public  HttpHost(final URI uri) throws URIException {
  this(uri.getHost(), uri.getPort(), Protocol.getProtocol(uri.getScheme()));
}

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

@SuppressWarnings("unused")
  public synchronized void setHost(URI uri)
  {
    try {
      setHost(uri.getHost(), uri.getPort(), uri.getScheme());
    } catch(URIException e) {
      throw new IllegalArgumentException(e.toString());
    }
  }
}

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

/**
 * URI constructor for HttpHost.
 *   
 * @param uri the URI.
 */
public  HttpHost(final URI uri) throws URIException {
  this(uri.getHost(), uri.getPort(), Protocol.getProtocol(uri.getScheme()));
}

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

/**
 * Sets the protocol, host and port from the given URI.
 * @param uri the URI.
 */
public synchronized void setHost(final URI uri) {
  try {
    setHost(uri.getHost(), uri.getPort(), uri.getScheme());
  } catch (URIException e) {
    throw new IllegalArgumentException(e.toString());
  }
}

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

/**
 * Sets the protocol, host and port from the given URI.
 * @param uri the URI.
 */
public synchronized void setHost(final URI uri) {
  try {
    setHost(uri.getHost(), uri.getPort(), uri.getScheme());
  } catch (URIException e) {
    throw new IllegalArgumentException(e.toString());
  }
}

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

/**
 * Sets the protocol, host and port from the given URI.
 * @param uri the URI.
 */
public synchronized void setHost(final URI uri) {
  try {
    setHost(uri.getHost(), uri.getPort(), uri.getScheme());
  } catch (URIException e) {
    throw new IllegalArgumentException(e.toString());
  }
}

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

protected void fixClientHost(HttpMethod method) {
  try {
    // update client host, workaround for Exchange 2003 mailbox with an Exchange 2007 frontend
    URI currentUri = method.getURI();
    if (currentUri != null && currentUri.getHost() != null && currentUri.getScheme() != null) {
      httpClient.getHostConfiguration().setHost(currentUri.getHost(), currentUri.getPort(), currentUri.getScheme());
    }
  } catch (URIException e) {
    LOGGER.warn("Unable to update http client host:" + e.getMessage(), e);
  }
}

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

/**
 * URI constructor for HttpHost.
 *   
 * @param uri the URI.
 */
public  HttpHost(final URI uri) throws URIException {
  this(uri.getHost(), uri.getPort(), Protocol.getProtocol(uri.getScheme()));
}

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

/**
 * Sets the protocol, host and port from the given URI.
 * @param uri the URI.
 */
public synchronized void setHost(final URI uri) {
  try {
    setHost(uri.getHost(), uri.getPort(), uri.getScheme());
  } catch (URIException e) {
    throw new IllegalArgumentException(e.toString());
  }
}

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

/**
 * URI constructor for HttpHost.
 *   
 * @param uri the URI.
 */
public  HttpHost(final URI uri) throws URIException {
  this(uri.getHost(), uri.getPort(), Protocol.getProtocol(uri.getScheme()));
}

代码示例来源:origin: deas/alfresco

@SuppressWarnings("unused")
  public synchronized void setHost(URI uri)
  {
    try {
      setHost(uri.getHost(), uri.getPort(), uri.getScheme());
    } catch(URIException e) {
      throw new IllegalArgumentException(e.toString());
    }
  }
}

代码示例来源:origin: org.zaproxy/zap

@Override
  public synchronized void setHost(URI uri) {
    try {
      setHost(new HttpHost(uri.getHost(), uri.getPort(), getProtocol()));
    } catch (URIException e) {
      throw new IllegalArgumentException(e.toString());
    }
  };
};

相关文章