当前位置: 首页>>代码示例>>Java>>正文


Java URIUtils.extractHost方法代码示例

本文整理汇总了Java中org.apache.http.client.utils.URIUtils.extractHost方法的典型用法代码示例。如果您正苦于以下问题:Java URIUtils.extractHost方法的具体用法?Java URIUtils.extractHost怎么用?Java URIUtils.extractHost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.http.client.utils.URIUtils的用法示例。


在下文中一共展示了URIUtils.extractHost方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: OTSUri

import org.apache.http.client.utils.URIUtils; //导入方法依赖的package包/类
public OTSUri(String endpoint, String action) {
    this.action = action;

    final String delimiter = "/";
    if (!endpoint.endsWith(delimiter)) {
        endpoint += delimiter;
    }

    // keep only one '/' in the end
    int index = endpoint.length() - 1;
    while (index > 0 && endpoint.charAt(index - 1) == '/') {
        index--;
    }

    endpoint = endpoint.substring(0, index + 1);

    try {
        this.uri = new URI(endpoint + action);
    } catch (URISyntaxException e) {
        throw new IllegalArgumentException("The endpoint is invalid.", e);
    }

    this.host = URIUtils.extractHost(uri);
}
 
开发者ID:aliyun,项目名称:aliyun-tablestore-java-sdk,代码行数:25,代码来源:OTSUri.java

示例2: initTarget

import org.apache.http.client.utils.URIUtils; //导入方法依赖的package包/类
protected void initTarget() throws ServletException {
    // TODO - should get the Kibana URI from Settings.java
//    targetUri = Settings.getKibanaUri();
    targetUri = settings.getYarnWebUIAddress();
    if (!targetUri.contains("http://")) {
      targetUri = "http://" + targetUri;
    }
    if (targetUri == null) {
      throw new ServletException(P_TARGET_URI + " is required.");
    }
    //test it's valid
    try {
      targetUriObj = new URI(targetUri);
    } catch (Exception e) {
      throw new ServletException("Trying to process targetUri init parameter: "
          + e, e);
    }
    targetHost = URIUtils.extractHost(targetUriObj);
  }
 
开发者ID:hopshadoop,项目名称:hopsworks,代码行数:20,代码来源:YarnUIProxyServlet.java

示例3: initTarget

import org.apache.http.client.utils.URIUtils; //导入方法依赖的package包/类
protected void initTarget() throws ServletException {
    // TODO - should get the Kibana URI from Settings.java
//    targetUri = Settings.getKibanaUri();
    targetUri = getConfigParam(P_TARGET_URI);
    if (targetUri == null) {
      throw new ServletException(P_TARGET_URI + " is required.");
    }
    //test it's valid
    try {
      targetUriObj = new URI(targetUri);
    } catch (Exception e) {
      throw new ServletException("Trying to process targetUri init parameter: "
          + e, e);
    }
    targetHost = URIUtils.extractHost(targetUriObj);
  }
 
开发者ID:hopshadoop,项目名称:hopsworks,代码行数:17,代码来源:ProxyServlet.java

示例4: createSession

import org.apache.http.client.utils.URIUtils; //导入方法依赖的package包/类
public void createSession(String alias, String url, Map<String, String> headers, Authentication auth, String verify,
		Boolean debug, String loggerClass, String password, boolean verifyHost, boolean selfSigned, Proxy proxy) {

	HostnameVerifier defaultHostnameVerifier = verifyHost ? null : NoopHostnameVerifier.INSTANCE;
	TrustStrategy trustStrategy = selfSigned ? new TrustSelfSignedStrategy() : null;

	if (!loggerClass.isEmpty()) {
		System.setProperty("org.apache.commons.logging.Log", loggerClass);
		System.setProperty("org.apache.commons.logging.robotlogger.log.org.apache.http", debug ? "DEBUG" : "INFO");
	}
	HttpHost target;
	try {
		target = URIUtils.extractHost(new URI(url));
	} catch (URISyntaxException e) {
		throw new RuntimeException("Parsing of URL failed. Error message: " + e.getMessage());
	}
	Session session = new Session();
	session.setProxy(proxy);
	session.setContext(this.createContext(auth, target));
	session.setClient(this.createHttpClient(auth, verify, target, false, password, null, null, proxy));
	session.setUrl(url);
	session.setHeaders(headers);
	session.setHttpHost(target);
	session.setVerify(verify);
	session.setAuthentication(auth);
	session.setPassword(password);
	session.setHostnameVerifier(defaultHostnameVerifier);
	session.setTrustStrategy(trustStrategy);
	sessions.put(alias, session);
}
 
开发者ID:Hi-Fi,项目名称:httpclient,代码行数:31,代码来源:RestClient.java

示例5: determineTarget

import org.apache.http.client.utils.URIUtils; //导入方法依赖的package包/类
public static HttpHost determineTarget(final HttpUriRequest request) throws ClientProtocolException {
    // A null target may be acceptable if there is a default target.
    // Otherwise, the null target is detected in the director.
    HttpHost target = null;

    final URI requestURI = request.getURI();
    if (requestURI.isAbsolute()) {
        target = URIUtils.extractHost(requestURI);
        if (target == null) {
            throw new ClientProtocolException("URI does not specify a valid host name: "
                    + requestURI);
        }
    }
    return target;
}
 
开发者ID:aws,项目名称:aws-xray-sdk-java,代码行数:16,代码来源:TracedHttpClient.java

示例6: determineTarget

import org.apache.http.client.utils.URIUtils; //导入方法依赖的package包/类
private static HttpHost determineTarget(HttpUriRequest request) throws ClientProtocolException {
    // A null target may be acceptable if there is a default target.
    // Otherwise, the null target is detected in the director.
    HttpHost target = null;

    URI requestURI = request.getURI();
    if (requestURI.isAbsolute()) {
        target = URIUtils.extractHost(requestURI);
        if (target == null) {
            throw new ClientProtocolException(
                    "URI does not specify a valid host name: " + requestURI);
        }
    }
    return target;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:16,代码来源:AbstractHttpClient.java

示例7: getHttpHost

import org.apache.http.client.utils.URIUtils; //导入方法依赖的package包/类
public static HttpHost getHttpHost(String serverUrl) {
    HttpHost host = null;
    //determine host name
    HttpGet serverGet = new HttpGet(serverUrl);
    final URI requestURI = serverGet.getURI();
    if (requestURI.isAbsolute()) {
        host = URIUtils.extractHost(requestURI);
    }
    return host;
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:11,代码来源:MCRHttpUtils.java

示例8: configureDomainForCookie

import org.apache.http.client.utils.URIUtils; //导入方法依赖的package包/类
/**
 *  It configures the cookie domain with the domain of the Apache CloudStack that is being accessed.
 *  The domain is extracted from {@link #url} variable.
 */
protected void configureDomainForCookie(BasicClientCookie cookie) {
    try {
        HttpHost httpHost = URIUtils.extractHost(new URI(url));
        String domain = httpHost.getHostName();
        cookie.setDomain(domain);
    } catch (URISyntaxException e) {
        throw new ApacheCloudStackClientRuntimeException(e);
    }
}
 
开发者ID:Autonomiccs,项目名称:apache-cloudstack-java-client,代码行数:14,代码来源:ApacheCloudStackClient.java

示例9: determineTarget

import org.apache.http.client.utils.URIUtils; //导入方法依赖的package包/类
private static HttpHost determineTarget(final HttpUriRequest request) throws ClientProtocolException {
    // A null target may be acceptable if there is a default target.
    // Otherwise, the null target is detected in the director.
    HttpHost target = null;

    final URI requestURI = request.getURI();
    if (requestURI.isAbsolute()) {
        target = URIUtils.extractHost(requestURI);
        if (target == null) {
            throw new ClientProtocolException("URI does not specify a valid host name: "
                    + requestURI);
        }
    }
    return target;
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:16,代码来源:CloseableHttpClient.java

示例10: determineTarget

import org.apache.http.client.utils.URIUtils; //导入方法依赖的package包/类
private static HttpHost determineTarget(final HttpUriRequest request) throws ClientProtocolException {
  HttpHost target = null;
  final URI requestURI = request.getURI();
  if (requestURI.isAbsolute()) {
    target = URIUtils.extractHost(requestURI);
    if (target == null) {
      throw new ClientProtocolException("URI does not specify a valid host name: " + requestURI);
    }
  }
  return target;
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:12,代码来源:FilteredHttpClientSupport.java

示例11: ClientConfig

import org.apache.http.client.utils.URIUtils; //导入方法依赖的package包/类
/**
 * Constructor
 *
 * @param endpoint the endpoint; {@link APUtil#TEST_ENDPOINT} / {@link APUtil#LIVE_ENDPOINT}
 *
 * @throws IllegalArgumentException on invalid URI
 */
public ClientConfig(final String endpoint) {
    if (StringUtils.isBlank(endpoint)) {
        throw new IllegalArgumentException("Invalid endpoint: " + endpoint);
    }
    endpointHost = URIUtils.extractHost(URI.create(endpoint));
    if (endpointHost == null) {
        throw new IllegalArgumentException("Invalid endpoint: " + endpoint);
    }
    this.endpoint = endpoint;
}
 
开发者ID:woki,项目名称:adyen-api,代码行数:18,代码来源:ClientConfig.java

示例12: HopsServletHandler

import org.apache.http.client.utils.URIUtils; //导入方法依赖的package包/类
public HopsServletHandler(HttpServletRequest request,
        HttpServletResponse response,
        Transport transport, URI targetUriObj) throws IOException {
  super(transport);
  this.request = request;
  this.response = response;
  this.targetUriObj = targetUriObj;
  this.targetHost = URIUtils.extractHost(targetUriObj);

  exchange = new Exchange(this);

  exchange.setProperty(Exchange.HTTP_SERVLET_REQUEST, request);
}
 
开发者ID:hopshadoop,项目名称:hopsworks,代码行数:14,代码来源:HopsServletHandler.java

示例13: initTarget

import org.apache.http.client.utils.URIUtils; //导入方法依赖的package包/类
protected void initTarget() throws ServletException {
    // TODO - should get the Kibana URI from Settings.java
//    targetUri = Settings.getKibanaUri();
    targetUri = settings.getHDFSWebUIAddress();
  
    if (targetUri == null) {
      throw new ServletException(P_TARGET_URI + " is required.");
    }
    
    if (settings.getHopsRpcTls()) {
      if (!targetUri.contains("https://")) {
        targetUri = "https://" + targetUri;
      }
    } else {
      if (!targetUri.contains("http://")) {
        targetUri = "http://" + targetUri;
      }
    }
    
    //test it's valid
    try {
      targetUriObj = new URI(targetUri);
    } catch (Exception e) {
      throw new ServletException("Trying to process targetUri init parameter: "
          + e, e);
    }
    targetHost = URIUtils.extractHost(targetUriObj);
  }
 
开发者ID:hopshadoop,项目名称:hopsworks,代码行数:29,代码来源:HDFSUIProxyServlet.java

示例14: initTarget

import org.apache.http.client.utils.URIUtils; //导入方法依赖的package包/类
protected void initTarget() throws ServletException {
    targetUri = getConfigParam(P_TARGET_URI);
    if (targetUri == null)
        throw new ServletException(P_TARGET_URI + " is required.");
    // test it's valid
    try {
        targetUriObj = new URI(targetUri);
    } catch (Exception e) {
        throw new ServletException("Trying to process targetUri init parameter: " + e, e);
    }
    targetHost = URIUtils.extractHost(targetUriObj);
}
 
开发者ID:sercxtyf,项目名称:onboard,代码行数:13,代码来源:ApiProxyServlet.java

示例15: validate

import org.apache.http.client.utils.URIUtils; //导入方法依赖的package包/类
/**
 * Validates URI
 *
 * @param url
 * @throws UrlValidationException is thrown when URL is in illegal form.
 */
public void validate(String url) throws UrlValidationException {

    if (!PathUtils.hasText(url)) {
        throw new RuntimeException("The URL cannot be empty");
    }

    try {
        URI parsedUri = new URIBuilder(url).build();
        String scheme = parsedUri.getScheme();
        if (!isAnySchemaAllowed() && StringUtils.isBlank(scheme)) {

            throw new UrlValidationException(String.format(
                    "Url scheme cannot be empty. The following schemes are allowed: %s. " +
                            "For example: %s://host",
                    Arrays.asList(allowedSchemes), allowedSchemes[0]
            ));


        } else if (!isAllowedSchema(scheme)) {
            throw new UrlValidationException(String.format(
                    "Scheme '%s' is not allowed. The following schemes are allowed: %s",
                    scheme, Arrays.asList(allowedSchemes)));
        }

        HttpHost host = URIUtils.extractHost(parsedUri);
        if (host == null) {
            throw new UrlValidationException("Cannot resolve host from url: " + url);
        }
    } catch (URISyntaxException e) {
        throw new UrlValidationException(String.format("'%s' is not a valid url", url));
    }
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:39,代码来源:UrlValidator.java


注:本文中的org.apache.http.client.utils.URIUtils.extractHost方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。