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


Java HttpHost.toURI方法代码示例

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


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

示例1: getModSlug0

import org.apache.http.HttpHost; //导入方法依赖的package包/类
@Nullable
private String getModSlug0(int id)
{
    try
    {
        log.debug("Getting mod slug from server...");
        URI uri = getURI(CURSEFORGE_URL, String.format(PROJECT_PATH, id), null);
        HttpGet request = new HttpGet(uri.toURL().toString());
        HttpContext context = new BasicHttpContext();
        HttpResponse response = http.execute(request, context);
        EntityUtils.consume(response.getEntity());
        HttpUriRequest currentReq = (HttpUriRequest) context.getAttribute(HttpCoreContext.HTTP_REQUEST);
        HttpHost currentHost = (HttpHost) context.getAttribute(HttpCoreContext.HTTP_TARGET_HOST);
        String currentUrl = (currentReq.getURI().isAbsolute()) ? currentReq.getURI().toString() : (currentHost.toURI() + currentReq.getURI());
        Splitter splitter = Splitter.on('/').omitEmptyStrings();
        List<String> pathParts = splitter.splitToList(currentUrl);
        return pathParts.get(pathParts.size() - 1);
    }
    catch (Exception e)
    {
        log.error("Failed to perform request from CurseForge site.", e);
        return null;
    }
}
 
开发者ID:PaleoCrafter,项目名称:CurseSync,代码行数:25,代码来源:CurseAPI.java

示例2: getHttpResponse

import org.apache.http.HttpHost; //导入方法依赖的package包/类
/**
 * Send the specified GET request to the indicated host.
 * 
 * @param host target HTTP host connection
 * @param request request path (may include parameters)
 * @return host response for the specified GET request
 * @throws IOException The request triggered an I/O exception
 */
public static HttpResponse getHttpResponse(HttpHost host, String request) throws IOException {
    HttpClient client = HttpClientBuilder.create().build();
    URL sessionURL = new URL(host.toURI() + request);
    BasicHttpEntityEnclosingRequest basicHttpEntityEnclosingRequest = 
            new BasicHttpEntityEnclosingRequest("GET", sessionURL.toExternalForm());
    return client.execute(host, basicHttpEntityEnclosingRequest);
}
 
开发者ID:Nordstrom,项目名称:Selenium-Foundation,代码行数:16,代码来源:GridUtility.java


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