當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。